wlan_config.html 4.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <table>
  2. <tr><td>WLAN-SSID</td><td><input type="text" name="ssid" id="ssid"></td><td>SSID of the WLAN</td></tr>
  3. <tr><td>WLAN-Password</td><td><input type="text" name="password" id="password"></td><td>ATTENTION: the password will not be encrypted during the sending.</td>
  4. </tr><tr><td> Hostname</td><td><input type="text" name="hostname" id="hostname"></td><td></td>
  5. </tr><tr><td>Fixed IP</td><td><input type="text" name="ip" id="ip"></td><td>Leave emtpy if set by router</td></tr>
  6. <tr><td>gateway</td><td><input type="text" name="gateway" id="gateway"></td><td>Leave emtpy if set by router</td></tr>
  7. <tr><td>netmask</td><td><input type="text" name="netmask" id="netmask"></td><td>Leave emtpy if set by router</td>
  8. </tr><tr><td>DNS</td><td><input type="text" name="dns" id="dns"></td><td>Leave emtpy if set by router</td></tr>
  9. <tr><td>RSSI Threashold</td><td><input type="number" name="name" id="threashold" min="-100" max="0" step="1" value = "0"></td><td>WLAN Mesh Parameter: Threashold for RSSI value to check for start switching access point in a mesh system.Possible values: -100 to 0, 0 = disabled - Value will be transfered to wlan.ini at next startup)</td></tr>
  10. </table>
  11. <button class="button" type="button" onclick="wr()">Write wlan.ini</button>
  12. <input id="newfile" type="file">
  13. <button class="button" style="width:300px" id="doUpdate" type="button" onclick="upload()">Upload Files</button>
  14. <script language="JavaScript">function wr(){
  15. api = "/config?"+"ssid"+document.getElementById("ssid").value+"&pwd="+document.getElementById("password").value;+"&hn="+document.getElementById("hostname").value;+"&ip="+document.getElementById("ip").value;+"&gw="+document.getElementById("gateway").value;+"&nm="+document.getElementById("netmask").value;+"&dns="+document.getElementById("dns").value;+"&rssi="+document.getElementById("threashold").value;
  16. fetch(api);}
  17. function upload() {
  18. var xhttp = new XMLHttpRequest();
  19. xhttp.onreadystatechange = function() {
  20. if (xhttp.readyState == 4) {stopProgressTimer();if (xhttp.status == 200) {extract();} }};
  21. var filePath = document.getElementById("newfile").value.split(/[\\\/]/).pop();
  22. var file = document.getElementById("newfile").files[0];
  23. if (!file.name.includes("remote-setup"))
  24. {
  25. if (!confirm("The zip file name should contain \"...remote-setup...\". Are you sure that you have downloaded the correct file?"))
  26. return;
  27. }
  28. var upload_path = "/upload/firmware/" + filePath; xhttp.open("POST", upload_path, true); xhttp.send(file);}
  29. function extract() {
  30. document.getElementById("status").innerText = "Status: Processing on device (takes up to 3 minutes)...";
  31. var xhttp = new XMLHttpRequest();
  32. /* first delete the old firmware */
  33. xhttp.onreadystatechange = function() {
  34. if (xhttp.readyState == 4) {
  35. stopProgressTimer();
  36. if (xhttp.status == 200) {
  37. document.getElementById("status").innerText = "Status: Update completed!";
  38. document.getElementById("doUpdate").disabled = true;
  39. document.getElementById("newfile").disabled = false;
  40. document.cookie = "page=overview.html"; // Make sure after the reboot we go to the overview page
  41. if (xhttp.responseText.startsWith("reboot"))
  42. {
  43. doRebootAfterUpdate();
  44. }
  45. else
  46. {
  47. alert("Processing done!\n\n" + xhttp.responseText);
  48. }
  49. } else if (xhttp.status == 0) {
  50. alert("Server closed the connection abruptly!");
  51. UpdatePage();
  52. } else {
  53. alert(xhttp.status + " Error!\n" + xhttp.responseText);
  54. UpdatePage();
  55. }
  56. }
  57. };
  58. startProgressTimer("Extraction");
  59. var nameneu = document.getElementById("newfile").value;
  60. filePath = nameneu.split(/[\\\/]/).pop();
  61. var _toDo = basepath + "/ota?task=update&file=" + filePath;
  62. xhttp.open("GET", _toDo, true);
  63. xhttp.send();
  64. }
  65. function startProgressTimer(step) {
  66. console.log(step + "...");
  67. document.getElementById('progress').innerHTML = "(0s)";
  68. action_runtime = 0;
  69. progressTimerHandle = setInterval(function() {
  70. action_runtime += 1;
  71. console.log("Progress: " + action_runtime + "s");
  72. document.getElementById('progress').innerHTML = "(" + action_runtime + "s)";
  73. }, 1000);
  74. }
  75. function stopProgressTimer() {
  76. clearInterval(progressTimerHandle);
  77. document.getElementById('progress').innerHTML = "";
  78. }
  79. </script>