Rolling 20220919

This commit is contained in:
jomjol
2022-09-19 22:07:16 +02:00
parent 013d5a99a8
commit 562cc4352b
2 changed files with 49 additions and 34 deletions

View File

@@ -35,36 +35,29 @@ Check at <a href="https://github.com/jomjol/AI-on-the-edge-device/releases" targ
<h2>Update</h2> <h2>Update</h2>
<table class="fixed" border="0"> <table class="fixed" border="0">
<tr> <tr>
<td> <p>
<table border="0"> <label for="newfile">Select the update file (update.zip, firmware.bin, html.zip, *.tfl/tflite):</label>
<tr> </p>
<td style="width: 230px">
<label for="newfile">Select the update file (update.zip, firmware.bin, html.zip, *.tfl/tflite):</label> </tr>
</td> <tr>
<td colspan="2"> <p>
<input id="newfile" type="file" onchange="setpath()" style="width:100%;"> <input id="newfile" type="file" onchange="setpath()" style="width:100%;">
</td> </p>
<td rowspan="2" style="padding-left:50px"> </tr>
<button class="button" id="doUpdate" type="button" onclick="doUpdate()">Flash the firmware<br>(Takes about 60s)</button> <tr>
</td> <p>
</tr> <button class="button" id="doUpdate" type="button" onclick="upload()">Do upload and update<br>(incl. reboot - if needed)</button>
<tr> </p>
<td> </tr>
<label for="filepath">Selected upload file:</label> <tr>
</td> <p>
<td> <h3><div id="status">Status: idle</div></h3>
<input id="filepath" type="text" style="width:100%; border: 0" readonly> </p>
</td>
<td>
<button id="upload" type="button" onclick="upload()">Upload</button>
</td>
</tr>
</table>
</td>
</tr> </tr>
</table> </table>
<h2>Reboot</h2> <h2>Reboot</h2>
<button class="button" id="reboot" type="button" onclick="doReboot()">Reboot to activate updates</button> <button class="button" id="reboot" type="button" onclick="doReboot()">Manual reboot</button>
<hr> <hr>
<script type="text/javascript" src="./gethost.js"></script> <script type="text/javascript" src="./gethost.js"></script>
@@ -79,7 +72,6 @@ function init(){
basepath = getbasepath(); basepath = getbasepath();
document.getElementById("reboot").disabled = true; document.getElementById("reboot").disabled = true;
document.getElementById("upload").disabled = true;
document.getElementById("doUpdate").disabled = true; document.getElementById("doUpdate").disabled = true;
} }
@@ -124,15 +116,16 @@ function doReboot() {
function setpath() { function setpath() {
var nameneu = document.getElementById("newfile").value; var nameneu = document.getElementById("newfile").value;
nameneu = nameneu.split(/[\\\/]/).pop(); nameneu = nameneu.split(/[\\\/]/).pop();
document.getElementById("filepath").value = nameneu; document.getElementById("doUpdate").disabled = false;
document.getElementById("upload").disabled = false; document.getElementById("status").innerText = "Status: file selected";
} }
function upload() { function upload() {
var xhttp = new XMLHttpRequest(); var xhttp = new XMLHttpRequest();
var filePath = document.getElementById("filepath").value; var nameneu = document.getElementById("newfile").value;
filePath = nameneu.split(/[\\\/]/).pop();
var upload_path = "/upload/firmware/" + filePath; var upload_path = "/upload/firmware/" + filePath;
var fileInput = document.getElementById("newfile").files; var fileInput = document.getElementById("newfile").files;
@@ -196,18 +189,29 @@ function upload() {
var file = fileInput[0]; var file = fileInput[0];
xhttp.open("POST", upload_path, false); xhttp.open("POST", upload_path, false);
document.getElementById("status").innerText = "Status: uploading";
xhttp.send(file); xhttp.send(file);
} }
alert("Start processing!"); document.getElementById("status").innerText = "Status: processing on ESP32";
var xhttp = new XMLHttpRequest(); var xhttp = new XMLHttpRequest();
/* first delete the old firmware */ /* first delete the old firmware */
xhttp.onreadystatechange = function() { xhttp.onreadystatechange = function() {
if (xhttp.readyState == 4) { if (xhttp.readyState == 4) {
if (xhttp.status == 200) { if (xhttp.status == 200) {
alert("Processing done!\n" + xhttp.responseText); if (xhttp.responseText == "reboot")
/* keine Reaktion, damit sich das Dokument nicht ändert */ {
var stringota = "/reboot_action.html";
window.location = stringota;
window.location.href = stringota;
window.location.assign(stringota);
window.location.replace(stringota);
}
else
{
alert("Processing done!\n\n" + xhttp.responseText);
}
} else if (xhttp.status == 0) { } else if (xhttp.status == 0) {
alert("Server closed the connection abruptly!"); alert("Server closed the connection abruptly!");
UpdatePage(); UpdatePage();

View File

@@ -0,0 +1,11 @@
<body style='font-family: arial'>
<h3 id=t></h3>
</body>
<script>
var h='Rebooting!<br>The page will automatically reload after around 25s.<br>';
document.getElementById('t').innerHTML=h;
setInterval(function (){h +='.';
document.getElementById('t').innerHTML=h;
fetch(window.location.hostname,{mode: 'no-cors'}).then(r=>{parent.location.href=('/index.html');})}, 1000);
</script>