diff --git a/src/modules/SX126x/SX1262.cpp b/src/modules/SX126x/SX1262.cpp index 33422125..fcfbb2b0 100644 --- a/src/modules/SX126x/SX1262.cpp +++ b/src/modules/SX126x/SX1262.cpp @@ -7,10 +7,16 @@ SX1262::SX1262(Module* mod) : SX126x(mod) { int16_t SX1262::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t syncWord, int8_t power, uint16_t preambleLength, float tcxoVoltage, bool useRegulatorLDO) { // execute common part - int16_t state = SX126x::begin(bw, sf, cr, syncWord, preambleLength, tcxoVoltage, useRegulatorLDO); + int16_t state = SX126x::begin(cr, syncWord, preambleLength, tcxoVoltage, useRegulatorLDO); RADIOLIB_ASSERT(state); // configure publicly accessible settings + state = setSpreadingFactor(sf); + RADIOLIB_ASSERT(state); + + state = setBandwidth(bw); + RADIOLIB_ASSERT(state); + state = setFrequency(freq); RADIOLIB_ASSERT(state); diff --git a/src/modules/SX126x/SX1268.cpp b/src/modules/SX126x/SX1268.cpp index dfa65430..fb6a95e0 100644 --- a/src/modules/SX126x/SX1268.cpp +++ b/src/modules/SX126x/SX1268.cpp @@ -7,13 +7,19 @@ SX1268::SX1268(Module* mod) : SX126x(mod) { int16_t SX1268::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t syncWord, int8_t power, uint16_t preambleLength, float tcxoVoltage, bool useRegulatorLDO) { // execute common part - int16_t state = SX126x::begin(bw, sf, cr, syncWord, preambleLength, tcxoVoltage, useRegulatorLDO); + int16_t state = SX126x::begin(cr, syncWord, preambleLength, tcxoVoltage, useRegulatorLDO); RADIOLIB_ASSERT(state); // configure publicly accessible settings state = setFrequency(freq); RADIOLIB_ASSERT(state); + state = setSpreadingFactor(sf); + RADIOLIB_ASSERT(state); + + state = setBandwidth(bw); + RADIOLIB_ASSERT(state); + state = setOutputPower(power); RADIOLIB_ASSERT(state); diff --git a/src/modules/SX126x/SX126x.cpp b/src/modules/SX126x/SX126x.cpp index a8f4b013..bfe9dba5 100644 --- a/src/modules/SX126x/SX126x.cpp +++ b/src/modules/SX126x/SX126x.cpp @@ -9,7 +9,7 @@ Module* SX126x::getMod() { return(_mod); } -int16_t SX126x::begin(float bw, uint8_t sf, uint8_t cr, uint8_t syncWord, uint16_t preambleLength, float tcxoVoltage, bool useRegulatorLDO) { +int16_t SX126x::begin(uint8_t cr, uint8_t syncWord, uint16_t preambleLength, float tcxoVoltage, bool useRegulatorLDO) { // set module properties _mod->init(); _mod->pinMode(_mod->getIrq(), INPUT); @@ -17,8 +17,9 @@ int16_t SX126x::begin(float bw, uint8_t sf, uint8_t cr, uint8_t syncWord, uint16 RADIOLIB_DEBUG_PRINTLN(F("M\tSX126x")); // BW in kHz and SF are required in order to calculate LDRO for setModulationParams - _bwKhz = bw; - _sf = sf; + // set the defaults, this will get overwritten later anyway + _bwKhz = 125.0; + _sf = 9; // initialize configuration variables (will be overwritten during public settings configuration) _bw = RADIOLIB_SX126X_LORA_BW_125_0; @@ -49,12 +50,6 @@ int16_t SX126x::begin(float bw, uint8_t sf, uint8_t cr, uint8_t syncWord, uint16 } // configure publicly accessible settings - state = setSpreadingFactor(sf); - RADIOLIB_ASSERT(state); - - state = setBandwidth(bw); - RADIOLIB_ASSERT(state); - state = setCodingRate(cr); RADIOLIB_ASSERT(state); diff --git a/src/modules/SX126x/SX126x.h b/src/modules/SX126x/SX126x.h index bd9525ce..8c9b34a3 100644 --- a/src/modules/SX126x/SX126x.h +++ b/src/modules/SX126x/SX126x.h @@ -361,10 +361,6 @@ class SX126x: public PhysicalLayer { /*! \brief Initialization method for LoRa modem. - \param bw LoRa bandwidth in kHz. Allowed values are 7.8, 10.4, 15.6, 20.8, 31.25, 41.7, 62.5, 125.0, 250.0 and 500.0 kHz. - - \param sf LoRa spreading factor. Allowed values are in range 5 to 12. - \param cr LoRa coding rate denominator. Allowed values range from 5 to 8. \param syncWord 1-byte LoRa sync word. @@ -377,7 +373,7 @@ class SX126x: public PhysicalLayer { \returns \ref status_codes */ - int16_t begin(float bw, uint8_t sf, uint8_t cr, uint8_t syncWord, uint16_t preambleLength, float tcxoVoltage, bool useRegulatorLDO = false); + int16_t begin(uint8_t cr, uint8_t syncWord, uint16_t preambleLength, float tcxoVoltage, bool useRegulatorLDO = false); /*! \brief Initialization method for FSK modem.