Watchdog: disable watchdog while OTA is running
This commit is contained in:
parent
213e3e998a
commit
26fa38d052
@ -287,6 +287,35 @@ void WLED::loop()
|
||||
#endif
|
||||
}
|
||||
|
||||
void WLED::enableWatchdog() {
|
||||
#if WLED_WATCHDOG_TIMEOUT > 0
|
||||
#ifdef ARDUINO_ARCH_ESP32
|
||||
esp_err_t watchdog = esp_task_wdt_init(WLED_WATCHDOG_TIMEOUT, true);
|
||||
DEBUG_PRINT(F("Watchdog enabled: "));
|
||||
if (watchdog == ESP_OK) {
|
||||
DEBUG_PRINTLN(F("OK"));
|
||||
} else {
|
||||
DEBUG_PRINTLN(watchdog);
|
||||
return;
|
||||
}
|
||||
esp_task_wdt_add(NULL);
|
||||
#else
|
||||
ESP.wdtEnable(WLED_WATCHDOG_TIMEOUT * 1000);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void WLED::disableWatchdog() {
|
||||
#if WLED_WATCHDOG_TIMEOUT > 0
|
||||
DEBUG_PRINTLN(F("Watchdog: disabled"));
|
||||
#ifdef ARDUINO_ARCH_ESP32
|
||||
esp_task_wdt_delete(NULL);
|
||||
#else
|
||||
ESP.wdtDisable();
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void WLED::setup()
|
||||
{
|
||||
#if defined(ARDUINO_ARCH_ESP32) && defined(WLED_DISABLE_BROWNOUT_DET)
|
||||
@ -311,21 +340,7 @@ void WLED::setup()
|
||||
DEBUG_PRINT(F("heap "));
|
||||
DEBUG_PRINTLN(ESP.getFreeHeap());
|
||||
|
||||
#if WLED_WATCHDOG_TIMEOUT > 0
|
||||
#ifdef ARDUINO_ARCH_ESP32
|
||||
esp_err_t watchdog = esp_task_wdt_init(WLED_WATCHDOG_TIMEOUT, true);
|
||||
DEBUG_PRINT(F("Enable watchdog "));
|
||||
if (watchdog == ESP_OK) {
|
||||
DEBUG_PRINTLN(F(" OK"));
|
||||
} else {
|
||||
DEBUG_PRINTLN(watchdog);
|
||||
}
|
||||
esp_task_wdt_add(NULL);
|
||||
#else
|
||||
// any timeout possible ?
|
||||
ESP.wdtEnable(WLED_WATCHDOG_TIMEOUT * 1000);
|
||||
#endif
|
||||
#endif
|
||||
enableWatchdog();
|
||||
|
||||
#if defined(ARDUINO_ARCH_ESP32) && defined(WLED_USE_PSRAM)
|
||||
if (psramFound()) {
|
||||
@ -426,8 +441,13 @@ void WLED::setup()
|
||||
#ifdef ESP8266
|
||||
wifi_set_sleep_type(NONE_SLEEP_T);
|
||||
#endif
|
||||
WLED::instance().disableWatchdog();
|
||||
DEBUG_PRINTLN(F("Start ArduinoOTA"));
|
||||
});
|
||||
ArduinoOTA.onError([](ota_error_t error) {
|
||||
// reenable watchdog on failed update
|
||||
WLED::instance().enableWatchdog();
|
||||
});
|
||||
if (strlen(cmDNS) > 0)
|
||||
ArduinoOTA.setHostname(cmDNS);
|
||||
}
|
||||
|
@ -703,5 +703,7 @@ public:
|
||||
void initConnection();
|
||||
void initInterfaces();
|
||||
void handleStatusLED();
|
||||
void enableWatchdog();
|
||||
void disableWatchdog();
|
||||
};
|
||||
#endif // WLED_H
|
||||
|
@ -203,6 +203,7 @@ void initServer()
|
||||
},[](AsyncWebServerRequest *request, String filename, size_t index, uint8_t *data, size_t len, bool final){
|
||||
if(!index){
|
||||
DEBUG_PRINTLN(F("OTA Update Start"));
|
||||
WLED::instance().disableWatchdog();
|
||||
#ifdef ESP8266
|
||||
Update.runAsync(true);
|
||||
#endif
|
||||
@ -214,6 +215,7 @@ void initServer()
|
||||
DEBUG_PRINTLN(F("Update Success"));
|
||||
} else {
|
||||
DEBUG_PRINTLN(F("Update Failed"));
|
||||
WLED::instance().enableWatchdog();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user