From e5d280718cbd2d63b09b55686c5828b5f3196ebb Mon Sep 17 00:00:00 2001 From: jgromes Date: Fri, 25 Oct 2024 20:49:50 +0100 Subject: [PATCH] [SX126x] Added setModem implementation --- src/modules/SX126x/SX1262.cpp | 15 +++++++++++++++ src/modules/SX126x/SX1262.h | 8 ++++++++ src/modules/SX126x/SX1268.cpp | 15 +++++++++++++++ src/modules/SX126x/SX1268.h | 8 ++++++++ 4 files changed, 46 insertions(+) diff --git a/src/modules/SX126x/SX1262.cpp b/src/modules/SX126x/SX1262.cpp index 43c97063..70b4e56a 100644 --- a/src/modules/SX126x/SX1262.cpp +++ b/src/modules/SX126x/SX1262.cpp @@ -145,4 +145,19 @@ int16_t SX1262::checkOutputPower(int8_t power, int8_t* clipped) { return(RADIOLIB_ERR_NONE); } +int16_t SX1262::setModem(ModemType_t modem) { + switch(modem) { + case(ModemType_t::LoRa): { + return(this->begin()); + } break; + case(ModemType_t::FSK): { + return(this->beginFSK()); + } break; + case(ModemType_t::LRFHSS): { + return(this->beginLRFHSS()); + } break; + } + return(RADIOLIB_ERR_WRONG_MODEM); +} + #endif diff --git a/src/modules/SX126x/SX1262.h b/src/modules/SX126x/SX1262.h index c05ee4b1..0dc27444 100644 --- a/src/modules/SX126x/SX1262.h +++ b/src/modules/SX126x/SX1262.h @@ -109,6 +109,14 @@ class SX1262: public SX126x { \returns \ref status_codes */ int16_t checkOutputPower(int8_t power, int8_t* clipped) override; + + /*! + \brief Set modem for the radio to use. Will perform full reset and reconfigure the radio + using its default parameters. + \param modem Modem type to set - FSK, LoRa or LR-FHSS. + \returns \ref status_codes + */ + int16_t setModem(ModemType_t modem) override; #if !RADIOLIB_GODMODE private: diff --git a/src/modules/SX126x/SX1268.cpp b/src/modules/SX126x/SX1268.cpp index 78cfdae3..588d7c40 100644 --- a/src/modules/SX126x/SX1268.cpp +++ b/src/modules/SX126x/SX1268.cpp @@ -140,4 +140,19 @@ int16_t SX1268::checkOutputPower(int8_t power, int8_t* clipped) { return(RADIOLIB_ERR_NONE); } +int16_t SX1268::setModem(ModemType_t modem) { + switch(modem) { + case(ModemType_t::LoRa): { + return(this->begin()); + } break; + case(ModemType_t::FSK): { + return(this->beginFSK()); + } break; + case(ModemType_t::LRFHSS): { + return(this->beginLRFHSS()); + } break; + } + return(RADIOLIB_ERR_WRONG_MODEM); +} + #endif diff --git a/src/modules/SX126x/SX1268.h b/src/modules/SX126x/SX1268.h index ad411ee7..87cf9b5c 100644 --- a/src/modules/SX126x/SX1268.h +++ b/src/modules/SX126x/SX1268.h @@ -107,6 +107,14 @@ class SX1268: public SX126x { \returns \ref status_codes */ int16_t checkOutputPower(int8_t power, int8_t* clipped) override; + + /*! + \brief Set modem for the radio to use. Will perform full reset and reconfigure the radio + using its default parameters. + \param modem Modem type to set - FSK, LoRa or LR-FHSS. + \returns \ref status_codes + */ + int16_t setModem(ModemType_t modem) override; #if !RADIOLIB_GODMODE private: