| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459 |
- <!DOCTYPE html>
- <html>
- <head>
- <link rel="icon" href="data:,">
- <title>OTA Update</title>
- <meta charset="utf-8">
- <style>
- h1 {font-size: 2em;}
- h2 {font-size: 1.5em;}
- h3 {font-size: 1.2em;}
- p {font-size: 1em;}
- input[type=number] {
- width: 138px;
- padding: 10px 5px;
- display: inline-block;
- border: 1px solid #ccc;
- font-size: 16px;
- }
- .button {
- padding: 10px 20px;
- width: 211px;
- font-size: 16px;
- }
- </style>
- </head>
- <body style="font-family: arial; padding: 0px 10px;">
- <h3>It is strongly recommended to update firmware and content of /html directory on SD-card at the same time!</h3>
- <h2>1. Firmware Update</h2>
- <table class="fixed" border="0">
- <tr>
- <td>
- <table border="0">
- <tr>
- <td style="width: 230px">
- <label for="newfile">Select the firmware file:</label>
- </td>
- <td colspan="2">
- <input id="newfile" type="file" onchange="setpath()" style="width:100%;">
- </td>
- </tr>
- <tr>
- <td>
- <label for="filepath">Set path on server:</label>
- </td>
- <td>
- <input id="filepath" type="text" style="width:100%;" readonly>
- </td>
- <td>
- <button id="upload" type="button" onclick="upload()">Upload</button>
- </td>
- </tr>
- </table>
- </td>
- </tr>
- <tr>
- <td>
- <table border="0">
- <tr>
- <td style="width: 230px">
- <button class="button" id="doUpdate" type="button" onclick="doUpdate()">Flash the firmware</button>
- </td>
- <td>
- (Takes about 60s)
- </td>
- </tr>
- </table>
- </td>
- </tr>
- </table>
- <h2>2. Update "/html" directory</h2>
- <table class="fixed" border="0">
- <tr>
- <td>
- <table border="0">
- <tr>
- <td style="width: 230px">
- <label for="newfilehtml">Select the zipped /html content:</label>
- </td>
- <td colspan="2">
- <input id="newfilehtml" type="file" onchange="setpathhtml()" style="width:100%;">
- </td>
- </tr>
- <tr>
- <td>
- <label for="filepathhtml">Set path on server:</label>
- </td>
- <td>
- <input id="filepathhtml" type="text" style="width:100%;" readonly>
- </td>
- <td>
- <button id="uploadhtml" type="button" onclick="uploadhtml()">Upload</button>
- </td>
- </tr>
- </table>
- </td>
- </tr>
- <tr>
- <td>
- <button class="button" id="doUpdatehtml" type="button" onclick="doUpdatehtml()">Update "/html" directory</button>
- </td>
- </tr>
- </table>
- <h2>3. Reboot</h2>
- <table class="fixed" border="0">
- <tr>
- <td>
- <button class="button" id="reboot" type="button" onclick="doReboot()">Reboot to activate updates</button>
- </td>
- </tr>
- </table>
- <h2>4. Upload neural network definition (tfl/tflite file)</h2>
- <table class="fixed" border="0">
- <tr>
- <td>
- <table border="0">
- <tr>
- <td>
- <label for="newfiletfl">Select the tfl/tflite file</label>
- </td>
- <td colspan="2">
- <input id="newfiletfl" type="file" onchange="setpathtfl()" style="width:100%;">
- </td>
- </tr>
- <tr>
- <td>
- <label for="filepathtfl">Set path on server</label>
- </td>
- <td>
- <input id="filepathtfl" type="text" style="width:100%;" readonly>
- </td>
- <td>
- <button id="uploadtfl" type="button" onclick="uploadtfl()" disabled>Upload</button>
- </td>
- </tr>
- </table>
- </td>
- </tr>
- The file must be activated in the config.ini file.
- </table>
- <script type="text/javascript" src="./gethost.js"></script>
- <script language="JavaScript">
- function init(){
- document.getElementById("reboot").disabled = true;
- document.getElementById("upload").disabled = true;
- document.getElementById("uploadhtml").disabled = true;
- document.getElementById("doUpdate").disabled = true;
- document.getElementById("doUpdatehtml").disabled = true;
- document.getElementById("uploadtfl").disabled = true;
- }
- function doUpdate() {
- if (confirm("Are you sure to update the firmware?")) {
- var stringota = "/ota?file=firmware.bin";
-
- var xhttp = new XMLHttpRequest();
-
- xhttp.onreadystatechange = function() {
- if (xhttp.readyState == 4) {
- if (xhttp.status == 200) {
- document.getElementById("reboot").disabled = false;
- alert("Flash successfull - Reboot necessary to make changes active.");
- /* keine Reaktion, damit sich das Dokument nicht ändert */
- } else if (xhttp.status == 0) {
- alert("Server closed the connection abruptly!");
- UpdatePage();
- } else {
- alert(xhttp.status + " Error!\n" + xhttp.responseText);
- UpdatePage();
- }
- }
- };
- xhttp.open("GET", stringota, true);
- xhttp.send();
- }
- }
- function doUpdatehtml() {
- if (confirm("Are you sure to update the /html content?")) {
- var stringota = "/ota?task=unziphtml";
-
- var xhttp = new XMLHttpRequest();
-
- xhttp.onreadystatechange = function() {
- if (xhttp.readyState == 4) {
- if (xhttp.status == 200) {
- document.getElementById("reboot").disabled = false;
- alert("Update /html successful!");
- /* keine Reaktion, damit sich das Dokument nicht ändert */
- } else if (xhttp.status == 0) {
- alert("Server closed the connection abruptly!");
- UpdatePage();
- } else {
- alert(xhttp.status + " Error!\n" + xhttp.responseText);
- UpdatePage();
- }
- }
- };
- xhttp.open("GET", stringota, true);
- xhttp.send();
- }
- }
- function doReboot() {
- if (confirm("Are you sure you want to reboot the ESP32?")) {
- var stringota = "/reboot";
- window.location = stringota;
- window.location.href = stringota;
- window.location.assign(stringota);
- window.location.replace(stringota);
- }
- }
- function setpath() {
- var fileserverpraefix = "/firmware/firmware.bin";
- document.getElementById("filepath").value = fileserverpraefix;
- document.getElementById("upload").disabled = false;
- }
- function setpathhtml() {
- var fileserverpraefix = "/firmware/html.zip";
- document.getElementById("filepathhtml").value = fileserverpraefix;
- document.getElementById("uploadhtml").disabled = false;
- }
- function setpathtfl() {
- var nameneu = document.getElementById("newfiletfl").value;
- nameneu = nameneu.split(/[\\\/]/).pop();
- var fileserverpraefix = "/config/" + nameneu;
- document.getElementById("filepathtfl").value = fileserverpraefix;
- document.getElementById("uploadtfl").disabled = false;
- }
- function upload() {
- var xhttp = new XMLHttpRequest();
-
- /* first delete the old firmware */
- xhttp.onreadystatechange = function() {
- if (xhttp.readyState == 4) {
- if (xhttp.status == 200) {
- /* keine Reaktion, damit sich das Dokument nicht ändert */
- } else if (xhttp.status == 0) {
- alert("Server closed the connection abruptly!");
- UpdatePage();
- } else {
- alert(xhttp.status + " Error!\n" + xhttp.responseText);
- UpdatePage();
- }
- }
- };
- xhttp.open("GET", "/ota?delete=firmware.bin", false);
- xhttp.send();
- /* ----------------------------- */
-
- var filePath = document.getElementById("filepath").value;
- var upload_path = "/upload/" + filePath;
- var fileInput = document.getElementById("newfile").files;
- /* Max size of an individual file. Make sure this
- * value is same as that set in file_server.c */
- var MAX_FILE_SIZE = 2000*1024;
- var MAX_FILE_SIZE_STR = "2000KB";
- if (fileInput.length == 0) {
- alert("No file selected!");
- } else if (filePath.length == 0) {
- alert("File path on server is not set!");
- } else if (filePath.indexOf(' ') >= 0) {
- alert("File path on server cannot have spaces!");
- } else if (filePath[filePath.length-1] == '/') {
- alert("File name not specified after path!");
- } else if (fileInput[0].size > 2000*1024) {
- alert("File size must be less than 2000KB!");
- } else {
- document.getElementById("newfile").disabled = true;
- document.getElementById("filepath").disabled = true;
- document.getElementById("upload").disabled = true;
-
- xhttp.onreadystatechange = function() {
- if (xhttp.readyState == 4) {
- if (xhttp.status == 200) {
- alert("Upload successfull!")
- // document.reload();
- document.getElementById("reboot").disabled = false;
- document.getElementById("doUpdate").disabled = false;
- } else if (xhttp.status == 0) {
- alert("Server closed the connection abruptly!");
- UpdatePage();
- } else {
- alert(xhttp.status + " Error!\n" + xhttp.responseText);
- UpdatePage();
- }
- }
- };
-
- var file = fileInput[0];
- xhttp.open("POST", upload_path, true);
- xhttp.send(file);
- }
- }
- function uploadhtml() {
- var xhttp = new XMLHttpRequest();
-
- /* first delete the old firmware */
- xhttp.onreadystatechange = function() {
- if (xhttp.readyState == 4) {
- if (xhttp.status == 200) {
- /* keine Reaktion, damit sich das Dokument nicht ändert */
- } else if (xhttp.status == 0) {
- alert("Server closed the connection abruptly!");
- UpdatePage();
- } else {
- alert(xhttp.status + " Error!\n" + xhttp.responseText);
- UpdatePage();
- }
- }
- };
- xhttp.open("GET", "/ota?delete=html.zip", false);
- xhttp.send();
- /* ----------------------------- */
-
- var filePath = document.getElementById("filepathhtml").value;
- var upload_path = "/upload/" + filePath;
- var fileInput = document.getElementById("newfilehtml").files;
- /* Max size of an individual file. Make sure this
- * value is same as that set in file_server.c */
- var MAX_FILE_SIZE = 2000*1024;
- var MAX_FILE_SIZE_STR = "2000KB";
- if (fileInput.length == 0) {
- alert("No file selected!");
- } else if (filePath.length == 0) {
- alert("File path on server is not set!");
- } else if (filePath.indexOf(' ') >= 0) {
- alert("File path on server cannot have spaces!");
- } else if (filePath[filePath.length-1] == '/') {
- alert("File name not specified after path!");
- } else if (fileInput[0].size > 2000*1024) {
- alert("File size must be less than 2000KB!");
- } else {
- document.getElementById("newfilehtml").disabled = true;
- document.getElementById("filepathhtml").disabled = true;
- document.getElementById("uploadhtml").disabled = true;
-
- xhttp.onreadystatechange = function() {
- if (xhttp.readyState == 4) {
- if (xhttp.status == 200) {
- alert("Upload successfull!")
- // document.reload();
- document.getElementById("reboot").disabled = false;
- document.getElementById("doUpdatehtml").disabled = false;
- } else if (xhttp.status == 0) {
- alert("Server closed the connection abruptly!");
- UpdatePage();
- } else {
- alert(xhttp.status + " Error!\n" + xhttp.responseText);
- UpdatePage();
- }
- }
- };
-
- var file = fileInput[0];
- xhttp.open("POST", upload_path, true);
- xhttp.send(file);
- }
- }
- function uploadtfl() {
- var xhttp = new XMLHttpRequest();
-
- /* first delete the old firmware */
- xhttp.onreadystatechange = function() {
- if (xhttp.readyState == 4) {
- if (xhttp.status == 200) {
- /* keine Reaktion, damit sich das Dokument nicht ändert */
- } else if (xhttp.status == 0) {
- alert("Server closed the connection abruptly!");
- UpdatePage();
- } else {
- alert(xhttp.status + " Error!\n" + xhttp.responseText);
- UpdatePage();
- }
- }
- };
- /* ----------------------------- */
-
- var filePath = document.getElementById("filepathtfl").value;
- var upload_path = "/upload/" + filePath;
- var fileInput = document.getElementById("newfiletfl").files;
- /* Max size of an individual file. Make sure this
- * value is same as that set in file_server.c */
- var MAX_FILE_SIZE = 2000*1024;
- var MAX_FILE_SIZE_STR = "2000KB";
- if (fileInput.length == 0) {
- alert("No file selected!");
- } else if (filePath.length == 0) {
- alert("File path on server is not set!");
- } else if (filePath.indexOf(' ') >= 0) {
- alert("File path on server cannot have spaces!");
- } else if (filePath[filePath.length-1] == '/') {
- alert("File name not specified after path!");
- } else if (fileInput[0].size > 2000*1024) {
- alert("File size must be less than 2000KB!");
- } else {
- document.getElementById("newfiletfl").disabled = true;
- document.getElementById("filepathtfl").disabled = true;
- document.getElementById("uploadtfl").disabled = true;
-
- xhttp.onreadystatechange = function() {
- if (xhttp.readyState == 4) {
- if (xhttp.status == 200) {
- alert("Upload successfull!")
- document.getElementById("newfiletfl").disabled = false;
- document.getElementById("filepathtfl").disabled = false;
- } else if (xhttp.status == 0) {
- alert("Server closed the connection abruptly!");
- UpdatePage();
- } else {
- alert(xhttp.status + " Error!\n" + xhttp.responseText);
- UpdatePage();
- }
- }
- };
-
- var file = fileInput[0];
- xhttp.open("POST", upload_path, true);
- xhttp.send(file);
- }
- }
- init();
- </script>
- </body>
- </html>
|