From 09ff0c347251800136ef1b3c1af8577921e023a2 Mon Sep 17 00:00:00 2001 From: h2zero Date: Tue, 12 Jan 2021 13:54:53 -0700 Subject: [PATCH] Remove client delay calls and check if task is valid before notifying. --- src/NimBLEClient.cpp | 5 +++-- src/NimBLEDevice.cpp | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) 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(); } }