diff --git a/main/ZgatewayBT.ino b/main/ZgatewayBT.ino index b2cec7ae7b..f0131a62b6 100644 --- a/main/ZgatewayBT.ino +++ b/main/ZgatewayBT.ino @@ -90,6 +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); @@ -586,6 +589,7 @@ void stopProcessing() { void startProcessing() { Log.notice(F("Start BLE processing" CR)); ProcessLock = false; + vTaskResume(xCoreTaskHandle); } void coreTask(void* pvParameters) { @@ -615,6 +619,7 @@ void coreTask(void* pvParameters) { } } else { Log.trace(F("BLE core task canceled by processLock" CR)); + vTaskSuspend(xCoreTaskHandle); } } } @@ -678,7 +683,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)); }