diff --git a/src/main.cpp b/src/main.cpp index fadb897..17ea471 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -29,7 +29,7 @@ void setup() initBLE(); initWiFi(); - delay(1000); + delay(500); Serial.println("Connection Type: " + String(config.getUChar("connection_type"))); if( (config.getUChar("connection_type") == CONNECTION_TYPE_TUNERSTUDIO) ) @@ -67,9 +67,10 @@ void setup() //Updates the firmware AND data from remote URLs server.on(UPDATE_REMOTE_URL, HTTP_POST, [](AsyncWebServerRequest *request) { + request->onDisconnect([](){ + ESP.restart(); + }); request->send(200, "text/html", saveRemoteFW_URLs(request)); - delay(1000); //Wait 1 second to allow the page to be sent before restarting - ESP.restart(); }); //Scan the wifi networks and return them as JSON server.on("/wifi", HTTP_GET, [](AsyncWebServerRequest *request) { diff --git a/src/static/static_js.cpp b/src/static/static_js.cpp index b0d59c5..d19bd8a 100644 --- a/src/static/static_js.cpp +++ b/src/static/static_js.cpp @@ -4,7 +4,7 @@ String staticJS_updates() { String js = ""; js += ""; return js; diff --git a/src/static/static_js.js b/src/static/static_js.js index f8b4d17..0a2e30d 100644 --- a/src/static/static_js.js +++ b/src/static/static_js.js @@ -96,8 +96,15 @@ function updateProgress() const percentComplete = Math.floor((jsonData.updateProgress / jsonData.updateSize) * 100) setInnerHTML(getElementByID('updatePercent'), percentComplete) console.log(percentComplete) - if(percentComplete >= 98) { window.location.href = '/' } + if(percentComplete >= 98) + { + setTimeout(() => { + const wl = window.location + wl.href = '/' + wl=wl.href //Force a refresh of page without resending POST data + }, 7000) + } else { updateProgress() } } - }, 1500); + }, 1100); } \ No newline at end of file diff --git a/src/updater.cpp b/src/updater.cpp index 200f5c8..1eeaf94 100644 --- a/src/updater.cpp +++ b/src/updater.cpp @@ -110,12 +110,12 @@ String updateInProgressPage() updatePage += "