From 0a2539650e9e6edd35225258d717104616e118f5 Mon Sep 17 00:00:00 2001 From: Andrew Moroz Date: Mon, 16 Jan 2023 23:35:56 -0500 Subject: [PATCH] sx126x-rx-boosted-gain: add support for setting Rx gain mode on SX126x chipsets --- platformio.ini | 2 +- src/mesh/NodeDB.cpp | 1 + src/mesh/SX126xInterface.cpp | 9 +++++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/platformio.ini b/platformio.ini index e58656dd2..2b77864aa 100644 --- a/platformio.ini +++ b/platformio.ini @@ -66,7 +66,7 @@ lib_deps = nanopb/Nanopb@^0.4.6 erriez/ErriezCRC32@^1.0.1 ; jgromes/RadioLib@^5.5.1 - https://github.com/jgromes/RadioLib.git#395844922c5d88d5db0481a9c91479931172428d + https://github.com/jgromes/RadioLib.git#7a25b27c3183ffe3627c5c221243c378d8951da7 ; Used for the code analysis in PIO Home / Inspect check_tool = cppcheck diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index 076f56af6..86e4ca29b 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -162,6 +162,7 @@ void NodeDB::installDefaultConfig() config.has_bluetooth = true; config.lora.tx_enabled = true; // FIXME: maybe false in the future, and setting region to enable it. (unset region forces it off) config.lora.override_duty_cycle = false; + config.lora.sx126x_rx_boosted_gain = false; config.lora.region = Config_LoRaConfig_RegionCode_UNSET; config.lora.modem_preset = Config_LoRaConfig_ModemPreset_LONG_FAST; config.lora.hop_limit = HOP_RELIABLE; diff --git a/src/mesh/SX126xInterface.cpp b/src/mesh/SX126xInterface.cpp index 0e033eeb6..79259d595 100644 --- a/src/mesh/SX126xInterface.cpp +++ b/src/mesh/SX126xInterface.cpp @@ -1,5 +1,6 @@ #include "configuration.h" #include "SX126xInterface.h" +#include "mesh/NodeDB.h" #include "error.h" // Particular boards might define a different max power based on what their hardware can do @@ -73,6 +74,14 @@ bool SX126xInterface::init() res = lora.setDio2AsRfSwitch(true); #endif +if (config.lora.sx126x_rx_boosted_gain) { + uint16_t result = lora.setRxBoostedGainMode(true); + LOG_INFO("Set Rx Boosted Gain mode; result: %d\n", result); +} else { + uint16_t result = lora.setRxBoostedGainMode(false); + LOG_INFO("Set Rx Power Saving Gain mode; result: %d\n", result); +} + #if 0 // Read/write a register we are not using (only used for FSK mode) to test SPI comms uint8_t crcLSB = 0;