[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
src/protocols

View file

@ -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());

View file

@ -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) {

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -2,9 +2,7 @@
#include <string.h>
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);

View file

@ -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;

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;
// 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());

View file

@ -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);
}