mirror of
https://github.com/h2zero/esp-nimble-cpp.git
synced 2024-11-22 05:00:55 +01:00
Workaround for bug in NimBLE stack when connect re-attempt enabled.
Connect reattempt does not pass the arg parameter correctly and the disconnect event will have no client pointer in the argument. This finds the client from the connection handle to compensate.
This commit is contained in:
parent
a59e8ee9e1
commit
7bd7b1dfc2
1 changed files with 6 additions and 5 deletions
|
@ -909,6 +909,12 @@ int NimBLEClient::handleGapEvent(struct ble_gap_event* event, void* arg) {
|
||||||
|
|
||||||
switch (event->type) {
|
switch (event->type) {
|
||||||
case BLE_GAP_EVENT_DISCONNECT: {
|
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;
|
rc = event->disconnect.reason;
|
||||||
// If Host reset tell the device now before returning to prevent
|
// If Host reset tell the device now before returning to prevent
|
||||||
// any errors caused by calling host functions before resyncing.
|
// any errors caused by calling host functions before resyncing.
|
||||||
|
@ -921,11 +927,6 @@ int NimBLEClient::handleGapEvent(struct ble_gap_event* event, void* arg) {
|
||||||
NimBLEDevice::onReset(rc);
|
NimBLEDevice::onReset(rc);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// Check that the event is for this client.
|
|
||||||
if (pClient->m_connHandle != event->disconnect.conn.conn_handle) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue