ESP8266 part of the f105-motor-demo project (see f105-motor-demo_stm32)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
1.2 KiB

var page_status = (function() {
var st = {};
function onUpdate(resp, status) {
if (status != 200) {
// bad response
console.error('Update failed.');
} else {
try {
// OK
var j = JSON.parse(resp);
$('.sta-only').toggle(j.sta);
$('.ap-only').toggle(j.ap);
$('#uptime').html(j.uptime);
$('#heap').html(j.heap + " bytes");
$('#wmode').html(j.wifiMode);
if (j.sta) {
$('#staSSID').html(j.sta.SSID);
$('#staRSSIperc').html(j.sta.RSSIperc);
$('#staRSSI').html(j.sta.RSSI);
$('#staMAC').html(j.sta.MAC);
}
if (j.ap) {
$('#apSSID').html(j.ap.SSID);
$('#apHidden').html(j.ap.hidden ? "Yes" : "No");
$('#apAuth').html(j.ap.auth);
// hide the password row if auth is Open
$('.ap-auth-only').toggle(j.ap.auth != 'Open');
$('#apPwd').html(j.ap.pwd);
$('#apChan').html(j.ap.chan);
$('#apMAC').html(j.ap.MAC);
}
// chip ID & macs don't change
} catch(e) {
console.error(e);
}
}
setTimeout(requestUpdate, 10000);
}
function requestUpdate() {
$().get('/api/status.json', onUpdate, true, true);
}
st.init = function() {
requestUpdate();
setTimeout(requestUpdate, 10000);
};
return st;
})();