[AX25] Use compact Doxygen and stop using reserved format
This commit is contained in:
parent
c988f64921
commit
5da2a023fe
2 changed files with 51 additions and 96 deletions
|
@ -152,32 +152,32 @@ void AX25Frame::setSendSequence(uint8_t seqNumber) {
|
|||
}
|
||||
|
||||
AX25Client::AX25Client(PhysicalLayer* phy) {
|
||||
_phy = phy;
|
||||
phyLayer = phy;
|
||||
#if !defined(RADIOLIB_EXCLUDE_AFSK)
|
||||
_audio = nullptr;
|
||||
audioClient = nullptr;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !defined(RADIOLIB_EXCLUDE_AFSK)
|
||||
AX25Client::AX25Client(AFSKClient* audio) {
|
||||
_phy = audio->_phy;
|
||||
_audio = audio;
|
||||
_afskMark = RADIOLIB_AX25_AFSK_MARK;
|
||||
_afskSpace = RADIOLIB_AX25_AFSK_SPACE;
|
||||
_afskLen = RADIOLIB_AX25_AFSK_TONE_DURATION;
|
||||
phyLayer = audio->phyLayer;
|
||||
audioClient = audio;
|
||||
afskMark = RADIOLIB_AX25_AFSK_MARK;
|
||||
afskSpace = RADIOLIB_AX25_AFSK_SPACE;
|
||||
afskLen = RADIOLIB_AX25_AFSK_TONE_DURATION;
|
||||
}
|
||||
|
||||
int16_t AX25Client::setCorrection(int16_t mark, int16_t space, float length) {
|
||||
_afskMark = RADIOLIB_AX25_AFSK_MARK + mark;
|
||||
_afskSpace = RADIOLIB_AX25_AFSK_SPACE + space;
|
||||
_afskLen = length*(float)RADIOLIB_AX25_AFSK_TONE_DURATION;
|
||||
afskMark = RADIOLIB_AX25_AFSK_MARK + mark;
|
||||
afskSpace = RADIOLIB_AX25_AFSK_SPACE + space;
|
||||
afskLen = length*(float)RADIOLIB_AX25_AFSK_TONE_DURATION;
|
||||
return(RADIOLIB_ERR_NONE);
|
||||
}
|
||||
#endif
|
||||
|
||||
int16_t AX25Client::begin(const char* srcCallsign, uint8_t srcSSID, uint8_t preambleLen) {
|
||||
int16_t AX25Client::begin(const char* srcCallsign, uint8_t srcSSID, uint8_t preLen) {
|
||||
// set source SSID
|
||||
_srcSSID = srcSSID;
|
||||
sourceSSID = srcSSID;
|
||||
|
||||
// check source callsign length (6 characters max)
|
||||
if(strlen(srcCallsign) > RADIOLIB_AX25_MAX_CALLSIGN_LEN) {
|
||||
|
@ -185,14 +185,14 @@ int16_t AX25Client::begin(const char* srcCallsign, uint8_t srcSSID, uint8_t prea
|
|||
}
|
||||
|
||||
// copy callsign
|
||||
memcpy(_srcCallsign, srcCallsign, strlen(srcCallsign));
|
||||
_srcCallsign[strlen(srcCallsign)] = '\0';
|
||||
memcpy(sourceCallsign, srcCallsign, strlen(srcCallsign));
|
||||
sourceCallsign[strlen(srcCallsign)] = '\0';
|
||||
|
||||
// save preamble length
|
||||
_preambleLen = preambleLen;
|
||||
preambleLen = preLen;
|
||||
|
||||
// configure for direct mode
|
||||
return(_phy->startDirect());
|
||||
return(phyLayer->startDirect());
|
||||
}
|
||||
|
||||
#if defined(RADIOLIB_BUILD_ARDUINO)
|
||||
|
@ -206,7 +206,7 @@ int16_t AX25Client::transmit(const char* str, const char* destCallsign, uint8_t
|
|||
uint8_t controlField = RADIOLIB_AX25_CONTROL_U_UNNUMBERED_INFORMATION | RADIOLIB_AX25_CONTROL_POLL_FINAL_DISABLED | RADIOLIB_AX25_CONTROL_UNNUMBERED_FRAME;
|
||||
|
||||
// build the frame
|
||||
AX25Frame frame(destCallsign, destSSID, _srcCallsign, _srcSSID, controlField, RADIOLIB_AX25_PID_NO_LAYER_3, (uint8_t*)str, strlen(str));
|
||||
AX25Frame frame(destCallsign, destSSID, sourceCallsign, sourceSSID, controlField, RADIOLIB_AX25_PID_NO_LAYER_3, (uint8_t*)str, strlen(str));
|
||||
|
||||
// send Unnumbered Information frame
|
||||
return(sendFrame(&frame));
|
||||
|
@ -312,16 +312,16 @@ int16_t AX25Client::sendFrame(AX25Frame* frame) {
|
|||
// prepare buffer for the final frame (stuffed, with added preamble + flags and NRZI-encoded)
|
||||
#if !defined(RADIOLIB_STATIC_ONLY)
|
||||
// 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
|
||||
uint8_t stuffedFrameBuff[RADIOLIB_STATIC_ARRAY_SIZE];
|
||||
#endif
|
||||
|
||||
// initialize buffer to all zeros
|
||||
memset(stuffedFrameBuff, 0x00, _preambleLen + 1 + (6*frameBuffLen)/5 + 2);
|
||||
memset(stuffedFrameBuff, 0x00, preambleLen + 1 + (6*frameBuffLen)/5 + 2);
|
||||
|
||||
// stuff bits (skip preamble and both flags)
|
||||
uint16_t stuffedFrameBuffLenBits = 8*(_preambleLen + 1);
|
||||
uint16_t stuffedFrameBuffLenBits = 8*(preambleLen + 1);
|
||||
uint8_t count = 0;
|
||||
for(size_t i = 0; i < frameBuffLen + 2; i++) {
|
||||
for(int8_t shift = 7; shift >= 0; shift--) {
|
||||
|
@ -359,7 +359,7 @@ int16_t AX25Client::sendFrame(AX25Frame* frame) {
|
|||
#endif
|
||||
|
||||
// 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] = RADIOLIB_AX25_FLAG;
|
||||
}
|
||||
|
||||
|
@ -377,7 +377,7 @@ int16_t AX25Client::sendFrame(AX25Frame* frame) {
|
|||
}
|
||||
|
||||
// convert to NRZI
|
||||
for(size_t i = _preambleLen + 1; i < stuffedFrameBuffLen*8; i++) {
|
||||
for(size_t i = preambleLen + 1; i < stuffedFrameBuffLen*8; i++) {
|
||||
size_t currBitPos = i + 7 - 2*(i%8);
|
||||
size_t prevBitPos = (i - 1) + 7 - 2*((i - 1)%8);
|
||||
if(TEST_BIT_IN_ARRAY(stuffedFrameBuff, currBitPos)) {
|
||||
|
@ -401,9 +401,9 @@ int16_t AX25Client::sendFrame(AX25Frame* frame) {
|
|||
// transmit
|
||||
int16_t state = RADIOLIB_ERR_NONE;
|
||||
#if !defined(RADIOLIB_EXCLUDE_AFSK)
|
||||
if(_audio != nullptr) {
|
||||
Module* mod = _phy->getMod();
|
||||
_phy->transmitDirect();
|
||||
if(audioClient != nullptr) {
|
||||
Module* mod = phyLayer->getMod();
|
||||
phyLayer->transmitDirect();
|
||||
|
||||
// iterate over all bytes in the buffer
|
||||
for(uint32_t i = 0; i < stuffedFrameBuffLen; i++) {
|
||||
|
@ -412,20 +412,20 @@ int16_t AX25Client::sendFrame(AX25Frame* frame) {
|
|||
for(uint16_t mask = 0x80; mask >= 0x01; mask >>= 1) {
|
||||
uint32_t start = mod->hal->micros();
|
||||
if(stuffedFrameBuff[i] & mask) {
|
||||
_audio->tone(_afskMark, false);
|
||||
audioClient->tone(afskMark, false);
|
||||
} else {
|
||||
_audio->tone(_afskSpace, false);
|
||||
audioClient->tone(afskSpace, false);
|
||||
}
|
||||
mod->waitForMicroseconds(start, _afskLen);
|
||||
mod->waitForMicroseconds(start, afskLen);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
_audio->noTone();
|
||||
audioClient->noTone();
|
||||
|
||||
} else {
|
||||
#endif
|
||||
state = _phy->transmit(stuffedFrameBuff, stuffedFrameBuffLen);
|
||||
state = phyLayer->transmit(stuffedFrameBuff, stuffedFrameBuffLen);
|
||||
#if !defined(RADIOLIB_EXCLUDE_AFSK)
|
||||
}
|
||||
#endif
|
||||
|
@ -439,11 +439,11 @@ int16_t AX25Client::sendFrame(AX25Frame* frame) {
|
|||
}
|
||||
|
||||
void AX25Client::getCallsign(char* buff) {
|
||||
strncpy(buff, _srcCallsign, RADIOLIB_AX25_MAX_CALLSIGN_LEN);
|
||||
strncpy(buff, sourceCallsign, RADIOLIB_AX25_MAX_CALLSIGN_LEN);
|
||||
}
|
||||
|
||||
uint8_t AX25Client::getSSID() {
|
||||
return(_srcSSID);
|
||||
return(sourceSSID);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -82,7 +82,6 @@
|
|||
|
||||
/*!
|
||||
\class AX25Frame
|
||||
|
||||
\brief Abstraction of AX.25 frame format.
|
||||
*/
|
||||
class AX25Frame {
|
||||
|
@ -171,62 +170,41 @@ class AX25Frame {
|
|||
|
||||
/*!
|
||||
\brief Overloaded constructor, for frames without info field.
|
||||
|
||||
\param destCallsign Callsign of the destination station.
|
||||
|
||||
\param destSSID SSID of the destination station.
|
||||
|
||||
\param srcCallsign Callsign of the source station.
|
||||
|
||||
\param srcSSID SSID of the source station.
|
||||
|
||||
\param control The control field.
|
||||
*/
|
||||
AX25Frame(const char* destCallsign, uint8_t destSSID, const char* srcCallsign, uint8_t srcSSID, uint8_t control);
|
||||
|
||||
/*!
|
||||
\brief Overloaded constructor, for frames with C-string info field.
|
||||
|
||||
\param destCallsign Callsign of the destination station.
|
||||
|
||||
\param destSSID SSID of the destination station.
|
||||
|
||||
\param srcCallsign Callsign of the source station.
|
||||
|
||||
\param srcSSID SSID of the source station.
|
||||
|
||||
\param control The control field.
|
||||
|
||||
\param protocolID The protocol identifier (PID) field. Set to zero if the frame doesn't have this field.
|
||||
|
||||
\param info Information field, in the form of null-terminated C-string.
|
||||
*/
|
||||
AX25Frame(const char* destCallsign, uint8_t destSSID, const char* srcCallsign, uint8_t srcSSID, uint8_t control, uint8_t protocolID, const char* info);
|
||||
|
||||
/*!
|
||||
\brief Default constructor.
|
||||
|
||||
\param destCallsign Callsign of the destination station.
|
||||
|
||||
\param destSSID SSID of the destination station.
|
||||
|
||||
\param srcCallsign Callsign of the source station.
|
||||
|
||||
\param srcSSID SSID of the source station.
|
||||
|
||||
\param control The control field.
|
||||
|
||||
\param protocolID The protocol identifier (PID) field. Set to zero if the frame doesn't have this field.
|
||||
|
||||
\param info Information field, in the form of arbitrary binary buffer.
|
||||
|
||||
\param infoLen Number of bytes in the information field.
|
||||
*/
|
||||
AX25Frame(const char* destCallsign, uint8_t destSSID, const char* srcCallsign, uint8_t srcSSID, uint8_t control, uint8_t protocolID, uint8_t* info, uint16_t infoLen);
|
||||
|
||||
/*!
|
||||
\brief Copy constructor.
|
||||
|
||||
\param frame AX25Frame instance to copy.
|
||||
*/
|
||||
AX25Frame(const AX25Frame& frame);
|
||||
|
@ -238,34 +216,27 @@ class AX25Frame {
|
|||
|
||||
/*!
|
||||
\brief Overload for assignment operator.
|
||||
|
||||
\param frame rvalue AX25Frame.
|
||||
*/
|
||||
AX25Frame& operator=(const AX25Frame& frame);
|
||||
|
||||
/*!
|
||||
\brief Method to set the repeater callsigns and SSIDs.
|
||||
|
||||
\param repeaterCallsigns Array of repeater callsigns in the form of null-terminated C-strings.
|
||||
|
||||
\param repeaterSSIDs Array of repeater SSIDs.
|
||||
|
||||
\param numRepeaters Number of repeaters, maximum is 8.
|
||||
|
||||
\returns \ref status_codes
|
||||
*/
|
||||
int16_t setRepeaters(char** repeaterCallsigns, uint8_t* repeaterSSIDs, uint8_t numRepeaters);
|
||||
|
||||
/*!
|
||||
\brief Method to set receive sequence number.
|
||||
|
||||
\param seqNumber Sequence number to set, 0 to 7.
|
||||
*/
|
||||
void setRecvSequence(uint8_t seqNumber);
|
||||
|
||||
/*!
|
||||
\brief Method to set send sequence number.
|
||||
|
||||
\param seqNumber Sequence number to set, 0 to 7.
|
||||
*/
|
||||
void setSendSequence(uint8_t seqNumber);
|
||||
|
@ -273,14 +244,12 @@ class AX25Frame {
|
|||
|
||||
/*!
|
||||
\class AX25Client
|
||||
|
||||
\brief Client for AX25 communication.
|
||||
*/
|
||||
class AX25Client {
|
||||
public:
|
||||
/*!
|
||||
\brief Constructor for 2-FSK mode.
|
||||
|
||||
\param phy Pointer to the wireless module providing PhysicalLayer communication.
|
||||
*/
|
||||
explicit AX25Client(PhysicalLayer* phy);
|
||||
|
@ -288,20 +257,16 @@ class AX25Client {
|
|||
#if !defined(RADIOLIB_EXCLUDE_AFSK)
|
||||
/*!
|
||||
\brief Constructor for AFSK mode.
|
||||
|
||||
\param audio Pointer to the AFSK instance providing audio.
|
||||
*/
|
||||
explicit AX25Client(AFSKClient* audio);
|
||||
|
||||
/*!
|
||||
\brief Set AFSK tone correction offset. On some platforms, this is required to get the audio produced by the setup to match the expected 1200/2200 Hz tones.
|
||||
|
||||
\brief Set AFSK tone correction offset. On some platforms, this is required to get the audio produced
|
||||
by the setup to match the expected 1200/2200 Hz tones.
|
||||
\param mark Positive or negative correction offset for mark audio frequency in Hz.
|
||||
|
||||
\param space Positive or negative correction offset for space audio frequency in Hz.
|
||||
|
||||
\param length Audio tone length modifier, defaults to 1.0.
|
||||
|
||||
\returns \ref status_codes
|
||||
*/
|
||||
int16_t setCorrection(int16_t mark, int16_t space, float length = 1.0f);
|
||||
|
@ -311,27 +276,22 @@ class AX25Client {
|
|||
|
||||
/*!
|
||||
\brief Initialization method.
|
||||
|
||||
\param srcCallsign Callsign of the source station.
|
||||
|
||||
\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 (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.
|
||||
|
||||
\param srcSSID 4-bit SSID of the source station (in case there are more stations with the same callsign).
|
||||
Defaults to 0.
|
||||
\param preLen 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
|
||||
*/
|
||||
int16_t begin(const char* srcCallsign, uint8_t srcSSID = 0x00, uint8_t preambleLen = 8);
|
||||
int16_t begin(const char* srcCallsign, uint8_t srcSSID = 0x00, uint8_t preLen = 8);
|
||||
|
||||
#if defined(RADIOLIB_BUILD_ARDUINO)
|
||||
/*!
|
||||
\brief Transmit unnumbered information (UI) frame.
|
||||
|
||||
\param str Data to be sent as Arduino String.
|
||||
|
||||
\param destCallsign Callsign of the destination station.
|
||||
|
||||
\param destSSID 4-bit SSID of the destination station (in case there are more stations with the same callsign). Defaults to 0.
|
||||
|
||||
\param destSSID 4-bit SSID of the destination station (in case there are more stations with the same callsign).
|
||||
Defaults to 0.
|
||||
\returns \ref status_codes
|
||||
*/
|
||||
int16_t transmit(String& str, const char* destCallsign, uint8_t destSSID = 0x00);
|
||||
|
@ -339,22 +299,17 @@ class AX25Client {
|
|||
|
||||
/*!
|
||||
\brief Transmit unnumbered information (UI) frame.
|
||||
|
||||
\param str Data to be sent.
|
||||
|
||||
\param destCallsign Callsign of the destination station.
|
||||
|
||||
\param destSSID 4-bit SSID of the destination station (in case there are more stations with the same callsign). Defaults to 0.
|
||||
|
||||
\param destSSID 4-bit SSID of the destination station (in case there are more stations with the same callsign).
|
||||
Defaults to 0.
|
||||
\returns \ref status_codes
|
||||
*/
|
||||
int16_t transmit(const char* str, const char* destCallsign, uint8_t destSSID = 0x00);
|
||||
|
||||
/*!
|
||||
\brief Transmit arbitrary AX.25 frame.
|
||||
|
||||
\param frame Frame to be sent.
|
||||
|
||||
\returns \ref status_codes
|
||||
*/
|
||||
int16_t sendFrame(AX25Frame* frame);
|
||||
|
@ -364,17 +319,17 @@ class AX25Client {
|
|||
#endif
|
||||
friend class APRSClient;
|
||||
|
||||
PhysicalLayer* _phy;
|
||||
PhysicalLayer* phyLayer;
|
||||
#if !defined(RADIOLIB_EXCLUDE_AFSK)
|
||||
AFSKClient* _audio;
|
||||
uint32_t _afskMark;
|
||||
uint32_t _afskSpace;
|
||||
uint32_t _afskLen;
|
||||
AFSKClient* audioClient;
|
||||
uint32_t afskMark;
|
||||
uint32_t afskSpace;
|
||||
uint32_t afskLen;
|
||||
#endif
|
||||
|
||||
char _srcCallsign[RADIOLIB_AX25_MAX_CALLSIGN_LEN + 1] = {0, 0, 0, 0, 0, 0, 0};
|
||||
uint8_t _srcSSID = 0;
|
||||
uint16_t _preambleLen = 0;
|
||||
char sourceCallsign[RADIOLIB_AX25_MAX_CALLSIGN_LEN + 1] = {0, 0, 0, 0, 0, 0, 0};
|
||||
uint8_t sourceSSID = 0;
|
||||
uint16_t preambleLen = 0;
|
||||
|
||||
static uint16_t getFrameCheckSequence(uint8_t* buff, size_t len);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue