Remove client delay calls and check if task is valid before notifying.

This commit is contained in:
h2zero 2021-01-12 13:54:53 -07:00
parent 740f280664
commit 09ff0c3472
2 changed files with 5 additions and 4 deletions

View file

@ -221,7 +221,6 @@ bool NimBLEClient::connect(const NimBLEAddress &address, bool deleteAttibutes) {
if (!NimBLEDevice::getScan()->stop()) { if (!NimBLEDevice::getScan()->stop()) {
return false; return false;
} }
vTaskDelay(1 / portTICK_PERIOD_MS);
break; break;
case BLE_HS_EDONE: case BLE_HS_EDONE:
@ -1028,7 +1027,9 @@ uint16_t NimBLEClient::getMTU() {
if(client->m_pTaskData != nullptr) { if(client->m_pTaskData != nullptr) {
client->m_pTaskData->rc = rc; client->m_pTaskData->rc = rc;
if(client->m_pTaskData->task) {
xTaskNotifyGive(client->m_pTaskData->task); xTaskNotifyGive(client->m_pTaskData->task);
}
client->m_pTaskData = nullptr; client->m_pTaskData = nullptr;
} }

View file

@ -174,7 +174,7 @@ void NimBLEDevice::stopAdvertising() {
} }
while(pClient->isConnected()) { while(pClient->isConnected()) {
vTaskDelay(10 / portTICK_PERIOD_MS); taskYIELD();
} }
} else if(pClient->m_pTaskData != nullptr) { } else if(pClient->m_pTaskData != nullptr) {
rc = ble_gap_conn_cancel(); rc = ble_gap_conn_cancel();
@ -182,7 +182,7 @@ void NimBLEDevice::stopAdvertising() {
return false; return false;
} }
while(pClient->m_pTaskData != nullptr) { while(pClient->m_pTaskData != nullptr) {
vTaskDelay(10 / portTICK_PERIOD_MS); taskYIELD();
} }
} }