From 20349d9e8b5f1d9645be9fd070ca6f10c1c076f2 Mon Sep 17 00:00:00 2001 From: h2zero Date: Mon, 2 Jun 2025 15:59:22 -0600 Subject: [PATCH] Fix server client read/write not returning when encryption is used. When the client created by the server reads or writes to an attribute and it triggers a pairing action the task will not be released because the client does not get the event. This passes the event to the client to prevent the task from being hung. --- src/NimBLEServer.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/NimBLEServer.cpp b/src/NimBLEServer.cpp index 15cf83a..42eb930 100644 --- a/src/NimBLEServer.cpp +++ b/src/NimBLEServer.cpp @@ -530,6 +530,11 @@ int NimBLEServer::handleGapEvent(ble_gap_event* event, void* arg) { } pServer->m_pServerCallbacks->onAuthenticationComplete(peerInfo); +# if CONFIG_BT_NIMBLE_ROLE_CENTRAL + if (pServer->m_pClient && pServer->m_pClient->m_connHandle == event->enc_change.conn_handle) { + NimBLEClient::handleGapEvent(event, pServer->m_pClient); + } +# endif break; } // BLE_GAP_EVENT_ENC_CHANGE