Correct client connection status signalling.

* NimBLEClient::disconnect() was setting the connected flag to false before the disconnection occured.

* NimBLEDevice::deleteClient() was not waiting for disconnection if it was already in progress.

* Client gap event handler was releasing the connection event semaphore when it should not.
This commit is contained in:
h2zero
2020-05-30 09:01:42 -06:00
parent 143631d327
commit 44f16e6ee2
2 changed files with 12 additions and 9 deletions
+9 -4
View File
@@ -152,21 +152,26 @@ void NimBLEDevice::stopAdvertising() {
return false;
}
int rc =0;
if(pClient->m_isConnected) {
if (pClient->disconnect() != 0) {
rc = pClient->disconnect();
if (rc != 0 && rc != BLE_HS_EALREADY && rc != BLE_HS_ENOTCONN) {
return false;
}
while(pClient->m_isConnected) {
vTaskDelay(1);
vTaskDelay(10);
}
}
if(pClient->m_waitingToConnect) {
if(ble_gap_conn_cancel() != 0){
rc = ble_gap_conn_cancel();
if (rc != 0 && rc != BLE_HS_EALREADY) {
return false;
}
while(pClient->m_waitingToConnect) {
vTaskDelay(1);
vTaskDelay(10);
}
}