handle OTA aborted cases

This commit is contained in:
technyon
2023-02-11 10:28:11 +01:00
parent 1181c821a7
commit b91908343d
2 changed files with 24 additions and 4 deletions

View File

@@ -1042,23 +1042,41 @@ void WebCfgServer::handleOtaUpload()
return;
}
if (upload.status == UPLOAD_FILE_START) {
if (upload.status == UPLOAD_FILE_START)
{
String filename = upload.filename;
if (!filename.startsWith("/")) {
if (!filename.startsWith("/"))
{
filename = "/" + filename;
}
_otaStartTs = millis();
esp_task_wdt_init(30, false);
_network->disableAutoRestarts();
Log->print("handleFileUpload Name: "); Log->println(filename);
} else if (upload.status == UPLOAD_FILE_WRITE) {
}
else if (upload.status == UPLOAD_FILE_WRITE)
{
_transferredSize = _transferredSize + upload.currentSize;
Log->println(_transferredSize);
_ota.updateFirmware(upload.buf, upload.currentSize);
} else if (upload.status == UPLOAD_FILE_END) {
} else if (upload.status == UPLOAD_FILE_END)
{
Log->println();
Log->print("handleFileUpload Size: "); Log->println(upload.totalSize);
}
else if(upload.status == UPLOAD_FILE_ABORTED)
{
Log->println();
Log->println("OTA aborted, restarting ESP.");
restartEsp(RestartReason::OTAAborted);
}
else
{
Log->println();
Log->print("OTA unknown state: ");
Log->println((int)upload.status);
restartEsp(RestartReason::OTAUnknownState);
}
}
void WebCfgServer::sendCss()