diff --git a/src/NimBLEClient.cpp b/src/NimBLEClient.cpp index 8d22e69..909167b 100644 --- a/src/NimBLEClient.cpp +++ b/src/NimBLEClient.cpp @@ -221,7 +221,6 @@ bool NimBLEClient::connect(const NimBLEAddress &address, bool deleteAttibutes) { if (!NimBLEDevice::getScan()->stop()) { return false; } - vTaskDelay(1 / portTICK_PERIOD_MS); break; case BLE_HS_EDONE: @@ -1028,7 +1027,9 @@ uint16_t NimBLEClient::getMTU() { if(client->m_pTaskData != nullptr) { client->m_pTaskData->rc = rc; - xTaskNotifyGive(client->m_pTaskData->task); + if(client->m_pTaskData->task) { + xTaskNotifyGive(client->m_pTaskData->task); + } client->m_pTaskData = nullptr; } diff --git a/src/NimBLEDevice.cpp b/src/NimBLEDevice.cpp index 833104c..4ea8020 100644 --- a/src/NimBLEDevice.cpp +++ b/src/NimBLEDevice.cpp @@ -174,7 +174,7 @@ void NimBLEDevice::stopAdvertising() { } while(pClient->isConnected()) { - vTaskDelay(10 / portTICK_PERIOD_MS); + taskYIELD(); } } else if(pClient->m_pTaskData != nullptr) { rc = ble_gap_conn_cancel(); @@ -182,7 +182,7 @@ void NimBLEDevice::stopAdvertising() { return false; } while(pClient->m_pTaskData != nullptr) { - vTaskDelay(10 / portTICK_PERIOD_MS); + taskYIELD(); } }