Added example

master
Mark Qvist 2014-06-23 22:26:01 +02:00
parent 9b988a51a3
commit 4bc8b92308
4 changed files with 42 additions and 9 deletions

View File

@ -1,14 +1,14 @@
#include <TelemetryKit.h>
void telemetryKitCallback(char *packet, size_t length) {
Serial.print("Received packet: ");
packet[length] = 0; // Null terminate string for println
Serial.print("Received "); Serial.print(length); Serial.println(" bytes: ");
Serial.println(packet);
}
void setup() {
extern Afsk modem;
Serial.begin(9600);
TelemetryKitInit();
}

View File

@ -0,0 +1,38 @@
#include <TelemetryKit.h>
#define BUFFER_SIZE 256
#define TX_EVERY_N 2
int count = 0;
size_t readLength = 0;
unsigned long time = 0;
char buffer[BUFFER_SIZE];
void telemetryKitCallback(char *packet, size_t length) { }
void setup() {
Serial.begin(38400); // Set this to baudrate of GPS
TelemetryKitInit();
}
void loop() {
while (Serial.available() && readLength < BUFFER_SIZE) {
buffer[readLength++] = Serial.read();
time = millis();
}
if (millis() - time > 4 && readLength > 0) {
if (count+1 == TX_EVERY_N) {
Serial.print("Transmitting "); Serial.print(readLength); Serial.println(" bytes");
TelemetryKitTransmit(buffer, readLength);
readLength = 0;
count = 0;
} else {
count++;
readLength = 0;
}
}
}

View File

@ -6,7 +6,6 @@ void telemetryKitCallback(char *packet, size_t length) {
}
void setup() {
extern Afsk modem;
Serial.begin(9600);
TelemetryKitInit();

View File

@ -1,12 +1,8 @@
#include <TelemetryKit.h>
void telemetryKitCallback(char *packet, size_t length) {
Serial.print("Received packet: ");
Serial.println(packet);
}
void telemetryKitCallback(char *packet, size_t length) { }
void setup() {
extern Afsk modem;
Serial.begin(9600);
TelemetryKitInit();