Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BT] Restarting the tasks is not enough in case of BLE stack stuck #1725

Merged
merged 1 commit into from
Aug 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 2 additions & 14 deletions main/ZgatewayBT.ino
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ struct decompose {
bool reverse;
};

unsigned long BLEstarts = 0;

vector<BLEAction> BLEactions;

vector<BLEdevice*> devices;
Expand Down Expand Up @@ -107,7 +105,7 @@ void BTConfig_init() {
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() {
static unsigned long previousBtScanCount = 0;
static unsigned long lastBtScan = 0;
Expand All @@ -117,8 +115,7 @@ void btScanWDG() {
scanCount != 0 &&
(now - lastBtScan > BTConfig.BLEinterval)) {
Log.error(F("BLE Scan watchdog triggered at : %ds" CR), lastBtScan / 1000);
stopProcessing();
startProcessing();
ESPRestart(4);
} else {
previousBtScanCount = scanCount;
lastBtScan = now;
Expand Down Expand Up @@ -157,7 +154,6 @@ String stateBTMeasures(bool start) {
jo["btqavg"] = (btQueueLengthCount > 0 ? btQueueLengthSum / (float)btQueueLengthCount : 0);
jo["bletaskstack"] = uxTaskGetStackHighWaterMark(xProcBLETaskHandle);
jo["blecoretaskstack"] = uxTaskGetStackHighWaterMark(xCoreTaskHandle);
jo["blestarts"] = BLEstarts;

if (start) {
Log.notice(F("BT sys: "));
Expand Down Expand Up @@ -870,12 +866,6 @@ void stopProcessing() {
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) {
while (true) {
if (!ProcessLock) {
Expand Down Expand Up @@ -993,8 +983,6 @@ void setupBTTasksAndBLE() {
1, /* Priority of the task */
&xCoreTaskHandle, /* Task handle. */
taskCore); /* Core where the task should run */

BLEstarts++;
}

void setupBT() {
Expand Down
1 change: 0 additions & 1 deletion main/config_BT.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ extern void MQTTtoBT(char* topicOri, JsonObject& RFdata);
extern void emptyBTQueue();
extern void launchBTDiscovery(bool overrideDiscovery);
extern void stopProcessing();
extern void startProcessing();
extern void lowPowerESP32();
extern String stateBTMeasures(bool);

Expand Down
Loading