@ -18,10 +18,18 @@
< / script >
< / script >
< / head >
< / head >
< body onload = "load()" >
< body onload = "load()" >
< h1 > Setup< / h1 >
< div class = "topnav" >
< div id = "setup" class = "content" >
< a href = "/" class = "title" > AhoyDTU< / a >
< a href = "javascript:void(0);" class = "icon" onclick = "topnav()" >
< span > < / span >
< span > < / span >
< span > < / span >
< / a >
< div id = "topnav" class = "hide" > < / div >
< / div >
< div id = "wrapper" >
< div id = "content" >
< div id = "content" >
< a class = "erase" href = "/erase" > ERASE SETTINGS (not WiFi)< / a >
< a class = "btn " href = "/erase" > ERASE SETTINGS (not WiFi)< / a >
< form method = "post" action = "/save" >
< form method = "post" action = "/save" >
< fieldset >
< fieldset >
@ -36,9 +44,11 @@
< fieldset >
< fieldset >
< legend class = "des" > WiFi< / legend >
< legend class = "des" > WiFi< / legend >
< p > Enter the credentials to your prefered WiFi station. After rebooting the device tries to connect with this information.< / p >
< p > Enter the credentials to your prefered WiFi station. After rebooting the device tries to connect with this information.< / p >
< label for = "scanbtn" > Search Networks< / label >
< input type = "button" name = "scanbtn" id = "scanbtn" class = "btn" value = "scan" onclick = "scan()" / > < br / >
< label for = "networks" > Avail Networks< / label >
< label for = "networks" > Avail Networks< / label >
< select name = "networks" id = "networks" onChange = "selNet()" >
< select name = "networks" id = "networks" onChange = "selNet()" >
< option value = "-1" > scanning ... < / option >
< option value = "-1" > not scanned < / option >
< / select >
< / select >
< label for = "ssid" > SSID< / label >
< label for = "ssid" > SSID< / label >
< input type = "text" name = "ssid" class = "text" / >
< input type = "text" name = "ssid" class = "text" / >
@ -52,7 +62,7 @@
< fieldset >
< fieldset >
< legend class = "des" > Inverter< / legend >
< legend class = "des" > Inverter< / legend >
< div id = "inverter" > < / div > < br / >
< div id = "inverter" > < / div > < br / >
< input type = "button" id = "btnAdd" value = "Add Inverter" / >
< input type = "button" id = "btnAdd" class = "btn" value = "Add Inverter" / >
< p class = "subdes" > General< / p >
< p class = "subdes" > General< / p >
< label for = "invInterval" > Interval [s]< / label >
< label for = "invInterval" > Interval [s]< / label >
< input type = "text" class = "text" name = "invInterval" / >
< input type = "text" class = "text" name = "invInterval" / >
@ -139,11 +149,17 @@
< / div >
< / div >
< / div >
< / div >
< div id = "footer" >
< div id = "footer" >
< p class = "left" > < a href = "/" > Home< / a > < / p >
< div class = "left" >
< p class = "left" > < a href = "/update" > Update Firmware< / a > < / p >
AhoyDTU & copy 2022
< p class = "right" id = "version" > < / p >
< ul >
< p class = "right" > < a href = "/factory" > Factory Reset< / a > < / p >
< li > < a href = "https://discord.gg/WzhxEY62mB" target = "_blank" > Discord< / a > < / li >
< p class = "right" > < a href = "/reboot" > Reboot< / a > < / p >
< li > < a href = "https://github.com/lumapu/ahoy" target = "_blank" > Github< / a > < / li >
< / ul >
< / div >
< div class = "right" >
< span id = "version" > < / span > < br / > < br / >
< a href = "https://creativecommons.org/licenses/by-nc-sa/3.0/de" target = "_blank" > CC BY-NC-SA 3.0< / a >
< / div >
< / div >
< / div >
< script type = "text/javascript" >
< script type = "text/javascript" >
var highestId = 0;
var highestId = 0;
@ -156,6 +172,15 @@
ivHtml(JSON.parse('{"name":"","serial":"","channels":4,"ch_max_power":[0,0,0,0],"ch_name":["","","",""]}'), highestId + 1);
ivHtml(JSON.parse('{"name":"","serial":"","channels":4,"ch_max_power":[0,0,0,0],"ch_name":["","","",""]}'), highestId + 1);
});
});
function apiCbWifi(obj) {
var e = document.getElementById("networks");
selDelAllOpt(e);
if(obj["success"])
e.appendChild(opt("-1", "scanning ..."))
else
e.appendChild(opt("-1", "Error: " + obj["error"]));
}
function apiCbNtp(obj) {
function apiCbNtp(obj) {
var e = document.getElementById("apiResultNtp");
var e = document.getElementById("apiResultNtp");
if(obj["success"])
if(obj["success"])
@ -180,6 +205,13 @@
getAjax("/api/setup", apiCbNtp, "POST", JSON.stringify(obj));
getAjax("/api/setup", apiCbNtp, "POST", JSON.stringify(obj));
}
}
function scan() {
var obj = new Object();
obj.cmd = "scan_wifi";
getAjax("/api/setup", apiCbWifi, "POST", JSON.stringify(obj));
setTimeout(function() {getAjax('/api/setup/networks', listNetworks)}, 7000);
}
function syncTime() {
function syncTime() {
var obj = new Object();
var obj = new Object();
obj.cmd = "sync_ntp";
obj.cmd = "sync_ntp";
@ -197,13 +229,14 @@
var e = document.getElementsByName(id + "Addr")[0];
var e = document.getElementsByName(id + "Addr")[0];
e.value = "";
e.value = "";
e.dispatchEvent(new Event("keyup"));
e.dispatchEvent(new Event("keyup"));
e.dispatchEvent(new Event("change"));
document.getElementsByName(id + "Name")[0].value = "";
document.getElementsByName(id + "Name")[0].value = "";
}
}
function ivHtml(obj, id) {
function ivHtml(obj, id) {
highestId = id;
highestId = id;
if(highestId == (maxInv - 1))
if(highestId == (maxInv - 1))
toggl e("btnAdd", true);
setHid e("btnAdd", true);
iv = document.getElementById("inverter");
iv = document.getElementById("inverter");
iv.appendChild(des("Inverter " + id));
iv.appendChild(des("Inverter " + id));
id = "inv" + id;
id = "inv" + id;
@ -212,28 +245,32 @@
iv.appendChild(lbl(id + "Addr", "Address*"));
iv.appendChild(lbl(id + "Addr", "Address*"));
var addr = inp(id + "Addr", obj["serial"], 12)
var addr = inp(id + "Addr", obj["serial"], 12)
iv.appendChild(addr);
iv.appendChild(addr);
addr.addEventListener("keyup", (e) => {
['keyup', 'change'].forEach(function(evt) {
var serial = addr.value.substring(0,4);
var max = 0;
addr.addEventListener(evt, (e) => {
for(var i=0;i< 4 ; i + + ) {
var serial = addr.value.substring(0,4);
toggle(id+"ModPwr"+i, true);
var max = 0;
toggle(id+"ModName"+i, true);
for(var i=0;i< 4 ; i + + ) {
}
setHide(id+"ModPwr"+i, true);
toggle("lbl"+id+"ModPwr", true);
setHide(id+"ModName"+i, true);
toggle("lbl"+id+"ModName", true);
}
setHide("lbl"+id+"ModPwr", true);
if(serial == "1161") max = 4;
setHide("lbl"+id+"ModName", true);
else if(serial == "1141") max = 2;
else if(serial == "1121") max = 1;
if(serial === "1161") max = 4;
else if(serial === "1141") max = 2;
for(var i=0;i< max ; i + + ) {
else if(serial === "1121") max = 1;
toggle(id+"ModPwr"+i, false);
else max = 0;
toggle(id+"ModName"+i, false);
}
if(max != 0) {
if(max != 0) {
for(var i=0;i< max ; i + + ) {
toggle("lbl"+id+"ModPwr", false);
setHide(id+"ModPwr"+i, false);
toggle("lbl"+id+"ModName", false);
setHide(id+"ModName"+i, false);
}
}
setHide("lbl"+id+"ModPwr", false);
setHide("lbl"+id+"ModName", false);
}
})
});
});
for(var i of [["Name", "name", "Name*", 32]]) {
for(var i of [["Name", "name", "Name*", 32]]) {
@ -268,7 +305,7 @@
function parseSys(obj) {
function parseSys(obj) {
for(var i of [["device", "device_name"], ["ssid", "ssid"]])
for(var i of [["device", "device_name"], ["ssid", "ssid"]])
document.getElementsByName(i[0])[0].value = obj[i[1]];
document.getElementsByName(i[0])[0].value = obj[i[1]];
document.getElementById("version").innerHTML = "Git SHA: " + obj["build"] + " :: " + obj["version"] ;
parseVersion(obj) ;
}
}
function parseIv(obj) {
function parseIv(obj) {
@ -372,6 +409,7 @@
function parse(root) {
function parse(root) {
if(null != root) {
if(null != root) {
parseMenu(root["menu"]);
parseSys(root["system"]);
parseSys(root["system"]);
parseIv(root["inverter"]);
parseIv(root["inverter"]);
parseMqtt(root["mqtt"]);
parseMqtt(root["mqtt"]);
@ -381,28 +419,26 @@
parseRadio(root["radio"]);
parseRadio(root["radio"]);
parseSerial(root["serial"]);
parseSerial(root["serial"]);
}
}
getAjax('/api/setup/networks', listNetworks);
window.setInterval("getAjax('/api/setup/networks', listNetworks)", 7000);
}
}
function listNetworks(root) {
function listNetworks(root) {
var s = document.getElementById("networks");
selDelAllOpt(s);
if(root["networks"].length > 0) {
if(root["networks"].length > 0) {
var s = document.getElementById("networks");
s.appendChild(opt("-1", "please select network"));
var i, l = s.options.length - 1;
for(i = l; i >= 0; i--) {
s.remove(i);
}
for(i = 0; i < root [ " networks " ] . length ; i + + ) {
for(i = 0; i < root [ " networks " ] . length ; i + + ) {
s.appendChild(opt(root["networks"][i]["ssid"], root["networks"][i]["ssid"] + " (" + root["networks"][i]["rssi"] + " dBm)"));
s.appendChild(opt(root["networks"][i]["ssid"], root["networks"][i]["ssid"] + " (" + root["networks"][i]["rssi"] + " dBm)"));
}
}
}
}
else
s.appendChild(opt("-1", "no network found"));
}
}
function selNet() {
function selNet() {
var s = document.getElementById("networks");
var s = document.getElementById("networks");
var e = document.getElementsByName("ssid")[0];
var e = document.getElementsByName("ssid")[0];
e.value = s.value;
if(-1 != s.value)
e.value = s.value;
}
}
hiddenInput = document.getElementById("disclaimer")
hiddenInput = document.getElementById("disclaimer")