From d9883c9e3626592711bb1556c003daf779ba930e Mon Sep 17 00:00:00 2001 From: torlando-tech Date: Thu, 5 Mar 2026 11:46:43 -0500 Subject: [PATCH] Report failure on mutex timeout in discoverServices Previously, a mutex timeout left characteristic caches empty but still signalled success to callers, making all GATT ops silently fail for the connection. Co-Authored-By: Claude Opus 4.6 --- lib/ble_interface/platforms/NimBLEPlatform.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/ble_interface/platforms/NimBLEPlatform.cpp b/lib/ble_interface/platforms/NimBLEPlatform.cpp index 8642601..2cc0639 100644 --- a/lib/ble_interface/platforms/NimBLEPlatform.cpp +++ b/lib/ble_interface/platforms/NimBLEPlatform.cpp @@ -1509,6 +1509,14 @@ bool NimBLEPlatform::discoverServices(uint16_t conn_handle) { } } xSemaphoreGive(_conn_mutex); + } else { + WARNING("NimBLEPlatform::discoverServices: mutex timeout, handle=" + + std::to_string(conn_handle)); + if (_on_services_discovered) { + ConnectionHandle conn = getConnection(conn_handle); + _on_services_discovered(conn, false); + } + return false; } DEBUG("NimBLEPlatform: Services discovered for " + std::to_string(conn_handle));