Make BLE TX power configurable for nRF52 variants (#9232)

* Make BLE TX power configurable for nRF52 variants

* Include BLE TX power setting in T114 variant.h as tested

---------

Co-authored-by: Ben Meadors <benmmeadors@gmail.com>
This commit is contained in:
Mattijs
2026-01-23 11:26:01 -06:00
committed by GitHub
co-authored by GitHub Ben Meadors
parent 73932dd1c3
commit 0157a769c3
2 changed files with 19 additions and 0 deletions
+11
View File
@@ -240,6 +240,14 @@ int NRF52Bluetooth::getRssi()
{
return 0; // FIXME figure out where to source this
}
// Valid BLE TX power levels as per nRF52840 Product Specification are: "-20 to +8 dBm TX power, configurable in 4 dB steps".
// See https://docs.nordicsemi.com/bundle/ps_nrf52840/page/keyfeatures_html5.html
#define VALID_BLE_TX_POWER(x) \
((x) == -20 || (x) == -16 || (x) == -12 || \
(x) == -8 || (x) == -4 || (x) == 0 || \
(x) == 4 || (x) == 8)
void NRF52Bluetooth::setup()
{
// Initialise the Bluefruit module
@@ -251,6 +259,9 @@ void NRF52Bluetooth::setup()
Bluefruit.Advertising.stop();
Bluefruit.Advertising.clearData();
Bluefruit.ScanResponse.clearData();
#if defined(NRF52_BLE_TX_POWER) && VALID_BLE_TX_POWER(NRF52_BLE_TX_POWER)
Bluefruit.setTxPower(NRF52_BLE_TX_POWER);
#endif
if (config.bluetooth.mode != meshtastic_Config_BluetoothConfig_PairingMode_NO_PIN) {
configuredPasskey = config.bluetooth.mode == meshtastic_Config_BluetoothConfig_PairingMode_FIXED_PIN
? config.bluetooth.fixed_pin
@@ -150,6 +150,14 @@ No longer populated on PCB
#define PIN_SPI1_MOSI ST7789_SDA
#define PIN_SPI1_SCK ST7789_SCK
/*
* Bluetooth
*/
// The bluetooth transmit power on the nRF52840 is adjustable from -20dB to +8dB in steps of 4dB
// so NRF52_BLE_TX_POWER can be set to -20, -16, -12, -8, -4, 0 (default), 4, and 8.
//#define NRF52_BLE_TX_POWER 8
/*
* GPS pins
*/