From a7aaf598d68fac481749ad062925f062fd29b904 Mon Sep 17 00:00:00 2001 From: mtiutiu Date: Fri, 6 Nov 2020 19:16:51 +0200 Subject: [PATCH 1/2] make sure that coreTask gets supended when not needed --- main/ZgatewayBT.ino | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/main/ZgatewayBT.ino b/main/ZgatewayBT.ino index b2cec7ae7b..6dbd11d02f 100644 --- a/main/ZgatewayBT.ino +++ b/main/ZgatewayBT.ino @@ -90,6 +90,7 @@ int minRssi = abs(MinimumRSSI); //minimum rssi value unsigned int scanCount = 0; +static TaskHandle_t xCoreTaskHandle; bool ProcessLock = false; // Process lock when we want to use a critical function like OTA for example BLEdevice* getDeviceByMac(const char* mac); @@ -586,6 +587,7 @@ void stopProcessing() { void startProcessing() { Log.notice(F("Start BLE processing" CR)); ProcessLock = false; + vTaskResume(xCoreTaskHandle); } void coreTask(void* pvParameters) { @@ -615,6 +617,7 @@ void coreTask(void* pvParameters) { } } else { Log.trace(F("BLE core task canceled by processLock" CR)); + vTaskSuspend(xCoreTaskHandle); } } } @@ -678,7 +681,7 @@ void setupBT() { 10000, /* Stack size in words */ NULL, /* Task input parameter */ 1, /* Priority of the task */ - NULL, /* Task handle. */ + &xCoreTaskHandle, /* Task handle. */ taskCore); /* Core where the task should run */ Log.trace(F("ZgatewayBT multicore ESP32 setup done " CR)); } From 858277d9ba8b45cee96fe126afd40dcbe5b97fab Mon Sep 17 00:00:00 2001 From: mtiutiu Date: Fri, 6 Nov 2020 21:21:51 +0200 Subject: [PATCH 2/2] arch dependend code fix --- main/ZgatewayBT.ino | 2 ++ 1 file changed, 2 insertions(+) diff --git a/main/ZgatewayBT.ino b/main/ZgatewayBT.ino index 6dbd11d02f..f0131a62b6 100644 --- a/main/ZgatewayBT.ino +++ b/main/ZgatewayBT.ino @@ -90,7 +90,9 @@ int minRssi = abs(MinimumRSSI); //minimum rssi value unsigned int scanCount = 0; +# ifdef ESP32 static TaskHandle_t xCoreTaskHandle; +# endif bool ProcessLock = false; // Process lock when we want to use a critical function like OTA for example BLEdevice* getDeviceByMac(const char* mac);