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.
 
 
 
 
 
 

122 lines
5.1 KiB

<!doctype html>
<html>
<head>
<title>System</title>
{#HTML_HEADER}
</head>
<body>
{#HTML_NAV}
<div id="wrapper">
<div id="content">
<pre id="stat"></pre>
<div id="info" class="col-sm-12 col-md-6 mt-3"></div>
<div id="radio" class="col-sm-12 col-md-6 mt-3"></div>
<div id="sun" class="col-sm-12 col-md-6 mt-3"></div>
<div id="html" class="mt-3 mb-3"></div>
</div>
</div>
{#HTML_FOOTER}
<script type="text/javascript">
function parseGeneric(obj) {
parseNav(obj);
parseESP(obj);
parseRssi(obj);
}
function genTabRow(key, value) {
var r = div(["row", "p-1"]);
r.appendChild(div(["col"], key));
r.appendChild(div(["col"], value));
return r;
}
function parseSysInfo(obj) {
const data = ["sdk", "cpu_freq", "chip_revision",
"chip_model", "chip_cores", "esp_type", "mac", "wifi_rssi", "ts_uptime",
"flash_size", "sketch_used", "heap_total", "heap_free", "heap_frag",
"max_free_blk", "version", "core_version", "reboot_reason"];
var main = document.getElementById("info");
var h = div(["head", "p-2"]);
var r = div(["row"]);
r.appendChild(div(["col", "a-c"], "System Information"));
h.appendChild(r);
main.appendChild(h);
for (const [key, value] of Object.entries(obj)) {
if(!data.includes(key) || (typeof value == 'undefined')) continue;
main.appendChild(genTabRow(key, value));
}
}
function parseRadio(obj, stat) {
const pa = ["MIN (recommended)", "LOW", "HIGH", "MAX"];
const datarate = ["1 MBps", "2 MBps", "250 kbps"];
var main = document.getElementById("radio");
var h = div(["head", "p-2"]);
var r = div(["row"]);
r.appendChild(div(["col", "a-c"], "Radio"));
h.appendChild(r);
main.appendChild(h);
main.appendChild(
genTabRow("nrf24l01" + (obj["isPVariant"] ? "+ " : ""), (obj["isconnected"] ? "is connected " : "is not connected "))
);
if(obj["isconnected"]) {
main.appendChild(genTabRow("Datarate", datarate[obj["DataRate"]]));
main.appendChild(genTabRow("Power Level", pa[obj["power_level"]]));
}
main.append(
genTabRow("TX count", stat["tx_cnt"]),
genTabRow("RX success", stat["rx_success"]),
genTabRow("RX fail", stat["rx_fail"]),
genTabRow("RX no answer", stat["rx_fail_answer"]),
genTabRow("RX fragments", stat["frame_cnt"]),
genTabRow("TX retransmits", stat["retransmits"])
);
}
function parseIndex(obj) {
if(obj["ts_sunrise"] > 0) {
var h = div(["head", "p-2"]);
var r = div(["row"]);
r.appendChild(div(["col", "a-c"], "Sun"));
h.appendChild(r);
document.getElementById("sun").append (
h,
genTabRow("Sunrise", new Date(obj["ts_sunrise"] * 1000).toLocaleString('de-DE')),
genTabRow("Sunset", new Date(obj["ts_sunset"] * 1000).toLocaleString('de-DE')),
genTabRow("Communication start", new Date((obj["ts_sunrise"] - obj["ts_offset"]) * 1000).toLocaleString('de-DE')),
genTabRow("Communication stop", new Date((obj["ts_sunset"] + obj["ts_offset"]) * 1000).toLocaleString('de-DE')),
genTabRow("Night Communication", ((obj["disNightComm"]) ? "disabled" : "enabled"))
);
}
}
function parse(obj) {
if(null != obj) {
parseGeneric(obj["generic"]);
if(null != obj["refresh"]) {
var meta = document.createElement('meta');
meta.httpEquiv = "refresh"
meta.content = obj["refresh"] + "; URL=" + obj["refresh_url"];
document.getElementsByTagName('head')[0].appendChild(meta);
}
else {
parseSysInfo(obj["system"]);
parseRadio(obj["system"]["radio"], obj["system"]["statistics"]);
getAjax('/api/index', parseIndex);
}
document.getElementById("html").innerHTML = obj["html"];
}
}
getAjax("/api/html" + window.location.pathname, parse);
</script>
</body>
</html>