From c2639d7ceffff3de8c10521e6f5377b0698ff284 Mon Sep 17 00:00:00 2001 From: Guo-Rong <5484552+gkoh@users.noreply.github.com> Date: Wed, 10 Sep 2025 11:24:57 +0930 Subject: [PATCH] Find client by handle during disconnect event. If the peer has RPA enabled, searching by address fails due to address resolution. If this occurs, attempt to find the client by connection handle. --- src/NimBLEClient.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/NimBLEClient.cpp b/src/NimBLEClient.cpp index 02773c44..543787b8 100644 --- a/src/NimBLEClient.cpp +++ b/src/NimBLEClient.cpp @@ -940,6 +940,11 @@ int NimBLEClient::handleGapEvent(struct ble_gap_event* event, void* arg) { pClient = NimBLEDevice::getClientByPeerAddress(event->disconnect.conn.peer_id_addr); } + // try by connection handle + if (pClient == nullptr) { + pClient = NimBLEDevice::getClientByHandle(event->disconnect.conn.conn_handle); + } + if (pClient == nullptr) { NIMBLE_LOGE(LOG_TAG, "Disconnected client not found, conn_handle=%d", event->disconnect.conn.conn_handle);