[AX25] Update to 5.0.0

This commit is contained in:
jgromes 2021-11-14 11:38:05 +01:00
parent fbdb3eb6a2
commit ba1568669f
5 changed files with 123 additions and 122 deletions

View file

@ -58,7 +58,7 @@ void setup() {
// (RF69, CC1101, Si4432 etc.), use the basic begin() method // (RF69, CC1101, Si4432 etc.), use the basic begin() method
// int state = radio.begin(); // int state = radio.begin();
if(state == ERR_NONE) { if(state == RADIOLIB_ERR_NONE) {
Serial.println(F("success!")); Serial.println(F("success!"));
} else { } else {
Serial.print(F("failed, code ")); Serial.print(F("failed, code "));
@ -72,7 +72,7 @@ void setup() {
// source station SSID: 0 // source station SSID: 0
// preamble length: 8 bytes // preamble length: 8 bytes
state = ax25.begin("N7LEM"); state = ax25.begin("N7LEM");
if(state == ERR_NONE) { if(state == RADIOLIB_ERR_NONE) {
Serial.println(F("success!")); Serial.println(F("success!"));
} else { } else {
Serial.print(F("failed, code ")); Serial.print(F("failed, code "));
@ -97,7 +97,7 @@ void loop() {
// send the frame // send the frame
Serial.print(F("[AX.25] Sending UI frame ... ")); Serial.print(F("[AX.25] Sending UI frame ... "));
int state = ax25.sendFrame(&frameUI); int state = ax25.sendFrame(&frameUI);
if (state == ERR_NONE) { if (state == RADIOLIB_ERR_NONE) {
// the packet was successfully transmitted // the packet was successfully transmitted
Serial.println(F("success!")); Serial.println(F("success!"));
@ -125,7 +125,7 @@ void loop() {
// send the frame // send the frame
Serial.print(F("[AX.25] Sending RR frame ... ")); Serial.print(F("[AX.25] Sending RR frame ... "));
state = ax25.sendFrame(&frameRR); state = ax25.sendFrame(&frameRR);
if (state == ERR_NONE) { if (state == RADIOLIB_ERR_NONE) {
// the packet was successfully transmitted // the packet was successfully transmitted
Serial.println(F("success!")); Serial.println(F("success!"));
@ -159,7 +159,7 @@ void loop() {
// send the frame // send the frame
Serial.print(F("[AX.25] Sending I frame ... ")); Serial.print(F("[AX.25] Sending I frame ... "));
state = ax25.sendFrame(&frameI); state = ax25.sendFrame(&frameI);
if (state == ERR_NONE) { if (state == RADIOLIB_ERR_NONE) {
// the packet was successfully transmitted // the packet was successfully transmitted
Serial.println(F("success!")); Serial.println(F("success!"));

View file

@ -50,7 +50,7 @@ void setup() {
// (RF69, CC1101,, Si4432 etc.), use the basic begin() method // (RF69, CC1101,, Si4432 etc.), use the basic begin() method
// int state = radio.begin(); // int state = radio.begin();
if(state == ERR_NONE) { if(state == RADIOLIB_ERR_NONE) {
Serial.println(F("success!")); Serial.println(F("success!"));
} else { } else {
Serial.print(F("failed, code ")); Serial.print(F("failed, code "));
@ -64,7 +64,7 @@ void setup() {
// source station SSID: 0 // source station SSID: 0
// preamble length: 8 bytes // preamble length: 8 bytes
state = ax25.begin("N7LEM"); state = ax25.begin("N7LEM");
if(state == ERR_NONE) { if(state == RADIOLIB_ERR_NONE) {
Serial.println(F("success!")); Serial.println(F("success!"));
} else { } else {
Serial.print(F("failed, code ")); Serial.print(F("failed, code "));
@ -79,7 +79,7 @@ void loop() {
// destination station callsign: "NJ7P" // destination station callsign: "NJ7P"
// destination station SSID: 0 // destination station SSID: 0
int state = ax25.transmit("Hello World!", "NJ7P"); int state = ax25.transmit("Hello World!", "NJ7P");
if (state == ERR_NONE) { if (state == RADIOLIB_ERR_NONE) {
// the packet was successfully transmitted // the packet was successfully transmitted
Serial.println(F("success!")); Serial.println(F("success!"));

View file

@ -53,7 +53,7 @@ void setup() {
// (RF69, CC1101,, Si4432 etc.), use the basic begin() method // (RF69, CC1101,, Si4432 etc.), use the basic begin() method
// int state = radio.begin(); // int state = radio.begin();
if(state == ERR_NONE) { if(state == RADIOLIB_ERR_NONE) {
Serial.println(F("success!")); Serial.println(F("success!"));
} else { } else {
Serial.print(F("failed, code ")); Serial.print(F("failed, code "));
@ -67,7 +67,7 @@ void setup() {
// source station SSID: 0 // source station SSID: 0
// preamble length: 8 bytes // preamble length: 8 bytes
state = ax25.begin("N7LEM"); state = ax25.begin("N7LEM");
if(state == ERR_NONE) { if(state == RADIOLIB_ERR_NONE) {
Serial.println(F("success!")); Serial.println(F("success!"));
} else { } else {
Serial.print(F("failed, code ")); Serial.print(F("failed, code "));
@ -82,7 +82,7 @@ void setup() {
/* /*
Serial.print(F("[AX.25] Setting correction ... ")); Serial.print(F("[AX.25] Setting correction ... "));
state = ax25.setCorrection(100, -100); state = ax25.setCorrection(100, -100);
if(state == ERR_NONE) { if(state == RADIOLIB_ERR_NONE) {
Serial.println(F("success!")); Serial.println(F("success!"));
} else { } else {
Serial.print(F("failed, code ")); Serial.print(F("failed, code "));
@ -98,7 +98,7 @@ void loop() {
// destination station callsign: "NJ7P" // destination station callsign: "NJ7P"
// destination station SSID: 0 // destination station SSID: 0
int state = ax25.transmit("Hello World!", "NJ7P"); int state = ax25.transmit("Hello World!", "NJ7P");
if (state == ERR_NONE) { if (state == RADIOLIB_ERR_NONE) {
// the packet was successfully transmitted // the packet was successfully transmitted
Serial.println(F("success!")); Serial.println(F("success!"));

View file

@ -24,7 +24,7 @@ AX25Frame::AX25Frame(const char* destCallsign, uint8_t destSSID, const char* src
// set repeaters // set repeaters
this->numRepeaters = 0; this->numRepeaters = 0;
#ifndef RADIOLIB_STATIC_ONLY #if !defined(RADIOLIB_STATIC_ONLY)
this->repeaterCallsigns = NULL; this->repeaterCallsigns = NULL;
this->repeaterSSIDs = NULL; this->repeaterSSIDs = NULL;
#endif #endif
@ -42,7 +42,7 @@ AX25Frame::AX25Frame(const char* destCallsign, uint8_t destSSID, const char* src
// info field // info field
this->infoLen = infoLen; this->infoLen = infoLen;
if(infoLen > 0) { if(infoLen > 0) {
#ifndef RADIOLIB_STATIC_ONLY #if !defined(RADIOLIB_STATIC_ONLY)
this->info = new uint8_t[infoLen]; this->info = new uint8_t[infoLen];
#endif #endif
memcpy(this->info, info, infoLen); memcpy(this->info, info, infoLen);
@ -54,7 +54,7 @@ AX25Frame::AX25Frame(const AX25Frame& frame) {
} }
AX25Frame::~AX25Frame() { AX25Frame::~AX25Frame() {
#ifndef RADIOLIB_STATIC_ONLY #if !defined(RADIOLIB_STATIC_ONLY)
// deallocate info field // deallocate info field
if(infoLen > 0) { if(infoLen > 0) {
delete[] this->info; delete[] this->info;
@ -109,21 +109,21 @@ AX25Frame& AX25Frame::operator=(const AX25Frame& frame) {
int16_t AX25Frame::setRepeaters(char** repeaterCallsigns, uint8_t* repeaterSSIDs, uint8_t numRepeaters) { int16_t AX25Frame::setRepeaters(char** repeaterCallsigns, uint8_t* repeaterSSIDs, uint8_t numRepeaters) {
// check number of repeaters // check number of repeaters
if((numRepeaters < 1) || (numRepeaters > 8)) { if((numRepeaters < 1) || (numRepeaters > 8)) {
return(ERR_INVALID_NUM_REPEATERS); return(RADIOLIB_ERR_INVALID_NUM_REPEATERS);
} }
// check repeater configuration // check repeater configuration
if((repeaterCallsigns == NULL) || (repeaterSSIDs == NULL)) { if((repeaterCallsigns == NULL) || (repeaterSSIDs == NULL)) {
return(ERR_INVALID_NUM_REPEATERS); return(RADIOLIB_ERR_INVALID_NUM_REPEATERS);
} }
for(uint16_t i = 0; i < numRepeaters; i++) { for(uint16_t i = 0; i < numRepeaters; i++) {
if(strlen(repeaterCallsigns[i]) > AX25_MAX_CALLSIGN_LEN) { if(strlen(repeaterCallsigns[i]) > RADIOLIB_AX25_MAX_CALLSIGN_LEN) {
return(ERR_INVALID_REPEATER_CALLSIGN); return(RADIOLIB_ERR_INVALID_REPEATER_CALLSIGN);
} }
} }
// create buffers // create buffers
#ifndef RADIOLIB_STATIC_ONLY #if !defined(RADIOLIB_STATIC_ONLY)
this->repeaterCallsigns = new char*[numRepeaters]; this->repeaterCallsigns = new char*[numRepeaters];
for(uint8_t i = 0; i < numRepeaters; i++) { for(uint8_t i = 0; i < numRepeaters; i++) {
this->repeaterCallsigns[i] = new char[strlen(repeaterCallsigns[i]) + 1]; this->repeaterCallsigns[i] = new char[strlen(repeaterCallsigns[i]) + 1];
@ -139,7 +139,7 @@ int16_t AX25Frame::setRepeaters(char** repeaterCallsigns, uint8_t* repeaterSSIDs
} }
memcpy(this->repeaterSSIDs, repeaterSSIDs, numRepeaters); memcpy(this->repeaterSSIDs, repeaterSSIDs, numRepeaters);
return(ERR_NONE); return(RADIOLIB_ERR_NONE);
} }
void AX25Frame::setRecvSequence(uint8_t seqNumber) { void AX25Frame::setRecvSequence(uint8_t seqNumber) {
@ -161,14 +161,14 @@ AX25Client::AX25Client(PhysicalLayer* phy) {
AX25Client::AX25Client(AFSKClient* audio) { AX25Client::AX25Client(AFSKClient* audio) {
_phy = audio->_phy; _phy = audio->_phy;
_audio = audio; _audio = audio;
_afskMark = AX25_AFSK_MARK; _afskMark = RADIOLIB_AX25_AFSK_MARK;
_afskSpace = AX25_AFSK_SPACE; _afskSpace = RADIOLIB_AX25_AFSK_SPACE;
} }
int16_t AX25Client::setCorrection(int16_t mark, int16_t space) { int16_t AX25Client::setCorrection(int16_t mark, int16_t space) {
_afskMark = AX25_AFSK_MARK + mark; _afskMark = RADIOLIB_AX25_AFSK_MARK + mark;
_afskSpace = AX25_AFSK_SPACE + space; _afskSpace = RADIOLIB_AX25_AFSK_SPACE + space;
return(ERR_NONE); return(RADIOLIB_ERR_NONE);
} }
#endif #endif
@ -177,8 +177,8 @@ int16_t AX25Client::begin(const char* srcCallsign, uint8_t srcSSID, uint8_t prea
_srcSSID = srcSSID; _srcSSID = srcSSID;
// check source callsign length (6 characters max) // check source callsign length (6 characters max)
if(strlen(srcCallsign) > AX25_MAX_CALLSIGN_LEN) { if(strlen(srcCallsign) > RADIOLIB_AX25_MAX_CALLSIGN_LEN) {
return(ERR_INVALID_CALLSIGN); return(RADIOLIB_ERR_INVALID_CALLSIGN);
} }
// copy callsign // copy callsign
@ -194,10 +194,10 @@ int16_t AX25Client::begin(const char* srcCallsign, uint8_t srcSSID, uint8_t prea
int16_t AX25Client::transmit(const char* str, const char* destCallsign, uint8_t destSSID) { int16_t AX25Client::transmit(const char* str, const char* destCallsign, uint8_t destSSID) {
// create control field // create control field
uint8_t controlField = AX25_CONTROL_U_UNNUMBERED_INFORMATION | AX25_CONTROL_POLL_FINAL_DISABLED | AX25_CONTROL_UNNUMBERED_FRAME; uint8_t controlField = RADIOLIB_AX25_CONTROL_U_UNNUMBERED_INFORMATION | RADIOLIB_AX25_CONTROL_POLL_FINAL_DISABLED | RADIOLIB_AX25_CONTROL_UNNUMBERED_FRAME;
// build the frame // build the frame
AX25Frame frame(destCallsign, destSSID, _srcCallsign, _srcSSID, controlField, AX25_PID_NO_LAYER_3, (uint8_t*)str, strlen(str)); AX25Frame frame(destCallsign, destSSID, _srcCallsign, _srcSSID, controlField, RADIOLIB_AX25_PID_NO_LAYER_3, (uint8_t*)str, strlen(str));
// send Unnumbered Information frame // send Unnumbered Information frame
return(sendFrame(&frame)); return(sendFrame(&frame));
@ -205,27 +205,27 @@ int16_t AX25Client::transmit(const char* str, const char* destCallsign, uint8_t
int16_t AX25Client::sendFrame(AX25Frame* frame) { int16_t AX25Client::sendFrame(AX25Frame* frame) {
// check destination callsign length (6 characters max) // check destination callsign length (6 characters max)
if(strlen(frame->destCallsign) > AX25_MAX_CALLSIGN_LEN) { if(strlen(frame->destCallsign) > RADIOLIB_AX25_MAX_CALLSIGN_LEN) {
return(ERR_INVALID_CALLSIGN); return(RADIOLIB_ERR_INVALID_CALLSIGN);
} }
// check repeater configuration // check repeater configuration
#ifndef RADIOLIB_STATIC_ONLY #if !defined(RADIOLIB_STATIC_ONLY)
if(!(((frame->repeaterCallsigns == NULL) && (frame->repeaterSSIDs == NULL) && (frame->numRepeaters == 0)) || if(!(((frame->repeaterCallsigns == NULL) && (frame->repeaterSSIDs == NULL) && (frame->numRepeaters == 0)) ||
((frame->repeaterCallsigns != NULL) && (frame->repeaterSSIDs != NULL) && (frame->numRepeaters != 0)))) { ((frame->repeaterCallsigns != NULL) && (frame->repeaterSSIDs != NULL) && (frame->numRepeaters != 0)))) {
return(ERR_INVALID_NUM_REPEATERS); return(RADIOLIB_ERR_INVALID_NUM_REPEATERS);
} }
for(uint16_t i = 0; i < frame->numRepeaters; i++) { for(uint16_t i = 0; i < frame->numRepeaters; i++) {
if(strlen(frame->repeaterCallsigns[i]) > AX25_MAX_CALLSIGN_LEN) { if(strlen(frame->repeaterCallsigns[i]) > RADIOLIB_AX25_MAX_CALLSIGN_LEN) {
return(ERR_INVALID_REPEATER_CALLSIGN); return(RADIOLIB_ERR_INVALID_REPEATER_CALLSIGN);
} }
} }
#endif #endif
// calculate frame length without FCS (destination address, source address, repeater addresses, control, PID, info) // calculate frame length without FCS (destination address, source address, repeater addresses, control, PID, info)
size_t frameBuffLen = ((2 + frame->numRepeaters)*(AX25_MAX_CALLSIGN_LEN + 1)) + 1 + 1 + frame->infoLen; size_t frameBuffLen = ((2 + frame->numRepeaters)*(RADIOLIB_AX25_MAX_CALLSIGN_LEN + 1)) + 1 + 1 + frame->infoLen;
// create frame buffer without preamble, start or stop flags // create frame buffer without preamble, start or stop flags
#ifndef RADIOLIB_STATIC_ONLY #if !defined(RADIOLIB_STATIC_ONLY)
uint8_t* frameBuff = new uint8_t[frameBuffLen + 2]; uint8_t* frameBuff = new uint8_t[frameBuffLen + 2];
#else #else
uint8_t frameBuff[RADIOLIB_STATIC_ARRAY_SIZE]; uint8_t frameBuff[RADIOLIB_STATIC_ARRAY_SIZE];
@ -233,37 +233,37 @@ int16_t AX25Client::sendFrame(AX25Frame* frame) {
uint8_t* frameBuffPtr = frameBuff; uint8_t* frameBuffPtr = frameBuff;
// set destination callsign - all address field bytes are shifted by one bit to make room for HDLC address extension bit // set destination callsign - all address field bytes are shifted by one bit to make room for HDLC address extension bit
memset(frameBuffPtr, ' ' << 1, AX25_MAX_CALLSIGN_LEN); memset(frameBuffPtr, ' ' << 1, RADIOLIB_AX25_MAX_CALLSIGN_LEN);
for(size_t i = 0; i < strlen(frame->destCallsign); i++) { for(size_t i = 0; i < strlen(frame->destCallsign); i++) {
*(frameBuffPtr + i) = frame->destCallsign[i] << 1; *(frameBuffPtr + i) = frame->destCallsign[i] << 1;
} }
frameBuffPtr += AX25_MAX_CALLSIGN_LEN; frameBuffPtr += RADIOLIB_AX25_MAX_CALLSIGN_LEN;
// set destination SSID // set destination SSID
*(frameBuffPtr++) = AX25_SSID_COMMAND_DEST | AX25_SSID_RESERVED_BITS | (frame->destSSID & 0x0F) << 1 | AX25_SSID_HDLC_EXTENSION_CONTINUE; *(frameBuffPtr++) = RADIOLIB_AX25_SSID_COMMAND_DEST | RADIOLIB_AX25_SSID_RESERVED_BITS | (frame->destSSID & 0x0F) << 1 | RADIOLIB_AX25_SSID_HDLC_EXTENSION_CONTINUE;
// set source callsign - all address field bytes are shifted by one bit to make room for HDLC address extension bit // set source callsign - all address field bytes are shifted by one bit to make room for HDLC address extension bit
memset(frameBuffPtr, ' ' << 1, AX25_MAX_CALLSIGN_LEN); memset(frameBuffPtr, ' ' << 1, RADIOLIB_AX25_MAX_CALLSIGN_LEN);
for(size_t i = 0; i < strlen(frame->srcCallsign); i++) { for(size_t i = 0; i < strlen(frame->srcCallsign); i++) {
*(frameBuffPtr + i) = frame->srcCallsign[i] << 1; *(frameBuffPtr + i) = frame->srcCallsign[i] << 1;
} }
frameBuffPtr += AX25_MAX_CALLSIGN_LEN; frameBuffPtr += RADIOLIB_AX25_MAX_CALLSIGN_LEN;
// set source SSID // set source SSID
*(frameBuffPtr++) = AX25_SSID_RESPONSE_SOURCE | AX25_SSID_RESERVED_BITS | (frame->srcSSID & 0x0F) << 1 | AX25_SSID_HDLC_EXTENSION_CONTINUE; *(frameBuffPtr++) = RADIOLIB_AX25_SSID_RESPONSE_SOURCE | RADIOLIB_AX25_SSID_RESERVED_BITS | (frame->srcSSID & 0x0F) << 1 | RADIOLIB_AX25_SSID_HDLC_EXTENSION_CONTINUE;
// set repeater callsigns // set repeater callsigns
for(uint16_t i = 0; i < frame->numRepeaters; i++) { for(uint16_t i = 0; i < frame->numRepeaters; i++) {
memset(frameBuffPtr, ' ' << 1, AX25_MAX_CALLSIGN_LEN); memset(frameBuffPtr, ' ' << 1, RADIOLIB_AX25_MAX_CALLSIGN_LEN);
for(size_t j = 0; j < strlen(frame->repeaterCallsigns[i]); j++) { for(size_t j = 0; j < strlen(frame->repeaterCallsigns[i]); j++) {
*(frameBuffPtr + j) = frame->repeaterCallsigns[i][j] << 1; *(frameBuffPtr + j) = frame->repeaterCallsigns[i][j] << 1;
} }
frameBuffPtr += AX25_MAX_CALLSIGN_LEN; frameBuffPtr += RADIOLIB_AX25_MAX_CALLSIGN_LEN;
*(frameBuffPtr++) = AX25_SSID_HAS_NOT_BEEN_REPEATED | AX25_SSID_RESERVED_BITS | (frame->repeaterSSIDs[i] & 0x0F) << 1 | AX25_SSID_HDLC_EXTENSION_CONTINUE; *(frameBuffPtr++) = RADIOLIB_AX25_SSID_HAS_NOT_BEEN_REPEATED | RADIOLIB_AX25_SSID_RESERVED_BITS | (frame->repeaterSSIDs[i] & 0x0F) << 1 | RADIOLIB_AX25_SSID_HDLC_EXTENSION_CONTINUE;
} }
// set HDLC extension end bit // set HDLC extension end bit
*(frameBuffPtr - 1) |= AX25_SSID_HDLC_EXTENSION_END; *(frameBuffPtr - 1) |= RADIOLIB_AX25_SSID_HDLC_EXTENSION_END;
// set sequence numbers of the frames that have it // set sequence numbers of the frames that have it
uint8_t controlField = frame->control; uint8_t controlField = frame->control;
@ -301,7 +301,7 @@ int16_t AX25Client::sendFrame(AX25Frame* frame) {
*(frameBuffPtr++) = (uint8_t)(fcs & 0xFF); *(frameBuffPtr++) = (uint8_t)(fcs & 0xFF);
// prepare buffer for the final frame (stuffed, with added preamble + flags and NRZI-encoded) // prepare buffer for the final frame (stuffed, with added preamble + flags and NRZI-encoded)
#ifndef RADIOLIB_STATIC_ONLY #if !defined(RADIOLIB_STATIC_ONLY)
// worst-case scenario: sequence of 1s, will have 120% of the original length, stuffed frame also includes both flags // worst-case scenario: sequence of 1s, will have 120% of the original length, stuffed frame also includes both flags
uint8_t* stuffedFrameBuff = new uint8_t[_preambleLen + 1 + (6*frameBuffLen)/5 + 2]; uint8_t* stuffedFrameBuff = new uint8_t[_preambleLen + 1 + (6*frameBuffLen)/5 + 2];
#else #else
@ -345,13 +345,13 @@ int16_t AX25Client::sendFrame(AX25Frame* frame) {
} }
// deallocate memory // deallocate memory
#ifndef RADIOLIB_STATIC_ONLY #if !defined(RADIOLIB_STATIC_ONLY)
delete[] frameBuff; delete[] frameBuff;
#endif #endif
// set preamble bytes and start flag field // set preamble bytes and start flag field
for(uint16_t i = 0; i < _preambleLen + 1; i++) { for(uint16_t i = 0; i < _preambleLen + 1; i++) {
stuffedFrameBuff[i] = AX25_FLAG; stuffedFrameBuff[i] = RADIOLIB_AX25_FLAG;
} }
// get stuffed frame length in bytes // get stuffed frame length in bytes
@ -361,10 +361,10 @@ int16_t AX25Client::sendFrame(AX25Frame* frame) {
// set end flag field (may be split into two bytes due to misalignment caused by extra stuffing bits) // set end flag field (may be split into two bytes due to misalignment caused by extra stuffing bits)
if(trailingLen != 0) { if(trailingLen != 0) {
stuffedFrameBuffLen++; stuffedFrameBuffLen++;
stuffedFrameBuff[stuffedFrameBuffLen - 2] = AX25_FLAG >> trailingLen; stuffedFrameBuff[stuffedFrameBuffLen - 2] = RADIOLIB_AX25_FLAG >> trailingLen;
stuffedFrameBuff[stuffedFrameBuffLen - 1] = AX25_FLAG << (8 - trailingLen); stuffedFrameBuff[stuffedFrameBuffLen - 1] = RADIOLIB_AX25_FLAG << (8 - trailingLen);
} else { } else {
stuffedFrameBuff[stuffedFrameBuffLen - 1] = AX25_FLAG; stuffedFrameBuff[stuffedFrameBuffLen - 1] = RADIOLIB_AX25_FLAG;
} }
// convert to NRZI // convert to NRZI
@ -390,9 +390,10 @@ int16_t AX25Client::sendFrame(AX25Frame* frame) {
} }
// transmit // transmit
int16_t state = ERR_NONE; int16_t state = RADIOLIB_ERR_NONE;
#if !defined(RADIOLIB_EXCLUDE_AFSK) #if !defined(RADIOLIB_EXCLUDE_AFSK)
if(_audio != nullptr) { if(_audio != nullptr) {
Module* mod = _phy->getMod();
_phy->transmitDirect(); _phy->transmitDirect();
// iterate over all bytes in the buffer // iterate over all bytes in the buffer
@ -400,14 +401,14 @@ int16_t AX25Client::sendFrame(AX25Frame* frame) {
// check each bit // check each bit
for(uint16_t mask = 0x80; mask >= 0x01; mask >>= 1) { for(uint16_t mask = 0x80; mask >= 0x01; mask >>= 1) {
uint32_t start = Module::micros(); uint32_t start = mod->micros();
if(stuffedFrameBuff[i] & mask) { if(stuffedFrameBuff[i] & mask) {
_audio->tone(_afskMark, false); _audio->tone(_afskMark, false);
} else { } else {
_audio->tone(_afskSpace, false); _audio->tone(_afskSpace, false);
} }
while(Module::micros() - start < AX25_AFSK_TONE_DURATION) { while(mod->micros() - start < RADIOLIB_AX25_AFSK_TONE_DURATION) {
Module::yield(); mod->yield();
} }
} }
@ -423,7 +424,7 @@ int16_t AX25Client::sendFrame(AX25Frame* frame) {
#endif #endif
// deallocate memory // deallocate memory
#ifndef RADIOLIB_STATIC_ONLY #if !defined(RADIOLIB_STATIC_ONLY)
delete[] stuffedFrameBuff; delete[] stuffedFrameBuff;
#endif #endif

View file

@ -1,5 +1,5 @@
#if !defined(_RADIOLIB_AX25_H) #if !defined(_RADIOLIB_RADIOLIB_AX25_H)
#define _RADIOLIB_AX25_H #define _RADIOLIB_RADIOLIB_AX25_H
#include "../../TypeDef.h" #include "../../TypeDef.h"
@ -21,64 +21,64 @@
#define CRC_CCITT_INIT 0xFFFF // initial value #define CRC_CCITT_INIT 0xFFFF // initial value
// maximum callsign length in bytes // maximum callsign length in bytes
#define AX25_MAX_CALLSIGN_LEN 6 #define RADIOLIB_AX25_MAX_CALLSIGN_LEN 6
// flag field MSB LSB DESCRIPTION // flag field MSB LSB DESCRIPTION
#define AX25_FLAG 0b01111110 // 7 0 AX.25 frame start/end flag #define RADIOLIB_AX25_FLAG 0b01111110 // 7 0 AX.25 frame start/end flag
// address field // address field
#define AX25_SSID_COMMAND_DEST 0b10000000 // 7 7 frame type: command (set in destination SSID) #define RADIOLIB_AX25_SSID_COMMAND_DEST 0b10000000 // 7 7 frame type: command (set in destination SSID)
#define AX25_SSID_COMMAND_SOURCE 0b00000000 // 7 7 command (set in source SSID) #define RADIOLIB_AX25_SSID_COMMAND_SOURCE 0b00000000 // 7 7 command (set in source SSID)
#define AX25_SSID_RESPONSE_DEST 0b00000000 // 7 7 response (set in destination SSID) #define RADIOLIB_AX25_SSID_RESPONSE_DEST 0b00000000 // 7 7 response (set in destination SSID)
#define AX25_SSID_RESPONSE_SOURCE 0b10000000 // 7 7 response (set in source SSID) #define RADIOLIB_AX25_SSID_RESPONSE_SOURCE 0b10000000 // 7 7 response (set in source SSID)
#define AX25_SSID_HAS_NOT_BEEN_REPEATED 0b00000000 // 7 7 not repeated yet (set in repeater SSID) #define RADIOLIB_AX25_SSID_HAS_NOT_BEEN_REPEATED 0b00000000 // 7 7 not repeated yet (set in repeater SSID)
#define AX25_SSID_HAS_BEEN_REPEATED 0b10000000 // 7 7 repeated (set in repeater SSID) #define RADIOLIB_AX25_SSID_HAS_BEEN_REPEATED 0b10000000 // 7 7 repeated (set in repeater SSID)
#define AX25_SSID_RESERVED_BITS 0b01100000 // 6 5 reserved bits in SSID #define RADIOLIB_AX25_SSID_RESERVED_BITS 0b01100000 // 6 5 reserved bits in SSID
#define AX25_SSID_HDLC_EXTENSION_CONTINUE 0b00000000 // 0 0 HDLC extension bit: next octet contains more address information #define RADIOLIB_AX25_SSID_HDLC_EXTENSION_CONTINUE 0b00000000 // 0 0 HDLC extension bit: next octet contains more address information
#define AX25_SSID_HDLC_EXTENSION_END 0b00000001 // 0 0 address field end #define RADIOLIB_AX25_SSID_HDLC_EXTENSION_END 0b00000001 // 0 0 address field end
// control field // control field
#define AX25_CONTROL_U_SET_ASYNC_BAL_MODE 0b01101100 // 7 2 U frame type: set asynchronous balanced mode (connect request) #define RADIOLIB_AX25_CONTROL_U_SET_ASYNC_BAL_MODE 0b01101100 // 7 2 U frame type: set asynchronous balanced mode (connect request)
#define AX25_CONTROL_U_SET_ASYNC_BAL_MODE_EXT 0b00101100 // 7 2 set asynchronous balanced mode extended (connect request with module 128) #define RADIOLIB_AX25_CONTROL_U_SET_ASYNC_BAL_MODE_EXT 0b00101100 // 7 2 set asynchronous balanced mode extended (connect request with module 128)
#define AX25_CONTROL_U_DISCONNECT 0b01000000 // 7 2 disconnect request #define RADIOLIB_AX25_CONTROL_U_DISCONNECT 0b01000000 // 7 2 disconnect request
#define AX25_CONTROL_U_DISCONNECT_MODE 0b00001100 // 7 2 disconnect mode (system busy or disconnected) #define RADIOLIB_AX25_CONTROL_U_DISCONNECT_MODE 0b00001100 // 7 2 disconnect mode (system busy or disconnected)
#define AX25_CONTROL_U_UNNUMBERED_ACK 0b01100000 // 7 2 unnumbered acknowledge #define RADIOLIB_AX25_CONTROL_U_UNNUMBERED_ACK 0b01100000 // 7 2 unnumbered acknowledge
#define AX25_CONTROL_U_FRAME_REJECT 0b10000100 // 7 2 frame reject #define RADIOLIB_AX25_CONTROL_U_FRAME_REJECT 0b10000100 // 7 2 frame reject
#define AX25_CONTROL_U_UNNUMBERED_INFORMATION 0b00000000 // 7 2 unnumbered information #define RADIOLIB_AX25_CONTROL_U_UNNUMBERED_INFORMATION 0b00000000 // 7 2 unnumbered information
#define AX25_CONTROL_U_EXHANGE_IDENTIFICATION 0b10101100 // 7 2 exchange ID #define RADIOLIB_AX25_CONTROL_U_EXHANGE_IDENTIFICATION 0b10101100 // 7 2 exchange ID
#define AX25_CONTROL_U_TEST 0b11100000 // 7 2 test #define RADIOLIB_AX25_CONTROL_U_TEST 0b11100000 // 7 2 test
#define AX25_CONTROL_POLL_FINAL_ENABLED 0b00010000 // 4 4 control field poll/final bit: enabled #define RADIOLIB_AX25_CONTROL_POLL_FINAL_ENABLED 0b00010000 // 4 4 control field poll/final bit: enabled
#define AX25_CONTROL_POLL_FINAL_DISABLED 0b00000000 // 4 4 disabled #define RADIOLIB_AX25_CONTROL_POLL_FINAL_DISABLED 0b00000000 // 4 4 disabled
#define AX25_CONTROL_S_RECEIVE_READY 0b00000000 // 3 2 S frame type: receive ready (system ready to receive) #define RADIOLIB_AX25_CONTROL_S_RECEIVE_READY 0b00000000 // 3 2 S frame type: receive ready (system ready to receive)
#define AX25_CONTROL_S_RECEIVE_NOT_READY 0b00000100 // 3 2 receive not ready (TNC buffer full) #define RADIOLIB_AX25_CONTROL_S_RECEIVE_NOT_READY 0b00000100 // 3 2 receive not ready (TNC buffer full)
#define AX25_CONTROL_S_REJECT 0b00001000 // 3 2 reject (out of sequence or duplicate) #define RADIOLIB_AX25_CONTROL_S_REJECT 0b00001000 // 3 2 reject (out of sequence or duplicate)
#define AX25_CONTROL_S_SELECTIVE_REJECT 0b00001100 // 3 2 selective reject (single frame repeat request) #define RADIOLIB_AX25_CONTROL_S_SELECTIVE_REJECT 0b00001100 // 3 2 selective reject (single frame repeat request)
#define AX25_CONTROL_INFORMATION_FRAME 0b00000000 // 0 0 frame type: information (I frame) #define RADIOLIB_AX25_CONTROL_INFORMATION_FRAME 0b00000000 // 0 0 frame type: information (I frame)
#define AX25_CONTROL_SUPERVISORY_FRAME 0b00000001 // 1 0 supervisory (S frame) #define RADIOLIB_AX25_CONTROL_SUPERVISORY_FRAME 0b00000001 // 1 0 supervisory (S frame)
#define AX25_CONTROL_UNNUMBERED_FRAME 0b00000011 // 1 0 unnumbered (U frame) #define RADIOLIB_AX25_CONTROL_UNNUMBERED_FRAME 0b00000011 // 1 0 unnumbered (U frame)
// protocol identifier field // protocol identifier field
#define AX25_PID_ISO_8208 0x01 #define RADIOLIB_AX25_PID_ISO_8208 0x01
#define AX25_PID_TCP_IP_COMPRESSED 0x06 #define RADIOLIB_AX25_PID_TCP_IP_COMPRESSED 0x06
#define AX25_PID_TCP_IP_UNCOMPRESSED 0x07 #define RADIOLIB_AX25_PID_TCP_IP_UNCOMPRESSED 0x07
#define AX25_PID_SEGMENTATION_FRAGMENT 0x08 #define RADIOLIB_AX25_PID_SEGMENTATION_FRAGMENT 0x08
#define AX25_PID_TEXNET_DATAGRAM_PROTOCOL 0xC3 #define RADIOLIB_AX25_PID_TEXNET_DATAGRAM_PROTOCOL 0xC3
#define AX25_PID_LINK_QUALITY_PROTOCOL 0xC4 #define RADIOLIB_AX25_PID_LINK_QUALITY_PROTOCOL 0xC4
#define AX25_PID_APPLETALK 0xCA #define RADIOLIB_AX25_PID_APPLETALK 0xCA
#define AX25_PID_APPLETALK_ARP 0xCB #define RADIOLIB_AX25_PID_APPLETALK_ARP 0xCB
#define AX25_PID_ARPA_INTERNET_PROTOCOL 0xCC #define RADIOLIB_AX25_PID_ARPA_INTERNET_PROTOCOL 0xCC
#define AX25_PID_ARPA_ADDRESS_RESOLUTION 0xCD #define RADIOLIB_AX25_PID_ARPA_ADDRESS_RESOLUTION 0xCD
#define AX25_PID_FLEXNET 0xCE #define RADIOLIB_AX25_PID_FLEXNET 0xCE
#define AX25_PID_NET_ROM 0xCF #define RADIOLIB_AX25_PID_NET_ROM 0xCF
#define AX25_PID_NO_LAYER_3 0xF0 #define RADIOLIB_AX25_PID_NO_LAYER_3 0xF0
#define AX25_PID_ESCAPE_CHARACTER 0xFF #define RADIOLIB_AX25_PID_ESCAPE_CHARACTER 0xFF
// AFSK tones in Hz // AFSK tones in Hz
#define AX25_AFSK_MARK 1200 #define RADIOLIB_AX25_AFSK_MARK 1200
#define AX25_AFSK_SPACE 2200 #define RADIOLIB_AX25_AFSK_SPACE 2200
// tone duration in us (for 1200 baud AFSK) // tone duration in us (for 1200 baud AFSK)
#define AX25_AFSK_TONE_DURATION 833 #define RADIOLIB_AX25_AFSK_TONE_DURATION 833
/*! /*!
\class AX25Frame \class AX25Frame
@ -90,7 +90,7 @@ class AX25Frame {
/*! /*!
\brief Callsign of the destination station. \brief Callsign of the destination station.
*/ */
char destCallsign[AX25_MAX_CALLSIGN_LEN + 1]; char destCallsign[RADIOLIB_AX25_MAX_CALLSIGN_LEN + 1];
/*! /*!
\brief SSID of the destination station. \brief SSID of the destination station.
@ -100,7 +100,7 @@ class AX25Frame {
/*! /*!
\brief Callsign of the source station. \brief Callsign of the source station.
*/ */
char srcCallsign[AX25_MAX_CALLSIGN_LEN + 1]; char srcCallsign[RADIOLIB_AX25_MAX_CALLSIGN_LEN + 1];
/*! /*!
\brief SSID of the source station. \brief SSID of the source station.
@ -137,7 +137,7 @@ class AX25Frame {
*/ */
uint16_t sendSeqNumber; uint16_t sendSeqNumber;
#ifndef RADIOLIB_STATIC_ONLY #if !defined(RADIOLIB_STATIC_ONLY)
/*! /*!
\brief The info field. \brief The info field.
*/ */
@ -161,7 +161,7 @@ class AX25Frame {
/*! /*!
\brief Array of repeater callsigns. \brief Array of repeater callsigns.
*/ */
char repeaterCallsigns[8][AX25_MAX_CALLSIGN_LEN + 1]; char repeaterCallsigns[8][RADIOLIB_AX25_MAX_CALLSIGN_LEN + 1];
/*! /*!
\brief Array of repeater SSIDs. \brief Array of repeater SSIDs.
@ -314,7 +314,7 @@ class AX25Client {
\param srcSSID 4-bit SSID of the source station (in case there are more stations with the same callsign). Defaults to 0. \param srcSSID 4-bit SSID of the source station (in case there are more stations with the same callsign). Defaults to 0.
\param preambleLen Number of "preamble" bytes (AX25_FLAG) sent ahead of the actual AX.25 frame. Does not include the first AX25_FLAG byte, which is considered part of the frame. Defaults to 8. \param preambleLen Number of "preamble" bytes (RADIOLIB_AX25_FLAG) sent ahead of the actual AX.25 frame. Does not include the first RADIOLIB_AX25_FLAG byte, which is considered part of the frame. Defaults to 8.
\returns \ref status_codes \returns \ref status_codes
*/ */
@ -342,7 +342,7 @@ class AX25Client {
*/ */
int16_t sendFrame(AX25Frame* frame); int16_t sendFrame(AX25Frame* frame);
#ifndef RADIOLIB_GODMODE #if !defined(ADIOLIB_GODMODE)
private: private:
#endif #endif
PhysicalLayer* _phy; PhysicalLayer* _phy;
@ -352,7 +352,7 @@ class AX25Client {
uint32_t _afskSpace; uint32_t _afskSpace;
#endif #endif
char _srcCallsign[AX25_MAX_CALLSIGN_LEN + 1] = {0, 0, 0, 0, 0, 0, 0}; char _srcCallsign[RADIOLIB_AX25_MAX_CALLSIGN_LEN + 1] = {0, 0, 0, 0, 0, 0, 0};
uint8_t _srcSSID = 0; uint8_t _srcSSID = 0;
uint16_t _preambleLen = 0; uint16_t _preambleLen = 0;