|
|
@@ -0,0 +1,129 @@
|
|
|
+<html><head>
|
|
|
+ <title>jomjol - AI on the edge</title>
|
|
|
+ <meta charset="utf-8">
|
|
|
+ <meta name="viewport" content="width=device-width, initial-scale=1">
|
|
|
+ <script type="text/javascript">
|
|
|
+ //<![CDATA[
|
|
|
+ //]]>
|
|
|
+
|
|
|
+ </script>
|
|
|
+</head>
|
|
|
+
|
|
|
+<body>
|
|
|
+<table class="fixed" border="0">
|
|
|
+ <td>
|
|
|
+ <table border="0">
|
|
|
+ <tr>
|
|
|
+ <td>
|
|
|
+ <label for="newfile">Upload the firmware.bin</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>
|
|
|
+ <button id="upload" type="button" onclick="doUpdate()">Do Firmware Update</button>
|
|
|
+ </td>
|
|
|
+ </tr>
|
|
|
+</table>
|
|
|
+
|
|
|
+<script>
|
|
|
+function doUpdate() {
|
|
|
+ if (confirm("Are you sure to update the firmware?")) {
|
|
|
+ var stringota = "/ota?file=firmware.bin";
|
|
|
+ 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;
|
|
|
+}
|
|
|
+
|
|
|
+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!");
|
|
|
+ location.reload()
|
|
|
+ } else {
|
|
|
+ alert(xhttp.status + " Error!\n" + xhttp.responseText);
|
|
|
+ location.reload()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+ 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();
|
|
|
+ } else if (xhttp.status == 0) {
|
|
|
+ alert("Server closed the connection abruptly!");
|
|
|
+ location.reload()
|
|
|
+ } else {
|
|
|
+ alert(xhttp.status + " Error!\n" + xhttp.responseText);
|
|
|
+ location.reload()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+
|
|
|
+ var file = fileInput[0];
|
|
|
+ xhttp.open("POST", upload_path, true);
|
|
|
+ xhttp.send(file);
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+
|
|
|
+</body></html>
|