[BT] Restarting the tasks is not enough in case of BLE stack stuck (#1725)
So restart the ESP instead
This commit is contained in:
1 parent
375ce91ece
commit
fac602e457
2 files changed
+2
-15
No files matched your search
+2
-14
@@ -68,8 +68,6 @@ struct decompose {
|
|||||||
bool reverse;
|
bool reverse;
|
||||||
};
|
};
|
||||||
|
|
||||||
unsigned long BLEstarts = 0;
|
|
||||||
|
|
||||||
vector<BLEAction> BLEactions;
|
vector<BLEAction> BLEactions;
|
||||||
|
|
||||||
vector<BLEdevice*> devices;
|
vector<BLEdevice*> devices;
|
||||||
@@ -107,7 +105,7 @@ void BTConfig_init() {
|
|||||||
BTConfig.movingTimer = MovingTimer;
|
BTConfig.movingTimer = MovingTimer;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Watchdog, if there was no change of BLE scanCount, restart BT
|
// Watchdog, if there was no change of BLE scanCount, restart the ESP
|
||||||
void btScanWDG() {
|
void btScanWDG() {
|
||||||
static unsigned long previousBtScanCount = 0;
|
static unsigned long previousBtScanCount = 0;
|
||||||
static unsigned long lastBtScan = 0;
|
static unsigned long lastBtScan = 0;
|
||||||
@@ -117,8 +115,7 @@ void btScanWDG() {
|
|||||||
scanCount != 0 &&
|
scanCount != 0 &&
|
||||||
(now - lastBtScan > BTConfig.BLEinterval)) {
|
(now - lastBtScan > BTConfig.BLEinterval)) {
|
||||||
Log.error(F("BLE Scan watchdog triggered at : %ds" CR), lastBtScan / 1000);
|
Log.error(F("BLE Scan watchdog triggered at : %ds" CR), lastBtScan / 1000);
|
||||||
stopProcessing();
|
ESPRestart(4);
|
||||||
startProcessing();
|
|
||||||
} else {
|
} else {
|
||||||
previousBtScanCount = scanCount;
|
previousBtScanCount = scanCount;
|
||||||
lastBtScan = now;
|
lastBtScan = now;
|
||||||
@@ -157,7 +154,6 @@ String stateBTMeasures(bool start) {
|
|||||||
jo["btqavg"] = (btQueueLengthCount > 0 ? btQueueLengthSum / (float)btQueueLengthCount : 0);
|
jo["btqavg"] = (btQueueLengthCount > 0 ? btQueueLengthSum / (float)btQueueLengthCount : 0);
|
||||||
jo["bletaskstack"] = uxTaskGetStackHighWaterMark(xProcBLETaskHandle);
|
jo["bletaskstack"] = uxTaskGetStackHighWaterMark(xProcBLETaskHandle);
|
||||||
jo["blecoretaskstack"] = uxTaskGetStackHighWaterMark(xCoreTaskHandle);
|
jo["blecoretaskstack"] = uxTaskGetStackHighWaterMark(xCoreTaskHandle);
|
||||||
jo["blestarts"] = BLEstarts;
|
|
||||||
|
|
||||||
if (start) {
|
if (start) {
|
||||||
Log.notice(F("BT sys: "));
|
Log.notice(F("BT sys: "));
|
||||||
@@ -870,12 +866,6 @@ void stopProcessing() {
|
|||||||
Log.notice(F("BLE gateway stopped, free heap: %d" CR), ESP.getFreeHeap());
|
Log.notice(F("BLE gateway stopped, free heap: %d" CR), ESP.getFreeHeap());
|
||||||
}
|
}
|
||||||
|
|
||||||
void startProcessing() {
|
|
||||||
ProcessLock = false;
|
|
||||||
setupBTTasksAndBLE();
|
|
||||||
Log.notice(F("BLE gateway started, free heap: %d" CR), ESP.getFreeHeap());
|
|
||||||
}
|
|
||||||
|
|
||||||
void coreTask(void* pvParameters) {
|
void coreTask(void* pvParameters) {
|
||||||
while (true) {
|
while (true) {
|
||||||
if (!ProcessLock) {
|
if (!ProcessLock) {
|
||||||
@@ -993,8 +983,6 @@ void setupBTTasksAndBLE() {
|
|||||||
1, /* Priority of the task */
|
1, /* Priority of the task */
|
||||||
&xCoreTaskHandle, /* Task handle. */
|
&xCoreTaskHandle, /* Task handle. */
|
||||||
taskCore); /* Core where the task should run */
|
taskCore); /* Core where the task should run */
|
||||||
|
|
||||||
BLEstarts++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void setupBT() {
|
void setupBT() {
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ extern void MQTTtoBT(char* topicOri, JsonObject& RFdata);
|
|||||||
extern void emptyBTQueue();
|
extern void emptyBTQueue();
|
||||||
extern void launchBTDiscovery(bool overrideDiscovery);
|
extern void launchBTDiscovery(bool overrideDiscovery);
|
||||||
extern void stopProcessing();
|
extern void stopProcessing();
|
||||||
extern void startProcessing();
|
|
||||||
extern void lowPowerESP32();
|
extern void lowPowerESP32();
|
||||||
extern String stateBTMeasures(bool);
|
extern String stateBTMeasures(bool);
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user