From 9caccbd14c8f5b59976308ec76b2879182d1f126 Mon Sep 17 00:00:00 2001 From: Florian Date: Fri, 11 Aug 2023 21:12:46 -0500 Subject: [PATCH] [OTA] Stop the BLE scan when doing OTA (#1731) Rather than waiting for its end. This will improve the success rate of OTA especially when the scan duration is high --- main/ZgatewayBT.ino | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/main/ZgatewayBT.ino b/main/ZgatewayBT.ino index 104d019..0841ffe 100644 --- a/main/ZgatewayBT.ino +++ b/main/ZgatewayBT.ino @@ -850,7 +850,11 @@ void BLEconnect() { void stopProcessing() { ProcessLock = true; - delay(BTConfig.scanDuration < 2000 ? BTConfig.scanDuration : 2000); + // We stop the scan + BLEScan* pBLEScan = BLEDevice::getScan(); + if (pBLEScan->isScanning()) { + pBLEScan->stop(); + } //Suspending, deleting tasks and stopping BT to free memory vTaskSuspend(xCoreTaskHandle); vTaskDelete(xCoreTaskHandle);