Skip to content

Commit 2056a46

Browse files
committed
Use address in event to find the client instance.
1 parent ee7c53f commit 2056a46

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/NimBLEClient.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -933,16 +933,16 @@ int NimBLEClient::handleGapEvent(struct ble_gap_event* event, void* arg) {
933933

934934
switch (event->type) {
935935
case BLE_GAP_EVENT_DISCONNECT: {
936-
NimBLEConnInfo peerInfo;
937-
rc = ble_gap_conn_find(event->disconnect.conn.conn_handle, &peerInfo.m_desc);
938-
if (rc != 0) {
939-
NIMBLE_LOGE(LOG_TAG, "Failed to find connection info; rc=%d", rc);
940-
return 0;
941-
}
942936

943937
// workaround for bug in NimBLE stack where disconnect event argument is not passed correctly
944-
pClient = NimBLEDevice::getClientByPeerAddress(peerInfo.m_desc.peer_id_addr);
938+
pClient = NimBLEDevice::getClientByPeerAddress(event->disconnect.conn.peer_ota_addr);
939+
if (pClient == nullptr) {
940+
pClient = NimBLEDevice::getClientByPeerAddress(event->disconnect.conn.peer_id_addr);
941+
}
942+
945943
if (pClient == nullptr) {
944+
NIMBLE_LOGE(LOG_TAG, "Disconnected client not found, conn_handle=%d",
945+
event->disconnect.conn.conn_handle);
946946
return 0;
947947
}
948948

0 commit comments

Comments
 (0)