restart ESP when OTA doesn't complete
This commit is contained in:
@@ -381,6 +381,13 @@ bool WebCfgServer::processArgs(String& message)
|
|||||||
|
|
||||||
void WebCfgServer::update()
|
void WebCfgServer::update()
|
||||||
{
|
{
|
||||||
|
if(_otaStartTs > 0 && (millis() - _otaStartTs) > 120000)
|
||||||
|
{
|
||||||
|
Serial.println(F("OTA time out, restarting"));
|
||||||
|
delay(200);
|
||||||
|
ESP.restart();
|
||||||
|
}
|
||||||
|
|
||||||
if(!_enabled) return;
|
if(!_enabled) return;
|
||||||
|
|
||||||
_server.handleClient();
|
_server.handleClient();
|
||||||
@@ -783,7 +790,8 @@ void WebCfgServer::waitAndProcess(const bool blocking, const uint32_t duration)
|
|||||||
|
|
||||||
void WebCfgServer::handleOtaUpload()
|
void WebCfgServer::handleOtaUpload()
|
||||||
{
|
{
|
||||||
if (_server.uri() != "/uploadota") {
|
if (_server.uri() != "/uploadota")
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(millis() < 60000)
|
if(millis() < 60000)
|
||||||
@@ -791,9 +799,6 @@ void WebCfgServer::handleOtaUpload()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
esp_task_wdt_init(30, false);
|
|
||||||
_network->disableAutoRestarts();
|
|
||||||
|
|
||||||
HTTPUpload& upload = _server.upload();
|
HTTPUpload& upload = _server.upload();
|
||||||
|
|
||||||
if(upload.filename == "")
|
if(upload.filename == "")
|
||||||
@@ -807,6 +812,9 @@ void WebCfgServer::handleOtaUpload()
|
|||||||
if (!filename.startsWith("/")) {
|
if (!filename.startsWith("/")) {
|
||||||
filename = "/" + filename;
|
filename = "/" + filename;
|
||||||
}
|
}
|
||||||
|
_otaStartTs = millis();
|
||||||
|
esp_task_wdt_init(30, false);
|
||||||
|
_network->disableAutoRestarts();
|
||||||
Serial.print("handleFileUpload Name: "); Serial.println(filename);
|
Serial.print("handleFileUpload Name: "); Serial.println(filename);
|
||||||
} else if (upload.status == UPLOAD_FILE_WRITE) {
|
} else if (upload.status == UPLOAD_FILE_WRITE) {
|
||||||
_transferredSize = _transferredSize + upload.currentSize;
|
_transferredSize = _transferredSize + upload.currentSize;
|
||||||
|
|||||||
@@ -74,6 +74,7 @@ private:
|
|||||||
char _credPassword[31] = {0};
|
char _credPassword[31] = {0};
|
||||||
bool _allowRestartToPortal = false;
|
bool _allowRestartToPortal = false;
|
||||||
uint32_t _transferredSize = 0;
|
uint32_t _transferredSize = 0;
|
||||||
|
unsigned long _otaStartTs = 0;
|
||||||
String _hostname;
|
String _hostname;
|
||||||
|
|
||||||
String _confirmCode = "----";
|
String _confirmCode = "----";
|
||||||
|
|||||||
Reference in New Issue
Block a user