[PHY] Make frequency step and max packet length public variables

This commit is contained in:
jgromes 2025-02-15 14:47:45 +01:00
parent 35059a86ff
commit 2fd2926c9f
9 changed files with 25 additions and 32 deletions

View file

@ -1,20 +1,23 @@
#include "ExternalRadio.h" #include "ExternalRadio.h"
#if defined(RADIOLIB_BUILD_ARDUINO) #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 = new Module(RADIOLIB_NC, RADIOLIB_NC, RADIOLIB_NC, pin);
mod->hal->pinMode(pin, mod->hal->GpioModeOutput); mod->hal->pinMode(pin, mod->hal->GpioModeOutput);
this->prevFrf = 0; this->prevFrf = 0;
} }
#endif #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 = new Module(hal, RADIOLIB_NC, RADIOLIB_NC, RADIOLIB_NC, pin);
mod->hal->pinMode(pin, mod->hal->GpioModeOutput); mod->hal->pinMode(pin, mod->hal->GpioModeOutput);
this->prevFrf = 0; this->prevFrf = 0;
} }
ExternalRadio::ExternalRadio(const ExternalRadio& ext) : PhysicalLayer(1, 0) { ExternalRadio::ExternalRadio(const ExternalRadio& ext) : PhysicalLayer() {
this->freqStep = 1;
this->prevFrf = ext.prevFrf; this->prevFrf = ext.prevFrf;
if(ext.mod) { if(ext.mod) {
this->mod = new Module(ext.mod->hal, RADIOLIB_NC, RADIOLIB_NC, RADIOLIB_NC, ext.mod->getGpio()); this->mod = new Module(ext.mod->hal, RADIOLIB_NC, RADIOLIB_NC, RADIOLIB_NC, ext.mod->getGpio());

View file

@ -34,7 +34,7 @@ int16_t FSK4Client::begin(float base, uint32_t shift, uint16_t rate) {
} }
// calculate 24-bit frequency // calculate 24-bit frequency
baseFreq = (base * 1000000.0f) / phyLayer->getFreqStep(); baseFreq = (base * 1000000.0f) / phyLayer->freqStep;
// configure for direct mode // configure for direct mode
return(phyLayer->startDirect()); return(phyLayer->startDirect());
@ -109,7 +109,7 @@ int16_t FSK4Client::standby() {
int32_t FSK4Client::getRawShift(int32_t shift) { int32_t FSK4Client::getRawShift(int32_t shift) {
// calculate module carrier frequency resolution // calculate module carrier frequency resolution
int32_t step = round(phyLayer->getFreqStep()); int32_t step = round(phyLayer->freqStep);
// check minimum shift value // check minimum shift value
if(RADIOLIB_ABS(shift) < step / 2) { if(RADIOLIB_ABS(shift) < step / 2) {

View file

@ -21,7 +21,7 @@ HellClient::HellClient(AFSKClient* audio) {
int16_t HellClient::begin(float base, float rate) { int16_t HellClient::begin(float base, float rate) {
// calculate 24-bit frequency // calculate 24-bit frequency
baseFreqHz = base; baseFreqHz = base;
baseFreq = (base * 1000000.0f) / phyLayer->getFreqStep(); baseFreq = (base * 1000000.0f) / phyLayer->freqStep;
// calculate "pixel" duration // calculate "pixel" duration
pixelDuration = 1000000.0f/rate; pixelDuration = 1000000.0f/rate;

View file

@ -23,7 +23,7 @@ MorseClient::MorseClient(AFSKClient* audio) {
int16_t MorseClient::begin(float base, uint8_t speed) { int16_t MorseClient::begin(float base, uint8_t speed) {
// calculate 24-bit frequency // calculate 24-bit frequency
baseFreqHz = base; baseFreqHz = base;
baseFreq = (base * 1000000.0f) / phyLayer->getFreqStep(); baseFreq = (base * 1000000.0f) / phyLayer->freqStep;
// calculate tone period for decoding // calculate tone period for decoding
basePeriod = (1000000.0f/base)/2.0f; basePeriod = (1000000.0f/base)/2.0f;

View file

@ -39,10 +39,10 @@ int16_t PagerClient::begin(float base, uint16_t speed, bool invert, uint16_t shi
// calculate 24-bit frequency // calculate 24-bit frequency
baseFreq = base; baseFreq = base;
baseFreqRaw = (baseFreq * 1000000.0f) / phyLayer->getFreqStep(); baseFreqRaw = (baseFreq * 1000000.0f) / phyLayer->freqStep;
// calculate module carrier frequency resolution // calculate module carrier frequency resolution
uint16_t step = round(phyLayer->getFreqStep()); uint16_t step = round(phyLayer->freqStep);
// calculate raw frequency shift // calculate raw frequency shift
shiftFreqHz = shift; shiftFreqHz = shift;

View file

@ -2,9 +2,7 @@
#include <string.h> #include <string.h>
PhysicalLayer::PhysicalLayer(float step, size_t maxLen) { PhysicalLayer::PhysicalLayer() {
this->freqStep = step;
this->maxPacketLength = maxLen;
#if !RADIOLIB_EXCLUDE_DIRECT_RECEIVE #if !RADIOLIB_EXCLUDE_DIRECT_RECEIVE
this->bufferBitPos = 0; this->bufferBitPos = 0;
this->bufferWritePos = 0; this->bufferWritePos = 0;
@ -294,10 +292,6 @@ int16_t PhysicalLayer::checkDataRate(DataRate_t dr) {
return(RADIOLIB_ERR_UNSUPPORTED); return(RADIOLIB_ERR_UNSUPPORTED);
} }
float PhysicalLayer::getFreqStep() const {
return(this->freqStep);
}
size_t PhysicalLayer::getPacketLength(bool update) { size_t PhysicalLayer::getPacketLength(bool update) {
(void)update; (void)update;
return(0); return(0);

View file

@ -216,14 +216,18 @@ enum RadioModeType_t {
class PhysicalLayer { class PhysicalLayer {
public: 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 // constructor
/*! /*!
\brief Default 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 // basic methods
@ -475,12 +479,6 @@ class PhysicalLayer {
*/ */
virtual int16_t checkDataRate(DataRate_t dr); 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. \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. \param update Update received packet length. Will return cached value when set to false.
@ -778,8 +776,6 @@ class PhysicalLayer {
#if !RADIOLIB_GODMODE #if !RADIOLIB_GODMODE
private: private:
#endif #endif
float freqStep;
size_t maxPacketLength;
#if !RADIOLIB_EXCLUDE_DIRECT_RECEIVE #if !RADIOLIB_EXCLUDE_DIRECT_RECEIVE
uint8_t bufferBitPos = 0; uint8_t bufferBitPos = 0;

View file

@ -31,7 +31,7 @@ int16_t RTTYClient::begin(float base, uint32_t shift, uint16_t rate, uint8_t enc
bitDuration = (RadioLibTime_t)1000000/rate; bitDuration = (RadioLibTime_t)1000000/rate;
// calculate module carrier frequency resolution // calculate module carrier frequency resolution
uint32_t step = round(phyLayer->getFreqStep()); uint32_t step = round(phyLayer->freqStep);
// check minimum shift value // check minimum shift value
if(shift < step / 2) { 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 // calculate 24-bit frequency
baseFreq = (base * 1000000.0f) / phyLayer->getFreqStep(); baseFreq = (base * 1000000.0f) / phyLayer->freqStep;
// configure for direct mode // configure for direct mode
return(phyLayer->startDirect()); return(phyLayer->startDirect());

View file

@ -219,7 +219,7 @@ int16_t SSTVClient::begin(float base, const SSTVMode_t& mode) {
txMode = mode; txMode = mode;
// calculate 24-bit frequency // calculate 24-bit frequency
baseFreq = (base * 1000000.0f) / phyLayer->getFreqStep(); baseFreq = (base * 1000000.0f) / phyLayer->freqStep;
// configure for direct mode // configure for direct mode
return(phyLayer->startDirect()); return(phyLayer->startDirect());
@ -365,10 +365,10 @@ void SSTVClient::tone(float freq, RadioLibTime_t len) {
if(audioClient != nullptr) { if(audioClient != nullptr) {
audioClient->tone(freq, false); audioClient->tone(freq, false);
} else { } else {
phyLayer->transmitDirect(baseFreq + (freq / phyLayer->getFreqStep())); phyLayer->transmitDirect(baseFreq + (freq / phyLayer->freqStep));
} }
#else #else
phyLayer->transmitDirect(baseFreq + (freq / phyLayer->getFreqStep())); phyLayer->transmitDirect(baseFreq + (freq / phyLayer->freqStep));
#endif #endif
mod->waitForMicroseconds(start, len); mod->waitForMicroseconds(start, len);
} }