[AX25] Added copy ctor and assignment operator
This commit is contained in:
parent
e89e8a053a
commit
e1990e460d
2 changed files with 53 additions and 0 deletions
|
@ -49,6 +49,10 @@ AX25Frame::AX25Frame(const char* destCallsign, uint8_t destSSID, const char* src
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AX25Frame::AX25Frame(const AX25Frame& frame) {
|
||||||
|
*this = frame;
|
||||||
|
}
|
||||||
|
|
||||||
AX25Frame::~AX25Frame() {
|
AX25Frame::~AX25Frame() {
|
||||||
#ifndef RADIOLIB_STATIC_ONLY
|
#ifndef RADIOLIB_STATIC_ONLY
|
||||||
// deallocate info field
|
// deallocate info field
|
||||||
|
@ -67,6 +71,41 @@ AX25Frame::~AX25Frame() {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AX25Frame& AX25Frame::operator=(const AX25Frame& frame) {
|
||||||
|
// destination callsign/SSID
|
||||||
|
memcpy(this->destCallsign, frame.destCallsign, strlen(frame.destCallsign));
|
||||||
|
this->destCallsign[strlen(frame.destCallsign)] = '\0';
|
||||||
|
this->destSSID = frame.destSSID;
|
||||||
|
|
||||||
|
// source callsign/SSID
|
||||||
|
memcpy(this->srcCallsign, frame.srcCallsign, strlen(frame.srcCallsign));
|
||||||
|
this->srcCallsign[strlen(frame.srcCallsign)] = '\0';
|
||||||
|
this->srcSSID = frame.srcSSID;
|
||||||
|
|
||||||
|
// repeaters
|
||||||
|
this->numRepeaters = frame.numRepeaters;
|
||||||
|
for(uint8_t i = 0; i < this->numRepeaters; i++) {
|
||||||
|
memcpy(this->repeaterCallsigns[i], frame.repeaterCallsigns[i], strlen(frame.repeaterCallsigns[i]));
|
||||||
|
}
|
||||||
|
memcpy(this->repeaterSSIDs, frame.repeaterSSIDs, this->numRepeaters);
|
||||||
|
|
||||||
|
// control field
|
||||||
|
this->control = frame.control;
|
||||||
|
|
||||||
|
// sequence numbers
|
||||||
|
this->rcvSeqNumber = frame.rcvSeqNumber;
|
||||||
|
this->sendSeqNumber = frame.sendSeqNumber;
|
||||||
|
|
||||||
|
// PID field
|
||||||
|
this->protocolID = frame.protocolID;
|
||||||
|
|
||||||
|
// info field
|
||||||
|
this->infoLen = frame.infoLen;
|
||||||
|
memcpy(this->info, frame.info, this->infoLen);
|
||||||
|
|
||||||
|
return(*this);
|
||||||
|
}
|
||||||
|
|
||||||
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)) {
|
||||||
|
|
|
@ -224,11 +224,25 @@ class AX25Frame {
|
||||||
*/
|
*/
|
||||||
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);
|
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);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Default destructor.
|
\brief Default destructor.
|
||||||
*/
|
*/
|
||||||
~AX25Frame();
|
~AX25Frame();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief Overload for assignment operator.
|
||||||
|
|
||||||
|
\param frame rvalue AX25Frame.
|
||||||
|
*/
|
||||||
|
AX25Frame& operator=(const AX25Frame& frame);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Method to set the repeater callsigns and SSIDs.
|
\brief Method to set the repeater callsigns and SSIDs.
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue