mirror of
https://github.com/rstrouse/ESPSomfy-RTS.git
synced 2026-10-31 22:02:17 +01:00
fix: only touch the task watchdog from tasks that are subscribed to it
Only loop() is subscribed. setConnected() runs on the WiFi event task and reached SocketEmitter::endEmit(), whose plain esp_task_wdt_reset() logged "esp_task_wdt_reset(707): task not found" on every boot. The web and socket handlers on async_tcp did the same. /scanaps on async_tcp called esp_task_wdt_add(NULL) after the scan, subscribing a task that nothing resets, so the board could panic 15 s after a scan from the UI. TaskWdt.h resets only a subscribed task and re-adds a task after a long call only when it was watched before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
e9109c56e0
commit
609cd455c6
10 changed files with 154 additions and 57 deletions
34
test/stubs/esp_task_wdt.h
Normal file
34
test/stubs/esp_task_wdt.h
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
#pragma once
|
||||
// Stands in for ESP-IDF's task watchdog for one calling task. Tests set
|
||||
// whether it is subscribed and count the resets.
|
||||
typedef int esp_err_t;
|
||||
#ifndef ESP_OK
|
||||
#define ESP_OK 0
|
||||
#endif
|
||||
#ifndef ESP_ERR_NOT_FOUND
|
||||
#define ESP_ERR_NOT_FOUND 0x105
|
||||
#endif
|
||||
|
||||
struct FakeTaskWdt {
|
||||
bool subscribed = false;
|
||||
int resets = 0;
|
||||
int adds = 0;
|
||||
};
|
||||
inline FakeTaskWdt fakeTaskWdt;
|
||||
|
||||
inline esp_err_t esp_task_wdt_status(void *) { return fakeTaskWdt.subscribed ? ESP_OK : ESP_ERR_NOT_FOUND; }
|
||||
inline esp_err_t esp_task_wdt_reset() {
|
||||
if(!fakeTaskWdt.subscribed) return ESP_ERR_NOT_FOUND;
|
||||
fakeTaskWdt.resets++;
|
||||
return ESP_OK;
|
||||
}
|
||||
inline esp_err_t esp_task_wdt_delete(void *) {
|
||||
if(!fakeTaskWdt.subscribed) return ESP_ERR_NOT_FOUND;
|
||||
fakeTaskWdt.subscribed = false;
|
||||
return ESP_OK;
|
||||
}
|
||||
inline esp_err_t esp_task_wdt_add(void *) {
|
||||
fakeTaskWdt.adds++;
|
||||
fakeTaskWdt.subscribed = true;
|
||||
return ESP_OK;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue