mirror of
https://github.com/rstrouse/ESPSomfy-RTS.git
synced 2026-10-31 22:02:17 +01:00
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>
34 lines
905 B
C
34 lines
905 B
C
#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;
|
|
}
|