From 1a671f287753e9140b72dd8bd83676766059fa0b Mon Sep 17 00:00:00 2001 From: Vladislav Osmanov <7123463+osmanovv@users.noreply.github.com> Date: Wed, 8 Sep 2021 14:30:52 +0300 Subject: [PATCH] override new RadioLib's default current limit value (60 mA) to the previous value of 100mA --- src/mesh/RF95Interface.cpp | 6 ++++++ src/mesh/RadioLibRF95.cpp | 6 ++++++ src/mesh/RadioLibRF95.h | 5 +++++ src/mesh/SX1262Interface.cpp | 6 ++++++ 4 files changed, 23 insertions(+) diff --git a/src/mesh/RF95Interface.cpp b/src/mesh/RF95Interface.cpp index 8ba3b6e29..8b7d9f112 100644 --- a/src/mesh/RF95Interface.cpp +++ b/src/mesh/RF95Interface.cpp @@ -70,6 +70,12 @@ bool RF95Interface::init() int res = lora->begin(freq, bw, sf, cr, syncWord, power, currentLimit, preambleLength); DEBUG_MSG("RF95 init result %d\n", res); + // current limit was removed from module' ctor + // override default value (60 mA) + res = lora->setCurrentLimit(currentLimit); + DEBUG_MSG("Current limit set to %f\n", currentLimit); + DEBUG_MSG("Current limit set result %d\n", res); + if (res == ERR_NONE) res = lora->setCRC(SX126X_LORA_CRC_ON); diff --git a/src/mesh/RadioLibRF95.cpp b/src/mesh/RadioLibRF95.cpp index 1bb2eca42..dcb987d1b 100644 --- a/src/mesh/RadioLibRF95.cpp +++ b/src/mesh/RadioLibRF95.cpp @@ -19,6 +19,12 @@ int16_t RadioLibRF95::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_ state = SX127x::begin(RF95_ALT_VERSION, syncWord, preambleLength); RADIOLIB_ASSERT(state); + // current limit was removed from module' ctor + // override default value (60 mA) + state = setCurrentLimit(currentLimit); + DEBUG_MSG("Current limit set to %f\n", currentLimit); + DEBUG_MSG("Current limit set result %d\n", state); + // configure settings not accessible by API state = config(); RADIOLIB_ASSERT(state); diff --git a/src/mesh/RadioLibRF95.h b/src/mesh/RadioLibRF95.h index bfe805f42..d6aeb541a 100644 --- a/src/mesh/RadioLibRF95.h +++ b/src/mesh/RadioLibRF95.h @@ -62,6 +62,11 @@ class RadioLibRF95: public SX1278 { /// For debugging uint8_t readReg(uint8_t addr); + protected: + // since default current limit for SX126x/127x in updated RadioLib is 60mA + // use the previous value + float currentLimit = 100; + #ifndef RADIOLIB_GODMODE private: #endif diff --git a/src/mesh/SX1262Interface.cpp b/src/mesh/SX1262Interface.cpp index 0d27bb0b2..76d44625f 100644 --- a/src/mesh/SX1262Interface.cpp +++ b/src/mesh/SX1262Interface.cpp @@ -53,6 +53,12 @@ bool SX1262Interface::init() int res = lora.begin(freq, bw, sf, cr, syncWord, power, preambleLength, tcxoVoltage, useRegulatorLDO); DEBUG_MSG("SX1262 init result %d\n", res); + // current limit was removed from module' ctor + // override default value (60 mA) + res = lora.setCurrentLimit(currentLimit); + DEBUG_MSG("Current limit set to %f\n", currentLimit); + DEBUG_MSG("Current limit set result %d\n", res); + #ifdef SX1262_TXEN // lora.begin sets Dio2 as RF switch control, which is not true if we are manually controlling RX and TX if (res == ERR_NONE)