From a94f510f27f1fe8a783d819cbdb95c415cd436e7 Mon Sep 17 00:00:00 2001 From: agessaman Date: Wed, 23 Sep 2026 21:56:27 -0700 Subject: [PATCH] radiolib: reapply runtime RX boosted gain on SX126x AGC reset sx126xResetAGC only restored the gain when the build defined SX126X_RX_BOOSTED_GAIN, so a gain set at runtime was lost on reset. Match lr11x0ResetAGC and always reapply. Also pass the gain state from the LLCC68 wrapper, whose call did not match the helper's signature. --- src/helpers/radiolib/CustomLLCC68Wrapper.h | 2 +- src/helpers/radiolib/SX126xReset.h | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/helpers/radiolib/CustomLLCC68Wrapper.h b/src/helpers/radiolib/CustomLLCC68Wrapper.h index 89d5e1bc..e96ae663 100644 --- a/src/helpers/radiolib/CustomLLCC68Wrapper.h +++ b/src/helpers/radiolib/CustomLLCC68Wrapper.h @@ -35,7 +35,7 @@ public: } uint8_t getSpreadingFactor() const override { return ((CustomLLCC68 *)_radio)->spreadingFactor; } - void doResetAGC() override { sx126xResetAGC((SX126x *)_radio); } + void doResetAGC() override { sx126xResetAGC((SX126x *)_radio, getRxBoostedGainMode()); } bool supportsRxBoostedGain() const override { return true; } bool setRxBoostedGainMode(bool en) override { diff --git a/src/helpers/radiolib/SX126xReset.h b/src/helpers/radiolib/SX126xReset.h index 472eb33b..bce84191 100644 --- a/src/helpers/radiolib/SX126xReset.h +++ b/src/helpers/radiolib/SX126xReset.h @@ -25,9 +25,8 @@ inline void sx126xResetAGC(SX126x* radio, bool rx_boost_gain) { #ifdef SX126X_DIO2_AS_RF_SWITCH radio->setDio2AsRfSwitch(SX126X_DIO2_AS_RF_SWITCH); #endif -#ifdef SX126X_RX_BOOSTED_GAIN + // always reapply: the gain may have been changed at runtime even when no build default is set radio->setRxBoostedGainMode(rx_boost_gain); -#endif #ifdef SX126X_REGISTER_PATCH uint8_t r_data = 0; radio->readRegister(0x8B5, &r_data, 1);