Browse Source

0.8.107

* improved `Wizard`
pull/1584/head
lumapu 9 months ago
parent
commit
a677079681
  1. 1
      src/CHANGES.md
  2. 7
      src/network/AhoyNetwork.h
  3. 1
      src/network/AhoyWifiAp.h
  4. 1
      src/web/RestApi.h
  5. 57
      src/web/html/wizard.html
  6. 1
      src/web/web.h

1
src/CHANGES.md

@ -3,6 +3,7 @@
## 0.8.107 - 2024-04-08
* fix boot loop on `reboot on midnight` feature #1542, #1599, #1566, #1571
* fix German translation #1569
* improved `Wizard`
## 0.8.106 - 2024-04-05
* fix bootloop with CMT and NRF on ESP32 #1566 #1562

7
src/network/AhoyNetwork.h

@ -91,12 +91,10 @@ class AhoyNetwork {
#if !defined(ETHERNET)
bool getAvailNetworks(JsonObject obj) {
JsonArray nets = obj.createNestedArray(F("networks"));
if(!mScanActive) {
mScanActive = true;
if(NetworkState::GOT_IP != mStatus)
WiFi.disconnect();
//if(NetworkState::GOT_IP != mStatus)
// WiFi.disconnect();
WiFi.scanNetworks(true, true);
return false;
}
@ -106,6 +104,7 @@ class AhoyNetwork {
return false;
if(n > 0) {
JsonArray nets = obj.createNestedArray(F("networks"));
int sort[n];
sortRSSI(&sort[0], n);
for (int i = 0; i < n; ++i) {

1
src/network/AhoyWifiAp.h

@ -44,6 +44,7 @@ class AhoyWifiAp {
WiFi.softAPConfig(mIp, mIp, IPAddress(255, 255, 255, 0));
WiFi.softAP(WIFI_AP_SSID, mCfg->apPwd);
mDns.setErrorReplyCode(DNSReplyCode::NoError);
mDns.start(53, "*", mIp);
mEnabled = true;

1
src/web/RestApi.h

@ -892,6 +892,7 @@ class RestApi {
#if !defined(ETHERNET)
void getNetworks(JsonObject obj) {
obj[F("success")] = mApp->getAvailNetworks(obj);
obj[F("ip")] = mApp->getIp();
}
#endif /* !defined(ETHERNET) */

57
src/web/html/wizard.html

@ -4,7 +4,7 @@
<title>{#NAV_WIZARD}</title>
{#HTML_HEADER}
</head>
<body>
<body onload="init()">
<div id="wrapper">
<div class="container d-flex aic jc">
<div id="con"></div>
@ -14,6 +14,7 @@
var v;
var found = false;
var c = document.getElementById("con");
var redirIp = "http://192.168.4.1/index"
/*IF_ESP32*/
var pinList = [
@ -206,7 +207,7 @@
]),
...lst,
ml("div", {class: "row my-4"}, ml("div", {class: "col a-r"}, ml("input", {type: "button", class:"btn", value: "{#BTN_REBOOT}", onclick: () => {saveEth()}}, null))),
ml("div", {class: "row mt-5"}, ml("div", {class: "col a-c"}, ml("a", {href: "http://192.168.4.1/"}, "{#STOP_WIZARD}")))
ml("div", {class: "row mt-5"}, ml("div", {class: "col a-c"}, ml("a", {onclick: () => {redirect()}}, "{#STOP_WIZARD}")))
])
}
/*ELSE*/
@ -218,7 +219,7 @@
sect("{#WIFI_MANUAL}", ml("input", {id: "man", type: "text"})),
sect("{#WIFI_PASSWORD}", ml("input", {id: "pwd", type: "password"})),
ml("div", {class: "row my-4"}, ml("div", {class: "col a-r"}, ml("input", {type: "button", class:"btn", value: "{#BTN_NEXT}", onclick: () => {saveWifi()}}, null))),
ml("div", {class: "row mt-5"}, ml("div", {class: "col a-c"}, ml("a", {href: "http://192.168.4.1/index"}, "{#STOP_WIZARD}")))
ml("div", {class: "row mt-5"}, ml("div", {class: "col a-c"}, ml("a", {onclick: () => {redirect()}}, "{#STOP_WIZARD}")))
])
}
/*ENDIF_ETHERNET*/
@ -229,13 +230,13 @@
ml("div", {class: "row"}, ml("div", {class: "col"}, ml("span", {class: "fs-5"}, "{#TEST_CONNECTION}"))),
sect("{#TRY_TO_CONNECT}", ml("span", {id: "state"}, "{#CONNECTING}")),
ml("div", {class: "row my-4"}, ml("div", {class: "col a-r"}, ml("input", {type: "button", class:"btn hide", id: "btn", value: "{#BTN_FINISH}", onclick: () => {redirect()}}, null))),
ml("div", {class: "row mt-5"}, ml("div", {class: "col a-c"}, ml("a", {href: "http://192.168.4.1/index"}, "{#STOP_WIZARD}")))
ml("div", {class: "row mt-5"}, ml("div", {class: "col a-c"}, ml("a", {onclick: () => {redirect()}}, "{#STOP_WIZARD}")))
)
v = setInterval(() => {getAjax('/api/setup/getip', printIp)}, 300);
v = setInterval(() => {getAjax('/api/setup/getip', printIp)}, 500);
}
function redirect() {
window.location.replace("http://192.168.4.1/")
window.location.replace(redirIp)
}
function printIp(obj) {
@ -266,29 +267,35 @@
}
/*ENDIF_ETHERNET*/
/*IF_ETHERNET*/
getAjax("/api/setup", ((o) => c.append(step1(o.eth))));
/*ELSE*/
function nets(obj) {
if(!obj.success)
return;
function init() {
/*IF_ETHERNET*/
getAjax("/api/setup", ((o) => c.append(step1(o.eth))));
/*ELSE*/
function nets(obj) {
if(!obj.success)
return;
clearInterval(v)
v = setInterval(() => {getAjax('/api/setup/networks', nets)}, 5000)
var e = document.getElementById("net");
if(obj.networks.length > 0) {
var a = []
a.push(ml("option", {value: -1}, obj.networks.length + " {#NUM_NETWORKS_FOUND}"))
for(n of obj.networks) {
a.push(ml("option", {value: n.ssid}, n.ssid + " (" + n.rssi + "dBm)"))
found = true;
var e = document.getElementById("net");
if(obj.networks.length > 0) {
var a = []
a.push(ml("option", {value: -1}, obj.networks.length + " {#NUM_NETWORKS_FOUND}"))
for(n of obj.networks) {
a.push(ml("option", {value: n.ssid}, n.ssid + " (" + n.rssi + "dBm)"))
found = true;
}
e.replaceChildren(...a)
}
e.replaceChildren(...a)
redirIp = obj.ip + "/index"
}
}
c.append(step1())
getAjax('/api/setup/networks', nets)
v = setInterval(() => {getAjax('/api/setup/networks', nets)}, 1000)
/*ENDIF_ETHERNET*/
c.append(step1())
getAjax('/api/setup/networks', nets)
/*ENDIF_ETHERNET*/
}
</script>
</body>

1
src/web/web.h

@ -76,6 +76,7 @@ class Web {
mWeb.on("/setup", HTTP_GET, std::bind(&Web::onSetup, this, std::placeholders::_1));
mWeb.on("/wizard", HTTP_GET, std::bind(&Web::onWizard, this, std::placeholders::_1));
mWeb.on("/generate_204", HTTP_GET, std::bind(&Web::onWizard, this, std::placeholders::_1)); //Android captive portal
mWeb.on("/save", HTTP_POST, std::bind(&Web::showSave, this, std::placeholders::_1));
mWeb.on("/live", HTTP_ANY, std::bind(&Web::onLive, this, std::placeholders::_1));

Loading…
Cancel
Save