From 91787eb26926c48d265768586d33a80ed8a03a2e Mon Sep 17 00:00:00 2001 From: jgromes Date: Thu, 6 Jul 2023 11:10:20 +0200 Subject: [PATCH] [PHY] Implemented more common methods --- src/protocols/PhysicalLayer/PhysicalLayer.cpp | 26 +++++++++ src/protocols/PhysicalLayer/PhysicalLayer.h | 54 +++++++++++++++++++ 2 files changed, 80 insertions(+) diff --git a/src/protocols/PhysicalLayer/PhysicalLayer.cpp b/src/protocols/PhysicalLayer/PhysicalLayer.cpp index 1e9d3584..84d82832 100644 --- a/src/protocols/PhysicalLayer/PhysicalLayer.cpp +++ b/src/protocols/PhysicalLayer/PhysicalLayer.cpp @@ -246,6 +246,32 @@ int16_t PhysicalLayer::setEncoding(uint8_t encoding) { return(RADIOLIB_ERR_UNSUPPORTED); } +int16_t PhysicalLayer::invertIQ(bool enable) { + (void)enable; + return(RADIOLIB_ERR_UNSUPPORTED); +} + +int16_t PhysicalLayer::setOutputPower(int8_t power) { + (void)power; + return(RADIOLIB_ERR_UNSUPPORTED); +} + +int16_t PhysicalLayer::setSyncWord(uint8_t* sync, size_t len) { + (void)sync; + (void)len; + return(RADIOLIB_ERR_UNSUPPORTED); +} + +int16_t PhysicalLayer::setPreambleLength(size_t len) { + (void)len; + return(RADIOLIB_ERR_UNSUPPORTED); +} + +int16_t PhysicalLayer::setDataRate(DataRate_t dr) { + (void)dr; + return(RADIOLIB_ERR_UNSUPPORTED); +} + float PhysicalLayer::getFreqStep() const { return(this->freqStep); } diff --git a/src/protocols/PhysicalLayer/PhysicalLayer.h b/src/protocols/PhysicalLayer/PhysicalLayer.h index 4e9ceb51..95a7ae6c 100644 --- a/src/protocols/PhysicalLayer/PhysicalLayer.h +++ b/src/protocols/PhysicalLayer/PhysicalLayer.h @@ -4,6 +4,24 @@ #include "../../TypeDef.h" #include "../../Module.h" +// data rate structure interpretation in case LoRa is used +struct LoRaRate_t { + uint8_t spreadingFactor; + float bandwidth; +}; + +// data rate structure interpretation in case FSK is used +struct FSKRate_t { + float bitRate; + float freqDev; +}; + +// common data rate +union DataRate_t { + LoRaRate_t lora; + FSKRate_t fsk; +}; + /*! \class PhysicalLayer @@ -223,6 +241,42 @@ class PhysicalLayer { */ virtual int16_t setEncoding(uint8_t encoding); + /*! + \brief Set IQ inversion. Must be implemented in module class if the module supports it. + \param enable True to use inverted IQ, false for non-inverted. + \returns \ref status_codes + */ + virtual int16_t invertIQ(bool enable); + + /*! + \brief Set output power. Must be implemented in module class if the module supports it. + \param power Output power in dBm. The allowed range depends on the module used. + \returns \ref status_codes + */ + virtual int16_t setOutputPower(int8_t power); + + /*! + \brief Set sync word. Must be implemented in module class if the module supports it. + \param sync Pointer to the sync word. + \param len Sync word length in bytes. Maximum length depends on the module used. + \returns \ref status_codes + */ + virtual int16_t setSyncWord(uint8_t* sync, size_t len); + + /*! + \brief Set preamble length. Must be implemented in module class if the module supports it. + \param len Preamble length in bytes. Maximum length depends on the module used. + \returns \ref status_codes + */ + virtual int16_t setPreambleLength(size_t len); + + /*! + \brief Set data. Must be implemented in module class if the module supports it. + \param dr Data rate struct. Interpretation depends on currently active modem (FSK or LoRa). + \returns \ref status_codes + */ + virtual int16_t setDataRate(DataRate_t dr); + /*! \brief Gets the module frequency step size that was set in constructor. \returns Synthesizer frequency step size in Hz.