Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/NimBLEClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -909,6 +909,12 @@ int NimBLEClient::handleGapEvent(struct ble_gap_event* event, void* arg) {

switch (event->type) {
case BLE_GAP_EVENT_DISCONNECT: {
// workaround for bug in NimBLE stack where disconnect event argument is not passed correctly
pClient = NimBLEDevice::getClientByHandle(event->disconnect.conn.conn_handle);
if (pClient == nullptr) {
return 0;
}

rc = event->disconnect.reason;
// If Host reset tell the device now before returning to prevent
// any errors caused by calling host functions before resyncing.
Expand All @@ -921,11 +927,6 @@ int NimBLEClient::handleGapEvent(struct ble_gap_event* event, void* arg) {
NimBLEDevice::onReset(rc);
break;
default:
// Check that the event is for this client.
if (pClient->m_connHandle != event->disconnect.conn.conn_handle) {
return 0;
}

break;
}

Expand Down