[BT] BLE Scan watchdog relying on scan count rather than msgs processed (#1622)
* [BT] BLE Scan watchdog relying on scan count rather than msgs processed * Condition the scan increment following the scan result
This commit is contained in:
1 parent
4b8dfbea42
commit
79615516ef
2 files changed
+13
-11
No files matched your search
+12
-11
@@ -101,20 +101,20 @@ void BTConfig_init() {
|
||||
BTConfig.presenceAwayTimer = PresenceAwayTimer;
|
||||
}
|
||||
|
||||
// Watchdog, if there was no change of btQueueLengthSum for 5 minutes, restart ESP
|
||||
// Watchdog, if there was no change of BLE scanCount, restart ESP
|
||||
void btScanWDG() {
|
||||
static unsigned long previousbtQueueLengthSum = 0;
|
||||
static unsigned long lastBtMsgTime = 0;
|
||||
static unsigned long previousBtScanCount = 0;
|
||||
static unsigned long lastBtScan = 0;
|
||||
unsigned long now = millis();
|
||||
if (!ProcessLock &&
|
||||
previousbtQueueLengthSum == btQueueLengthSum &&
|
||||
btQueueLengthSum != 0 &&
|
||||
(now - lastBtMsgTime > BTConfig.BLEinterval)) {
|
||||
Log.error(F("BLE Scan watchdog triggered at : %ds" CR), lastBtMsgTime / 1000);
|
||||
ESPRestart();
|
||||
previousBtScanCount == scanCount &&
|
||||
scanCount != 0 &&
|
||||
(now - lastBtScan > BTConfig.BLEinterval)) {
|
||||
Log.error(F("BLE Scan watchdog triggered at : %ds" CR), lastBtScan / 1000);
|
||||
watchdogReboot(4);
|
||||
} else {
|
||||
previousbtQueueLengthSum = btQueueLengthSum;
|
||||
lastBtMsgTime = now;
|
||||
previousBtScanCount = scanCount;
|
||||
lastBtScan = now;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -744,7 +744,8 @@ void BLEscan() {
|
||||
pBLEScan->setInterval(BLEScanInterval);
|
||||
pBLEScan->setWindow(BLEScanWindow);
|
||||
BLEScanResults foundDevices = pBLEScan->start(BTConfig.scanDuration / 1000, false);
|
||||
scanCount++;
|
||||
if (foundDevices.getCount())
|
||||
scanCount++;
|
||||
Log.notice(F("Found %d devices, scan number %d end" CR), foundDevices.getCount(), scanCount);
|
||||
Log.trace(F("Process BLE stack free: %u" CR), uxTaskGetStackHighWaterMark(xProcBLETaskHandle));
|
||||
}
|
||||
|
||||
@@ -2597,6 +2597,7 @@ String toString(uint32_t input) {
|
||||
1 - Repeated MQTT Connection Failure
|
||||
2 - Repeated WiFi Connection Failure
|
||||
3 - Failed WiFiManager configuration portal
|
||||
4 - BLE Scan watchdog
|
||||
*/
|
||||
void watchdogReboot(byte reason) {
|
||||
Log.warning(F("Rebooting for reason code %d" CR), reason);
|
||||
|
||||
Reference in new issue
Block a user