Add libesphttpd to extras and supporting example (#458)
* libesphttpd: added extras and example * Added "heatshrink" as a submodule * Updated libesphttpd * Updated libesphttpd * Trying to fix the commit id * Updated libesphttpd * Added zlib1g-dev package * Use native gcc to build mkespfsimage and mkupgimg * Added NS and GW for DHCP server configuration
This commit is contained in:
parent
d36e9d65a0
commit
09b8b8087c
30 changed files with 1192 additions and 0 deletions
2
examples/esphttpd/html/wifi/140medley.min.js
vendored
Normal file
2
examples/esphttpd/html/wifi/140medley.min.js
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
var t=function(a,b){return function(c,d){return a.replace(/#{([^}]*)}/g,function(a,f){return Function("x","with(x)return "+f).call(c,d||b||{})})}},s=function(a,b){return b?{get:function(c){return a[c]&&b.parse(a[c])},set:function(c,d){a[c]=b.stringify(d)}}:{}}(this.localStorage||{},JSON),p=function(a,b,c,d){c=c||document;d=c[b="on"+b];a=c[b]=function(e){d=d&&d(e=e||c.event);return(a=a&&b(e))?b:d};c=this},m=function(a,b,c){b=document;c=b.createElement("p");c.innerHTML=a;for(a=b.createDocumentFragment();b=
|
||||
c.firstChild;)a.appendChild(b);return a},$=function(a,b){a=a.match(/^(\W)?(.*)/);return(b||document)["getElement"+(a[1]?a[1]=="#"?"ById":"sByClassName":"sByTagName")](a[2])},j=function(a){for(a=0;a<4;a++)try{return a?new ActiveXObject([,"Msxml2","Msxml3","Microsoft"][a]+".XMLHTTP"):new XMLHttpRequest}catch(b){}};
|
43
examples/esphttpd/html/wifi/connecting.html
Normal file
43
examples/esphttpd/html/wifi/connecting.html
Normal file
|
@ -0,0 +1,43 @@
|
|||
<html><head><title>Connecting...</title>
|
||||
<link rel="stylesheet" type="text/css" href="style.css">
|
||||
<script type="text/javascript" src="140medley.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
|
||||
var xhr=j();
|
||||
|
||||
|
||||
function getStatus() {
|
||||
xhr.open("GET", "connstatus.cgi");
|
||||
xhr.onreadystatechange=function() {
|
||||
if (xhr.readyState==4 && xhr.status>=200 && xhr.status<300) {
|
||||
var data=JSON.parse(xhr.responseText);
|
||||
if (data.status=="idle") {
|
||||
$("#status").innerHTML="Preparing to connect...";
|
||||
window.setTimeout(getStatus, 1000);
|
||||
} else if (data.status=="success") {
|
||||
$("#status").innerHTML="Connected! Got IP "+data.ip+". If you're in the same network, you can access it <a href=\"http://"+data.ip+"/\">here</a>.";
|
||||
} else if (data.status=="working") {
|
||||
$("#status").innerHTML="Trying to connect to selected access point...";
|
||||
window.setTimeout(getStatus, 1000);
|
||||
} else if (data.status=="fail") {
|
||||
$("#status").innerHTML="Connection failed. Check password and selected AP.<br /><a href=\"wifi.tpl\">Go Back</a>";
|
||||
}
|
||||
}
|
||||
}
|
||||
xhr.send();
|
||||
}
|
||||
|
||||
window.onload=function(e) {
|
||||
getStatus();
|
||||
};
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="main">
|
||||
<h2>Connecting to AP...</h2>
|
||||
<p>Status:<br />
|
||||
<div id="status">...</div>
|
||||
</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
BIN
examples/esphttpd/html/wifi/icons.png
Normal file
BIN
examples/esphttpd/html/wifi/icons.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 914 B |
24
examples/esphttpd/html/wifi/style.css
Normal file
24
examples/esphttpd/html/wifi/style.css
Normal file
|
@ -0,0 +1,24 @@
|
|||
|
||||
body {
|
||||
background-color: #404040;
|
||||
font-family: sans-serif;
|
||||
}
|
||||
|
||||
#main {
|
||||
background-color: #d0d0FF;
|
||||
-moz-border-radius: 5px;
|
||||
-webkit-border-radius: 5px;
|
||||
border-radius: 5px;
|
||||
border: 2px solid #000000;
|
||||
width: 800px;
|
||||
margin: 0 auto;
|
||||
padding: 20px
|
||||
}
|
||||
|
||||
.icon {
|
||||
background-image: url("icons.png");
|
||||
background-color: transparent;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
display: inline-block;
|
||||
}
|
94
examples/esphttpd/html/wifi/wifi.tpl
Normal file
94
examples/esphttpd/html/wifi/wifi.tpl
Normal file
|
@ -0,0 +1,94 @@
|
|||
<html><head><title>WiFi connection</title>
|
||||
<link rel="stylesheet" type="text/css" href="style.css">
|
||||
<script type="text/javascript" src="140medley.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
|
||||
var xhr=j();
|
||||
var currAp="%currSsid%";
|
||||
|
||||
function createInputForAp(ap) {
|
||||
if (ap.essid=="" && ap.rssi==0) return;
|
||||
var div=document.createElement("div");
|
||||
div.id="apdiv";
|
||||
var rssi=document.createElement("div");
|
||||
var rssiVal=-Math.floor(ap.rssi/51)*32;
|
||||
rssi.className="icon";
|
||||
rssi.style.backgroundPosition="0px "+rssiVal+"px";
|
||||
var encrypt=document.createElement("div");
|
||||
var encVal="-64"; //assume wpa/wpa2
|
||||
if (ap.enc=="0") encVal="0"; //open
|
||||
if (ap.enc=="1") encVal="-32"; //wep
|
||||
encrypt.className="icon";
|
||||
encrypt.style.backgroundPosition="-32px "+encVal+"px";
|
||||
var input=document.createElement("input");
|
||||
input.type="radio";
|
||||
input.name="essid";
|
||||
input.value=ap.essid;
|
||||
if (currAp==ap.essid) input.checked="1";
|
||||
input.id="opt-"+ap.essid;
|
||||
var label=document.createElement("label");
|
||||
label.htmlFor="opt-"+ap.essid;
|
||||
label.textContent=ap.essid;
|
||||
div.appendChild(input);
|
||||
div.appendChild(rssi);
|
||||
div.appendChild(encrypt);
|
||||
div.appendChild(label);
|
||||
return div;
|
||||
}
|
||||
|
||||
function getSelectedEssid() {
|
||||
var e=document.forms.wifiform.elements;
|
||||
for (var i=0; i<e.length; i++) {
|
||||
if (e[i].type=="radio" && e[i].checked) return e[i].value;
|
||||
}
|
||||
return currAp;
|
||||
}
|
||||
|
||||
|
||||
function scanAPs() {
|
||||
xhr.open("GET", "wifiscan.cgi");
|
||||
xhr.onreadystatechange=function() {
|
||||
if (xhr.readyState==4 && xhr.status>=200 && xhr.status<300) {
|
||||
var data=JSON.parse(xhr.responseText);
|
||||
currAp=getSelectedEssid();
|
||||
if (data.result.inProgress=="0" && data.result.APs.length>1) {
|
||||
$("#aps").innerHTML="";
|
||||
for (var i=0; i<data.result.APs.length; i++) {
|
||||
if (data.result.APs[i].essid=="" && data.result.APs[i].rssi==0) continue;
|
||||
$("#aps").appendChild(createInputForAp(data.result.APs[i]));
|
||||
}
|
||||
window.setTimeout(scanAPs, 20000);
|
||||
} else {
|
||||
window.setTimeout(scanAPs, 1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
xhr.send();
|
||||
}
|
||||
|
||||
|
||||
window.onload=function(e) {
|
||||
scanAPs();
|
||||
};
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="main">
|
||||
<p>
|
||||
Current WiFi mode: %WiFiMode%
|
||||
</p>
|
||||
<p>
|
||||
Note: %WiFiapwarn%
|
||||
</p>
|
||||
<form name="wifiform" action="connect.cgi" method="post">
|
||||
<p>
|
||||
To connect to a WiFi network, please select one of the detected networks...<br>
|
||||
<div id="aps">Scanning...</div>
|
||||
<br>
|
||||
WiFi password, if applicable: <br />
|
||||
<input type="text" name="passwd" val="%WiFiPasswd%"> <br />
|
||||
<input type="submit" name="connect" value="Connect!">
|
||||
</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
Loading…
Add table
Add a link
Reference in a new issue