Fix a compile error. Add a quick callsign appending string method.

This commit is contained in:
Stephen Olesen 2015-07-02 02:38:28 -06:00
parent 4a8e9c69e6
commit 0e9a549f56
3 changed files with 32 additions and 16 deletions

View File

@ -477,6 +477,28 @@ size_t AFSK::Packet::write(const uint8_t *ptr, size_t len) {
return i;
}
// Add a callsign, flagged as source, destination, or digi
// Also tell the routine the SSID to use and if this is the final callsign
size_t AFSK::Packet::appendCallsign(const char *callsign, uint8_t ssid, bool final) {
uint8_t i;
for(i = 0; i < strlen(callsign) && i < 6; i++) {
appendFCS(callsign[i]<<1);
}
if(i < 6) {
for(;i<6;i++) {
appendFCS(' '<<1);
}
}
uint8_t ssidField = (ssid&0xf) << 1;
// TODO: Handle digis in the address C bit
if(final) {
ssidField |= 0b01100001;
} else {
ssidField |= 0b11100000;
}
appendFCS(ssidField);
}
// Determine what we want to do on this ADC tick.
void AFSK::timer() {
if(encoder.isSending())

6
AFSK.h
View File

@ -14,6 +14,10 @@
#define PACKET_BUFFER_SIZE 2
#define PACKET_STATIC 0
// If this is set, all the packet buffers will be pre-allocated at compile time
// This will use more RAM, but can make it easier to do memory planning.
// TODO: Make this actually work right and not crash.
//#define PACKET_PREALLOCATE
// This is with all the digis, two addresses, framing and full payload
@ -87,6 +91,8 @@ public:
return false;
}
size_t appendCallsign(const char *callsign, uint8_t ssid, bool final = false);
inline void finish() {
append(~(fcs & 0xff));
append(~((fcs>>8) & 0xff));

View File

@ -31,20 +31,8 @@ void loop() {
// put your main code here, to run repeatedly:
AFSK::Packet *packet = AFSK::PacketBuffer::makePacket(22 + 32);
packet->start();
packet->appendFCS('V'<<1);
packet->appendFCS('E'<<1);
packet->appendFCS('6'<<1);
packet->appendFCS('S'<<1);
packet->appendFCS('L'<<1);
packet->appendFCS('P'<<1);
packet->appendFCS(0b11100000);
packet->appendFCS('V'<<1);
packet->appendFCS('A'<<1);
packet->appendFCS('6'<<1);
packet->appendFCS('G'<<1);
packet->appendFCS('A'<<1);
packet->appendFCS(' '<<1);
packet->appendFCS(0b01100001 | (15 & 0xf) << 1);
packet->appendCallsign("VE6SLP",0);
packet->appendCallsign("VA6GA",15,true);
packet->appendFCS(0x03);
packet->appendFCS(0xf0);
packet->print("Hello ");
@ -61,7 +49,7 @@ void loop() {
// Wait up to 2.5 seconds to finish sending, and stop transmitter.
// TODO: This is hackery.
for(int i = 0; i < 500; i++) {
if(!radio.afsk.isSending())
if(!radio.afsk.encoder.isSending())
break;
delay(50);
}