From bc9a3d50939398623cc1ac916e3fab2934cb4871 Mon Sep 17 00:00:00 2001 From: Links2004 Date: Sat, 20 Sep 2025 12:02:15 +0200 Subject: [PATCH] Disable BLE Client role to save space --- arch/esp32/esp32.ini | 1 + src/nimble/NimbleBluetooth.cpp | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/arch/esp32/esp32.ini b/arch/esp32/esp32.ini index fcba1247f..f0122e236 100644 --- a/arch/esp32/esp32.ini +++ b/arch/esp32/esp32.ini @@ -33,6 +33,7 @@ build_flags = -DCONFIG_BT_NIMBLE_ENABLED -DNIMBLE_TWO -DCONFIG_NIMBLE_CPP_LOG_LEVEL=2 + -DCONFIG_BT_NIMBLE_ROLE_CENTRAL_DISABLED -DCONFIG_BT_NIMBLE_MAX_CCCDS=20 -DCONFIG_BT_NIMBLE_HOST_TASK_STACK_SIZE=8192 -DESP_OPENSSL_SUPPRESS_LEGACY_WARNING diff --git a/src/nimble/NimbleBluetooth.cpp b/src/nimble/NimbleBluetooth.cpp index 2b41efd0e..db217bbde 100644 --- a/src/nimble/NimbleBluetooth.cpp +++ b/src/nimble/NimbleBluetooth.cpp @@ -310,10 +310,24 @@ int NimbleBluetooth::getRssi() if (bleServer && isConnected()) { auto service = bleServer->getServiceByUUID(MESH_SERVICE_UUID); uint16_t handle = service->getHandle(); +#ifdef CONFIG_BT_NIMBLE_ROLE_CENTRAL_DISABLED + if (handle == BLE_HS_CONN_HANDLE_NONE) { + return 0; + } + + int8_t rssi = 0; + int rc = ble_gap_conn_rssi(handle, &rssi); + if (rc != 0) { + return 0; + } + + return rssi; +#else #ifdef NIMBLE_TWO return NimBLEDevice::getClientByHandle(handle)->getRssi(); #else return NimBLEDevice::getClientByID(handle)->getRssi(); +#endif #endif } return 0; // FIXME figure out where to source this