working afsk packets

This commit is contained in:
morgan 2016-09-24 17:33:00 -07:00
parent b9f75e0c11
commit 4ff3f7d9d0
2 changed files with 43 additions and 58 deletions

View File

@ -13,7 +13,6 @@
*/
#define DDS_REFCLK_DEFAULT 9600
#include <HamShield.h>
#include <DDS.h>
@ -63,14 +62,15 @@ void setup() {
Serial.println("HELLO");
}
String temp[1] = "";
void loop() {
if(Serial.available()) {
char temp = (char)Serial.read();
if(temp == '`') {
prepMessage(); msgptr = 0; Serial.print("!!"); }
//Serial.println(messagebuff);
prepMessage();
msgptr = 0;
Serial.print("!!");
}
else {
messagebuff += temp;
msgptr++;
@ -79,7 +79,6 @@ void loop() {
if(msgptr > 254) { messagebuff = ""; Serial.print("X!"); }
if(afsk.decoder.read() || afsk.rxPacketCount()) {
Serial.println("got pkt");
// A true return means something was put onto the packet FIFO
// If we actually have data packets in the buffer, process them all now
while(afsk.rxPacketCount()) {
@ -96,16 +95,16 @@ void loop() {
void prepMessage() {
radio.setModeTransmit();
delay(500);
delay(1000);
origin_call = messagebuff.substring(0,messagebuff.indexOf(',')); // get originating callsign
destination_call = messagebuff.substring(messagebuff.indexOf(',')+1,
messagebuff.indexOf(',',messagebuff.indexOf(',')+1)); // get the destination call
textmessage = messagebuff.substring(messagebuff.indexOf(":"));
destination_call = messagebuff.substring(messagebuff.indexOf(',')+1,messagebuff.indexOf(',',messagebuff.indexOf(',')+1)); // get the destination call
textmessage = messagebuff.substring(messagebuff.indexOf(":")+1);
// Serial.print("From: "); Serial.print(origin_call); Serial.print(" To: "); Serial.println(destination_call); Serial.println("Text: "); Serial.println(textmessage);
AFSK::Packet *packet = AFSK::PacketBuffer::makePacket(22 + 32);
packet->start();
packet->appendFCS(HDLC_FRAME);
packet->appendCallsign(origin_call.c_str(),0);
packet->appendCallsign(destination_call.c_str(),15,true);
packet->appendFCS(0x03);
@ -113,13 +112,11 @@ void prepMessage() {
packet->print(textmessage);
packet->finish();
textmessage = "";
bool ret = afsk.putTXPacket(packet);
if(afsk.txReady()) {
Serial.println(F("txReady"));
//radio.setModeTransmit();
radio.setModeTransmit();
//delay(100);
if(afsk.txStart()) {
Serial.println(F("txStart"));
@ -137,19 +134,15 @@ void prepMessage() {
delay(50);
}
Serial.println("Done sending");
delay(3000);
radio.setModeReceive();
}
// TODO: d2 is now our switch, so don't write to that
ISR(TIMER2_OVF_vect) {
TIFR2 = _BV(TOV2);
static uint8_t tcnt = 0;
if(++tcnt == 8) {
//digitalWrite(2, HIGH);
dds.clockTick();
//digitalWrite(2, LOW);
tcnt = 0;
}
}
@ -157,15 +150,9 @@ ISR(TIMER2_OVF_vect) {
ISR(ADC_vect) {
static uint8_t tcnt = 0;
TIFR1 = _BV(ICF1); // Clear the timer flag
//PORTD |= _BV(2); // Diagnostic pin (D2)
dds.clockTick();
if(++tcnt == 1) {
//if(afsk.encoder.isSending())
{
afsk.timer();
}
tcnt = 0;
}
//PORTD &= ~(_BV(2)); // Pin D2 off again
}

View File

@ -18,7 +18,6 @@ DDS dds;
KISS kiss(&Serial, &radio, &dds);
AFSK afsk;
//TODO: move these into library
#define PWM_PIN 3
#define RESET_PIN A3
#define SWITCH_PIN 2
@ -45,7 +44,6 @@ void setup() {
radio.initialize();
radio.setSQOff();
radio.frequency(144390);
//I2Cdev::writeWord(A1846S_DEV_ADDR_SENLOW, 0x44, 0x05FF);
dds.start();
afsk.start(&dds);