From dde7a1c19d86bed58b79c259608b4c9b353193c8 Mon Sep 17 00:00:00 2001 From: sindney <346567691@qq.com> Date: Mon, 6 Apr 2020 20:46:11 +0800 Subject: [PATCH] Fix BLEClient disconnect bug By default the disconnect is broadcasted to every clients. So if you call disconnect on one connected client, they'll all be disconnected if we don't filter the event by conn_id. --- libraries/BLE/src/BLEClient.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libraries/BLE/src/BLEClient.cpp b/libraries/BLE/src/BLEClient.cpp index 436813f859d..e13b8d62008 100644 --- a/libraries/BLE/src/BLEClient.cpp +++ b/libraries/BLE/src/BLEClient.cpp @@ -178,6 +178,8 @@ void BLEClient::gattClientEventHandler( // - uint16_t conn_id // - esp_bd_addr_t remote_bda case ESP_GATTC_DISCONNECT_EVT: { + if (evtParam->disconnect.conn_id != m_conn_id) + break; // If we receive a disconnect event, set the class flag that indicates that we are // no longer connected. m_isConnected = false;