restart ESP when OTA doesn't complete

This commit is contained in:
technyon
2022-07-21 20:23:56 +02:00
parent f580c92f17
commit 492690ecf1
2 changed files with 13 additions and 4 deletions

View File

@@ -381,6 +381,13 @@ bool WebCfgServer::processArgs(String& message)
void WebCfgServer::update()
{
if(_otaStartTs > 0 && (millis() - _otaStartTs) > 120000)
{
Serial.println(F("OTA time out, restarting"));
delay(200);
ESP.restart();
}
if(!_enabled) return;
_server.handleClient();
@@ -783,7 +790,8 @@ void WebCfgServer::waitAndProcess(const bool blocking, const uint32_t duration)
void WebCfgServer::handleOtaUpload()
{
if (_server.uri() != "/uploadota") {
if (_server.uri() != "/uploadota")
{
return;
}
if(millis() < 60000)
@@ -791,9 +799,6 @@ void WebCfgServer::handleOtaUpload()
return;
}
esp_task_wdt_init(30, false);
_network->disableAutoRestarts();
HTTPUpload& upload = _server.upload();
if(upload.filename == "")
@@ -807,6 +812,9 @@ void WebCfgServer::handleOtaUpload()
if (!filename.startsWith("/")) {
filename = "/" + filename;
}
_otaStartTs = millis();
esp_task_wdt_init(30, false);
_network->disableAutoRestarts();
Serial.print("handleFileUpload Name: "); Serial.println(filename);
} else if (upload.status == UPLOAD_FILE_WRITE) {
_transferredSize = _transferredSize + upload.currentSize;