Browse Source

0.8.107

* improved `Wizard`
pull/1584/head
lumapu 10 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 ## 0.8.107 - 2024-04-08
* fix boot loop on `reboot on midnight` feature #1542, #1599, #1566, #1571 * fix boot loop on `reboot on midnight` feature #1542, #1599, #1566, #1571
* fix German translation #1569 * fix German translation #1569
* improved `Wizard`
## 0.8.106 - 2024-04-05 ## 0.8.106 - 2024-04-05
* fix bootloop with CMT and NRF on ESP32 #1566 #1562 * fix bootloop with CMT and NRF on ESP32 #1566 #1562

7
src/network/AhoyNetwork.h

@ -91,12 +91,10 @@ class AhoyNetwork {
#if !defined(ETHERNET) #if !defined(ETHERNET)
bool getAvailNetworks(JsonObject obj) { bool getAvailNetworks(JsonObject obj) {
JsonArray nets = obj.createNestedArray(F("networks"));
if(!mScanActive) { if(!mScanActive) {
mScanActive = true; mScanActive = true;
if(NetworkState::GOT_IP != mStatus) //if(NetworkState::GOT_IP != mStatus)
WiFi.disconnect(); // WiFi.disconnect();
WiFi.scanNetworks(true, true); WiFi.scanNetworks(true, true);
return false; return false;
} }
@ -106,6 +104,7 @@ class AhoyNetwork {
return false; return false;
if(n > 0) { if(n > 0) {
JsonArray nets = obj.createNestedArray(F("networks"));
int sort[n]; int sort[n];
sortRSSI(&sort[0], n); sortRSSI(&sort[0], n);
for (int i = 0; i < n; ++i) { 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.softAPConfig(mIp, mIp, IPAddress(255, 255, 255, 0));
WiFi.softAP(WIFI_AP_SSID, mCfg->apPwd); WiFi.softAP(WIFI_AP_SSID, mCfg->apPwd);
mDns.setErrorReplyCode(DNSReplyCode::NoError);
mDns.start(53, "*", mIp); mDns.start(53, "*", mIp);
mEnabled = true; mEnabled = true;

1
src/web/RestApi.h

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

57
src/web/html/wizard.html

@ -4,7 +4,7 @@
<title>{#NAV_WIZARD}</title> <title>{#NAV_WIZARD}</title>
{#HTML_HEADER} {#HTML_HEADER}
</head> </head>
<body> <body onload="init()">
<div id="wrapper"> <div id="wrapper">
<div class="container d-flex aic jc"> <div class="container d-flex aic jc">
<div id="con"></div> <div id="con"></div>
@ -14,6 +14,7 @@
var v; var v;
var found = false; var found = false;
var c = document.getElementById("con"); var c = document.getElementById("con");
var redirIp = "http://192.168.4.1/index"
/*IF_ESP32*/ /*IF_ESP32*/
var pinList = [ var pinList = [
@ -206,7 +207,7 @@
]), ]),
...lst, ...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 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*/ /*ELSE*/
@ -218,7 +219,7 @@
sect("{#WIFI_MANUAL}", ml("input", {id: "man", type: "text"})), sect("{#WIFI_MANUAL}", ml("input", {id: "man", type: "text"})),
sect("{#WIFI_PASSWORD}", ml("input", {id: "pwd", type: "password"})), 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 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*/ /*ENDIF_ETHERNET*/
@ -229,13 +230,13 @@
ml("div", {class: "row"}, ml("div", {class: "col"}, ml("span", {class: "fs-5"}, "{#TEST_CONNECTION}"))), ml("div", {class: "row"}, ml("div", {class: "col"}, ml("span", {class: "fs-5"}, "{#TEST_CONNECTION}"))),
sect("{#TRY_TO_CONNECT}", ml("span", {id: "state"}, "{#CONNECTING}")), 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 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() { function redirect() {
window.location.replace("http://192.168.4.1/") window.location.replace(redirIp)
} }
function printIp(obj) { function printIp(obj) {
@ -266,29 +267,35 @@
} }
/*ENDIF_ETHERNET*/ /*ENDIF_ETHERNET*/
/*IF_ETHERNET*/ function init() {
getAjax("/api/setup", ((o) => c.append(step1(o.eth)))); /*IF_ETHERNET*/
/*ELSE*/ getAjax("/api/setup", ((o) => c.append(step1(o.eth))));
function nets(obj) { /*ELSE*/
if(!obj.success) function nets(obj) {
return; if(!obj.success)
return;
clearInterval(v)
v = setInterval(() => {getAjax('/api/setup/networks', nets)}, 5000)
var e = document.getElementById("net"); var e = document.getElementById("net");
if(obj.networks.length > 0) { if(obj.networks.length > 0) {
var a = [] var a = []
a.push(ml("option", {value: -1}, obj.networks.length + " {#NUM_NETWORKS_FOUND}")) a.push(ml("option", {value: -1}, obj.networks.length + " {#NUM_NETWORKS_FOUND}"))
for(n of obj.networks) { for(n of obj.networks) {
a.push(ml("option", {value: n.ssid}, n.ssid + " (" + n.rssi + "dBm)")) a.push(ml("option", {value: n.ssid}, n.ssid + " (" + n.rssi + "dBm)"))
found = true; found = true;
}
e.replaceChildren(...a)
} }
e.replaceChildren(...a)
redirIp = obj.ip + "/index"
} }
}
c.append(step1()) c.append(step1())
getAjax('/api/setup/networks', nets) getAjax('/api/setup/networks', nets)
v = setInterval(() => {getAjax('/api/setup/networks', nets)}, 1000) /*ENDIF_ETHERNET*/
/*ENDIF_ETHERNET*/ }
</script> </script>
</body> </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("/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("/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("/save", HTTP_POST, std::bind(&Web::showSave, this, std::placeholders::_1));
mWeb.on("/live", HTTP_ANY, std::bind(&Web::onLive, this, std::placeholders::_1)); mWeb.on("/live", HTTP_ANY, std::bind(&Web::onLive, this, std::placeholders::_1));

Loading…
Cancel
Save