ui changes for OTA

This commit is contained in:
technyon
2022-06-15 20:10:23 +02:00
parent d64975c5ef
commit 1e5cdd8267
3 changed files with 22 additions and 11 deletions

View File

@@ -1,3 +1,3 @@
#pragma once #pragma once
#define nuki_hub_version "3.2" #define nuki_hub_version "3.3"

View File

@@ -125,11 +125,12 @@ void WebCfgServer::initialize()
return _server.requestAuthentication(); return _server.requestAuthentication();
} }
String response = ""; _server.send(200, "text/html", "");
buildConfirmHtml(response, "Initiating Over-the-air Update. This will take a moment, please be patient.", 35);
_server.send(200, "text/html", response);
}, [&]() { }, [&]() {
if (_hasCredentials && !_server.authenticate(_credUser, _credPassword)) {
return _server.requestAuthentication();
}
handleOtaUpload(); handleOtaUpload();
}); });
@@ -371,7 +372,7 @@ void WebCfgServer::buildHtml(String& response)
response.concat("<button type=\"submit\">Edit</button>"); response.concat("<button type=\"submit\">Edit</button>");
response.concat("</form>"); response.concat("</form>");
response.concat("<BR><BR><h3>OTA</h3>"); response.concat("<BR><BR><h3>Firmware update</h3>");
response.concat("<form method=\"get\" action=\"/ota\">"); response.concat("<form method=\"get\" action=\"/ota\">");
response.concat("<button type=\"submit\">Open</button>"); response.concat("<button type=\"submit\">Open</button>");
response.concat("</form>"); response.concat("</form>");
@@ -453,11 +454,20 @@ void WebCfgServer::buildCredHtml(String &response)
void WebCfgServer::buildOtaHtml(String &response) void WebCfgServer::buildOtaHtml(String &response)
{ {
buildHtmlHeader(response); buildHtmlHeader(response);
response.concat("<form id=\"upform\" enctype=\"multipart/form-data\" action=\"/uploadota\" method=\"POST\"><input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"100000\" />Choose a file to upload: <input name=\"uploadedfile\" type=\"file\" accept=\".bin\" /><br/>");
response.concat("<form enctype=\"multipart/form-data\" action=\"/uploadota\" method=\"POST\">"); response.concat("<br><input id=\"submitbtn\" type=\"submit\" value=\"Upload File\" /></form>");
response.concat("<input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"100000\" />"); response.concat("<div id=\"msgdiv\" style=\"visibility:hidden\">Initiating Over-the-air update. This will take about a minute, please be patient.<br>You will be forwarwed automatically when the update is complete.</div>");
response.concat("Choose a file to upload: <input name=\"uploadedfile\" type=\"file\" accept=\".bin\" /><br />"); response.concat("<script type=\"text/javascript\">");
response.concat("<input type=\"submit\" value=\"Upload File\" /></form>"); response.concat("window.addEventListener('load', function () {");
response.concat(" var button = document.getElementById(\"submitbtn\");");
response.concat(" button.addEventListener('click',hideshow,false);");
response.concat(" function hideshow() {");
response.concat(" document.getElementById('upform').style.visibility = 'hidden';");
response.concat(" document.getElementById('msgdiv').style.visibility = 'visible';");
response.concat(" setTimeout(\"location.href = '/';\",60000);");
response.concat(" }");
response.concat("});");
response.concat("</script>");
response.concat("</BODY>\n</HTML>\n"); response.concat("</BODY>\n</HTML>\n");
} }

View File

@@ -62,6 +62,7 @@ private:
char _credPassword[20] = {0}; char _credPassword[20] = {0};
bool _allowRestartToPortal = false; bool _allowRestartToPortal = false;
uint32_t _transferredSize = 0; uint32_t _transferredSize = 0;
bool _otaStart = true;
String _confirmCode = "----"; String _confirmCode = "----";