diff --git a/src/helpers/radiolib/CustomSX1262Wrapper.h b/src/helpers/radiolib/CustomSX1262Wrapper.h index 1afee5e8b..c4192e875 100644 --- a/src/helpers/radiolib/CustomSX1262Wrapper.h +++ b/src/helpers/radiolib/CustomSX1262Wrapper.h @@ -3,6 +3,12 @@ #include "CustomSX1262.h" #include "RadioLibWrappers.h" +// RSSI_OFFSET is used to compensate for external LNA gain (e.g. Heltec V4) +// Set to a negative value equal to the LNA gain to get true RSSI values +#ifndef RSSI_OFFSET + #define RSSI_OFFSET 0 +#endif + class CustomSX1262Wrapper : public RadioLibWrapper { public: CustomSX1262Wrapper(CustomSX1262& radio, mesh::MainBoard& board) : RadioLibWrapper(radio, board) { } @@ -10,9 +16,9 @@ class CustomSX1262Wrapper : public RadioLibWrapper { return ((CustomSX1262 *)_radio)->isReceiving(); } float getCurrentRSSI() override { - return ((CustomSX1262 *)_radio)->getRSSI(false); + return ((CustomSX1262 *)_radio)->getRSSI(false) + RSSI_OFFSET; } - float getLastRSSI() const override { return ((CustomSX1262 *)_radio)->getRSSI(); } + float getLastRSSI() const override { return ((CustomSX1262 *)_radio)->getRSSI() + RSSI_OFFSET; } float getLastSNR() const override { return ((CustomSX1262 *)_radio)->getSNR(); } float packetScore(float snr, int packet_len) override { diff --git a/variants/heltec_v4/platformio.ini b/variants/heltec_v4/platformio.ini index ecfd7889b..5f784a876 100644 --- a/variants/heltec_v4/platformio.ini +++ b/variants/heltec_v4/platformio.ini @@ -31,6 +31,7 @@ build_flags = -D SX126X_DIO3_TCXO_VOLTAGE=1.8 -D SX126X_CURRENT_LIMIT=140 -D SX126X_RX_BOOSTED_GAIN=1 + -D RSSI_OFFSET=-17 ; GC1109 LNA gain compensation (17dB) - subtract to get true RSSI -D PIN_GPS_RX=38 -D PIN_GPS_TX=39 -D PIN_GPS_RESET=42