handle OTA aborted cases
This commit is contained in:
@@ -13,6 +13,8 @@ enum class RestartReason
|
|||||||
ConfigurationUpdated,
|
ConfigurationUpdated,
|
||||||
RestartTimer,
|
RestartTimer,
|
||||||
OTATimeout,
|
OTATimeout,
|
||||||
|
OTAAborted,
|
||||||
|
OTAUnknownState,
|
||||||
DeviceUnpaired,
|
DeviceUnpaired,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1042,23 +1042,41 @@ void WebCfgServer::handleOtaUpload()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (upload.status == UPLOAD_FILE_START) {
|
if (upload.status == UPLOAD_FILE_START)
|
||||||
|
{
|
||||||
String filename = upload.filename;
|
String filename = upload.filename;
|
||||||
if (!filename.startsWith("/")) {
|
if (!filename.startsWith("/"))
|
||||||
|
{
|
||||||
filename = "/" + filename;
|
filename = "/" + filename;
|
||||||
}
|
}
|
||||||
_otaStartTs = millis();
|
_otaStartTs = millis();
|
||||||
esp_task_wdt_init(30, false);
|
esp_task_wdt_init(30, false);
|
||||||
_network->disableAutoRestarts();
|
_network->disableAutoRestarts();
|
||||||
Log->print("handleFileUpload Name: "); Log->println(filename);
|
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;
|
_transferredSize = _transferredSize + upload.currentSize;
|
||||||
Log->println(_transferredSize);
|
Log->println(_transferredSize);
|
||||||
_ota.updateFirmware(upload.buf, upload.currentSize);
|
_ota.updateFirmware(upload.buf, upload.currentSize);
|
||||||
} else if (upload.status == UPLOAD_FILE_END) {
|
} else if (upload.status == UPLOAD_FILE_END)
|
||||||
|
{
|
||||||
Log->println();
|
Log->println();
|
||||||
Log->print("handleFileUpload Size: "); Log->println(upload.totalSize);
|
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()
|
void WebCfgServer::sendCss()
|
||||||
|
|||||||
Reference in New Issue
Block a user