diff --git a/src/protocols/ExternalRadio/ExternalRadio.cpp b/src/protocols/ExternalRadio/ExternalRadio.cpp index 212f8a15..48a7790c 100644 --- a/src/protocols/ExternalRadio/ExternalRadio.cpp +++ b/src/protocols/ExternalRadio/ExternalRadio.cpp @@ -1,20 +1,23 @@ #include "ExternalRadio.h" #if defined(RADIOLIB_BUILD_ARDUINO) -ExternalRadio::ExternalRadio(uint32_t pin) : PhysicalLayer(1, 0) { +ExternalRadio::ExternalRadio(uint32_t pin) : PhysicalLayer() { + this->freqStep = 1; mod = new Module(RADIOLIB_NC, RADIOLIB_NC, RADIOLIB_NC, pin); mod->hal->pinMode(pin, mod->hal->GpioModeOutput); this->prevFrf = 0; } #endif -ExternalRadio::ExternalRadio(RadioLibHal *hal, uint32_t pin) : PhysicalLayer(1, 0) { +ExternalRadio::ExternalRadio(RadioLibHal *hal, uint32_t pin) : PhysicalLayer() { + this->freqStep = 1; mod = new Module(hal, RADIOLIB_NC, RADIOLIB_NC, RADIOLIB_NC, pin); mod->hal->pinMode(pin, mod->hal->GpioModeOutput); this->prevFrf = 0; } -ExternalRadio::ExternalRadio(const ExternalRadio& ext) : PhysicalLayer(1, 0) { +ExternalRadio::ExternalRadio(const ExternalRadio& ext) : PhysicalLayer() { + this->freqStep = 1; this->prevFrf = ext.prevFrf; if(ext.mod) { this->mod = new Module(ext.mod->hal, RADIOLIB_NC, RADIOLIB_NC, RADIOLIB_NC, ext.mod->getGpio()); diff --git a/src/protocols/FSK4/FSK4.cpp b/src/protocols/FSK4/FSK4.cpp index 4eb9b7bf..b96362e2 100644 --- a/src/protocols/FSK4/FSK4.cpp +++ b/src/protocols/FSK4/FSK4.cpp @@ -34,7 +34,7 @@ int16_t FSK4Client::begin(float base, uint32_t shift, uint16_t rate) { } // calculate 24-bit frequency - baseFreq = (base * 1000000.0f) / phyLayer->getFreqStep(); + baseFreq = (base * 1000000.0f) / phyLayer->freqStep; // configure for direct mode return(phyLayer->startDirect()); @@ -109,7 +109,7 @@ int16_t FSK4Client::standby() { int32_t FSK4Client::getRawShift(int32_t shift) { // calculate module carrier frequency resolution - int32_t step = round(phyLayer->getFreqStep()); + int32_t step = round(phyLayer->freqStep); // check minimum shift value if(RADIOLIB_ABS(shift) < step / 2) { diff --git a/src/protocols/Hellschreiber/Hellschreiber.cpp b/src/protocols/Hellschreiber/Hellschreiber.cpp index 907aab7c..5e5d3c2b 100644 --- a/src/protocols/Hellschreiber/Hellschreiber.cpp +++ b/src/protocols/Hellschreiber/Hellschreiber.cpp @@ -21,7 +21,7 @@ HellClient::HellClient(AFSKClient* audio) { int16_t HellClient::begin(float base, float rate) { // calculate 24-bit frequency baseFreqHz = base; - baseFreq = (base * 1000000.0f) / phyLayer->getFreqStep(); + baseFreq = (base * 1000000.0f) / phyLayer->freqStep; // calculate "pixel" duration pixelDuration = 1000000.0f/rate; diff --git a/src/protocols/Morse/Morse.cpp b/src/protocols/Morse/Morse.cpp index fbacc824..b5de2741 100644 --- a/src/protocols/Morse/Morse.cpp +++ b/src/protocols/Morse/Morse.cpp @@ -23,7 +23,7 @@ MorseClient::MorseClient(AFSKClient* audio) { int16_t MorseClient::begin(float base, uint8_t speed) { // calculate 24-bit frequency baseFreqHz = base; - baseFreq = (base * 1000000.0f) / phyLayer->getFreqStep(); + baseFreq = (base * 1000000.0f) / phyLayer->freqStep; // calculate tone period for decoding basePeriod = (1000000.0f/base)/2.0f; diff --git a/src/protocols/Pager/Pager.cpp b/src/protocols/Pager/Pager.cpp index 905778ed..e4615a51 100644 --- a/src/protocols/Pager/Pager.cpp +++ b/src/protocols/Pager/Pager.cpp @@ -39,10 +39,10 @@ int16_t PagerClient::begin(float base, uint16_t speed, bool invert, uint16_t shi // calculate 24-bit frequency baseFreq = base; - baseFreqRaw = (baseFreq * 1000000.0f) / phyLayer->getFreqStep(); + baseFreqRaw = (baseFreq * 1000000.0f) / phyLayer->freqStep; // calculate module carrier frequency resolution - uint16_t step = round(phyLayer->getFreqStep()); + uint16_t step = round(phyLayer->freqStep); // calculate raw frequency shift shiftFreqHz = shift; diff --git a/src/protocols/PhysicalLayer/PhysicalLayer.cpp b/src/protocols/PhysicalLayer/PhysicalLayer.cpp index 3b7d870a..b2e61d7d 100644 --- a/src/protocols/PhysicalLayer/PhysicalLayer.cpp +++ b/src/protocols/PhysicalLayer/PhysicalLayer.cpp @@ -2,9 +2,7 @@ #include -PhysicalLayer::PhysicalLayer(float step, size_t maxLen) { - this->freqStep = step; - this->maxPacketLength = maxLen; +PhysicalLayer::PhysicalLayer() { #if !RADIOLIB_EXCLUDE_DIRECT_RECEIVE this->bufferBitPos = 0; this->bufferWritePos = 0; @@ -294,10 +292,6 @@ int16_t PhysicalLayer::checkDataRate(DataRate_t dr) { return(RADIOLIB_ERR_UNSUPPORTED); } -float PhysicalLayer::getFreqStep() const { - return(this->freqStep); -} - size_t PhysicalLayer::getPacketLength(bool update) { (void)update; return(0); diff --git a/src/protocols/PhysicalLayer/PhysicalLayer.h b/src/protocols/PhysicalLayer/PhysicalLayer.h index 3d785b6d..8cb32a0d 100644 --- a/src/protocols/PhysicalLayer/PhysicalLayer.h +++ b/src/protocols/PhysicalLayer/PhysicalLayer.h @@ -216,14 +216,18 @@ enum RadioModeType_t { class PhysicalLayer { public: + /*! \brief Frequency step of the synthesizer in Hz. */ + float freqStep; + + /*! \brief Maximum length of packet that can be received by the module. */ + size_t maxPacketLength; + // constructor /*! \brief Default constructor. - \param step Frequency step of the synthesizer in Hz. - \param maxLen Maximum length of packet that can be received by the module. */ - PhysicalLayer(float step, size_t maxLen); + PhysicalLayer(); // basic methods @@ -475,12 +479,6 @@ class PhysicalLayer { */ virtual int16_t checkDataRate(DataRate_t dr); - /*! - \brief Gets the module frequency step size that was set in constructor. - \returns Synthesizer frequency step size in Hz. - */ - float getFreqStep() const; - /*! \brief Query modem for the packet length of received payload. Must be implemented in module class. \param update Update received packet length. Will return cached value when set to false. @@ -778,8 +776,6 @@ class PhysicalLayer { #if !RADIOLIB_GODMODE private: #endif - float freqStep; - size_t maxPacketLength; #if !RADIOLIB_EXCLUDE_DIRECT_RECEIVE uint8_t bufferBitPos = 0; diff --git a/src/protocols/RTTY/RTTY.cpp b/src/protocols/RTTY/RTTY.cpp index aceddbe8..61fe7cdf 100644 --- a/src/protocols/RTTY/RTTY.cpp +++ b/src/protocols/RTTY/RTTY.cpp @@ -31,7 +31,7 @@ int16_t RTTYClient::begin(float base, uint32_t shift, uint16_t rate, uint8_t enc bitDuration = (RadioLibTime_t)1000000/rate; // calculate module carrier frequency resolution - uint32_t step = round(phyLayer->getFreqStep()); + uint32_t step = round(phyLayer->freqStep); // check minimum shift value if(shift < step / 2) { @@ -46,7 +46,7 @@ int16_t RTTYClient::begin(float base, uint32_t shift, uint16_t rate, uint8_t enc } // calculate 24-bit frequency - baseFreq = (base * 1000000.0f) / phyLayer->getFreqStep(); + baseFreq = (base * 1000000.0f) / phyLayer->freqStep; // configure for direct mode return(phyLayer->startDirect()); diff --git a/src/protocols/SSTV/SSTV.cpp b/src/protocols/SSTV/SSTV.cpp index b4df4252..397dc80b 100644 --- a/src/protocols/SSTV/SSTV.cpp +++ b/src/protocols/SSTV/SSTV.cpp @@ -219,7 +219,7 @@ int16_t SSTVClient::begin(float base, const SSTVMode_t& mode) { txMode = mode; // calculate 24-bit frequency - baseFreq = (base * 1000000.0f) / phyLayer->getFreqStep(); + baseFreq = (base * 1000000.0f) / phyLayer->freqStep; // configure for direct mode return(phyLayer->startDirect()); @@ -365,10 +365,10 @@ void SSTVClient::tone(float freq, RadioLibTime_t len) { if(audioClient != nullptr) { audioClient->tone(freq, false); } else { - phyLayer->transmitDirect(baseFreq + (freq / phyLayer->getFreqStep())); + phyLayer->transmitDirect(baseFreq + (freq / phyLayer->freqStep)); } #else - phyLayer->transmitDirect(baseFreq + (freq / phyLayer->getFreqStep())); + phyLayer->transmitDirect(baseFreq + (freq / phyLayer->freqStep)); #endif mod->waitForMicroseconds(start, len); }