diff --git a/scripts/htmlPreprocessorDefines.py b/scripts/htmlPreprocessorDefines.py
index f8230a90..f5d7cc31 100644
--- a/scripts/htmlPreprocessorDefines.py
+++ b/scripts/htmlPreprocessorDefines.py
@@ -35,6 +35,6 @@ def check(inp, lst, pattern):
return out
def conv(inp, lst):
- print(lst)
+ #print(lst)
out = check(inp, lst, r'\/\*(?:IF_|ELS|ENDIF_)([A-Z0-9\-_]+)?\*\/')
return check(out, lst, r'\<\!\-\-(?:IF_|ELS|ENDIF_)([A-Z0-9\-_]+)?\-\-\>')
diff --git a/src/CHANGES.md b/src/CHANGES.md
index f8b8ba84..5cc43614 100644
--- a/src/CHANGES.md
+++ b/src/CHANGES.md
@@ -1,5 +1,9 @@
# Development Changes
+## 0.8.102 - 2024-04-01
+* fix NTP for `opendtufusion` #1542
+* fix scan WiFi in AP mode
+
## 0.8.101 - 2024-03-28
* updated converter scripts to include all enabled features again (redundant scan of build flags) #1534
diff --git a/src/app.cpp b/src/app.cpp
index 506074c5..ae50ba49 100644
--- a/src/app.cpp
+++ b/src/app.cpp
@@ -62,7 +62,6 @@ void app::setup() {
#endif // ETHERNET
mNetwork->setup(mConfig, &mTimestamp, [this](bool gotIp) { this->onNetwork(gotIp); }, [this](bool gotTime) { this->onNtpUpdate(gotTime); });
mNetwork->begin();
- everySec(std::bind(&AhoyNetwork::tickNetworkLoop, mNetwork), "net");
esp_task_wdt_reset();
@@ -176,6 +175,7 @@ void app::regularTickers(void) {
DPRINTLN(DBG_DEBUG, F("regularTickers"));
everySec(std::bind(&WebType::tickSecond, &mWeb), "webSc");
everySec([this]() { mProtection->tickSecond(); }, "prot");
+ everySec([this]() {mNetwork->tickNetworkLoop(); }, "net");
// Plugins
#if defined(PLUGIN_DISPLAY)
diff --git a/src/app.h b/src/app.h
index 66234a31..300c1c25 100644
--- a/src/app.h
+++ b/src/app.h
@@ -167,10 +167,6 @@ class app : public IApp, public ah::Scheduler {
}
#if !defined(ETHERNET)
- void scanAvailNetworks() override {
- mNetwork->scanAvailNetworks();
- }
-
bool getAvailNetworks(JsonObject obj) override {
return mNetwork->getAvailNetworks(obj);
}
@@ -179,10 +175,6 @@ class app : public IApp, public ah::Scheduler {
mNetwork->begin();
}
- /*void setStopApAllowedMode(bool allowed) override {
- mWifi.setStopApAllowedMode(allowed);
- }*/
-
bool getWasInCh12to14(void) const override {
#if defined(ESP8266)
return mNetwork->getWasInCh12to14();
diff --git a/src/appInterface.h b/src/appInterface.h
index b7ee2aaf..49470e02 100644
--- a/src/appInterface.h
+++ b/src/appInterface.h
@@ -26,10 +26,8 @@ class IApp {
virtual const char *getVersionModules() = 0;
#if !defined(ETHERNET)
- virtual void scanAvailNetworks() = 0;
virtual bool getAvailNetworks(JsonObject obj) = 0;
virtual void setupStation(void) = 0;
- //virtual void setStopApAllowedMode(bool allowed) = 0;
virtual bool getWasInCh12to14(void) const = 0;
#endif /* defined(ETHERNET) */
virtual String getIp(void) = 0;
diff --git a/src/defines.h b/src/defines.h
index 3edc6f09..ab7c860b 100644
--- a/src/defines.h
+++ b/src/defines.h
@@ -13,7 +13,7 @@
//-------------------------------------
#define VERSION_MAJOR 0
#define VERSION_MINOR 8
-#define VERSION_PATCH 101
+#define VERSION_PATCH 102
//-------------------------------------
typedef struct {
uint8_t ch;
diff --git a/src/network/AhoyNetwork.h b/src/network/AhoyNetwork.h
index 9573f48f..c98d9866 100644
--- a/src/network/AhoyNetwork.h
+++ b/src/network/AhoyNetwork.h
@@ -86,19 +86,20 @@ class AhoyNetwork {
}
#if !defined(ETHERNET)
- void scanAvailNetworks(void) {
+ bool getAvailNetworks(JsonObject obj) {
+ JsonArray nets = obj.createNestedArray(F("networks"));
+
if(!mScanActive) {
mScanActive = true;
- WiFi.scanNetworks(true);
+ WiFi.disconnect();
+ WiFi.scanNetworks(true, true);
+ return false;
}
- }
-
- bool getAvailNetworks(JsonObject obj) {
- JsonArray nets = obj.createNestedArray(F("networks"));
int n = WiFi.scanComplete();
- if (n < 0)
+ if (WIFI_SCAN_RUNNING == n)
return false;
+
if(n > 0) {
int sort[n];
sortRSSI(&sort[0], n);
@@ -174,7 +175,6 @@ class AhoyNetwork {
private:
void sendNTPpacket(void) {
- //DPRINTLN(DBG_VERBOSE, F("wifi::sendNTPpacket"));
uint8_t buf[NTP_PACKET_SIZE];
memset(buf, 0, NTP_PACKET_SIZE);
diff --git a/src/network/AhoyWifiAp.h b/src/network/AhoyWifiAp.h
index 3c75dc12..56ff63d7 100644
--- a/src/network/AhoyWifiAp.h
+++ b/src/network/AhoyWifiAp.h
@@ -22,6 +22,12 @@ class AhoyWifiAp {
void tickLoop() {
if(mEnabled)
mDns.processNextRequest();
+
+ if (WiFi.softAPgetStationNum() != mLast) {
+ mLast = WiFi.softAPgetStationNum();
+ if(mLast > 0)
+ DBGPRINTLN(F("AP client connected"));
+ }
}
void enable() {
@@ -68,6 +74,7 @@ class AhoyWifiAp {
DNSServer mDns;
IPAddress mIp;
bool mEnabled = false;
+ uint8_t mLast = 0;
};
#endif /*__AHOY_WIFI_AP_H__*/
diff --git a/src/network/AhoyWifiEsp32.h b/src/network/AhoyWifiEsp32.h
index 255f2b03..58f5dc5d 100644
--- a/src/network/AhoyWifiEsp32.h
+++ b/src/network/AhoyWifiEsp32.h
@@ -28,7 +28,7 @@ class AhoyWifi : public AhoyNetwork {
WiFi.setSortMethod(WIFI_CONNECT_AP_BY_SIGNAL);
WiFi.begin(mConfig->sys.stationSsid, mConfig->sys.stationPwd, WIFI_ALL_CHANNEL_SCAN);
- DBGPRINT(F("connect to network '")); Serial.flush();
+ DBGPRINT(F("connect to network '"));
DBGPRINT(mConfig->sys.stationSsid);
#endif
}
@@ -44,10 +44,6 @@ class AhoyWifi : public AhoyNetwork {
mOnNetworkCB(false);
mAp.enable();
}
-
- if (WiFi.softAPgetStationNum() > 0) {
- DBGPRINTLN(F("AP client connected"));
- }
break;
case NetworkState::CONNECTED:
diff --git a/src/network/AhoyWifiEsp8266.h b/src/network/AhoyWifiEsp8266.h
index b9417556..93597f72 100644
--- a/src/network/AhoyWifiEsp8266.h
+++ b/src/network/AhoyWifiEsp8266.h
@@ -96,6 +96,8 @@ class AhoyWifi : public AhoyNetwork {
mOnNetworkCB(true);
}
+ MDNS.update();
+
if(WiFi.channel() > 11)
mWasInCh12to14 = true;
break;
diff --git a/src/utils/improv.h b/src/utils/improv.h
index 20b2bcad..d2ccc0c3 100644
--- a/src/utils/improv.h
+++ b/src/utils/improv.h
@@ -147,10 +147,12 @@ class Improv {
}
void getNetworks(void) {
- if(!mScanRunning)
- mApp->scanAvailNetworks();
-
JsonObject obj;
+ if(!mScanRunning) {
+ mApp->getAvailNetworks(obj);
+ return;
+ }
+
if(!mApp->getAvailNetworks(obj))
return;
diff --git a/src/web/RestApi.h b/src/web/RestApi.h
index 8087883e..0f256f25 100644
--- a/src/web/RestApi.h
+++ b/src/web/RestApi.h
@@ -100,7 +100,7 @@ class RestApi {
else if(path == "setup") getSetup(request, root);
#if !defined(ETHERNET)
else if(path == "setup/networks") getNetworks(root);
- else if(path == "setup/getip") getWifiIp(root);
+ else if(path == "setup/getip") getIp(root);
#endif /* !defined(ETHERNET) */
else if(path == "live") getLive(request,root);
else if (path == "powerHistory") getPowerHistory(request, root);
@@ -891,12 +891,13 @@ class RestApi {
#if !defined(ETHERNET)
void getNetworks(JsonObject obj) {
- mApp->getAvailNetworks(obj);
+ obj[F("success")] = mApp->getAvailNetworks(obj);
}
- void getWifiIp(JsonObject obj) {
+ #endif /* !defined(ETHERNET) */
+
+ void getIp(JsonObject obj) {
obj[F("ip")] = mApp->getIp();
}
- #endif /* !defined(ETHERNET) */
void getLive(AsyncWebServerRequest *request, JsonObject obj) {
getGeneric(request, obj.createNestedObject(F("generic")));
@@ -1031,11 +1032,6 @@ class RestApi {
if(isProtected(jsonIn, jsonOut, clientIP))
return false;
- #if !defined(ETHERNET)
- if(F("scan_wifi") == jsonIn[F("cmd")])
- mApp->scanAvailNetworks();
- else
- #endif /* !defined(ETHERNET) */
if(F("set_time") == jsonIn[F("cmd")])
mApp->setTimestamp(jsonIn[F("val")]);
else if(F("sync_ntp") == jsonIn[F("cmd")])
@@ -1049,7 +1045,6 @@ class RestApi {
snprintf(mConfig->sys.stationSsid, SSID_LEN, "%s", jsonIn[F("ssid")].as());
snprintf(mConfig->sys.stationPwd, PWD_LEN, "%s", jsonIn[F("pwd")].as());
mApp->saveSettings(false); // without reboot
- //mApp->setStopApAllowedMode(false);
mApp->setupStation();
}
#else
diff --git a/src/web/html/wizard.html b/src/web/html/wizard.html
index 179adb5a..d57562d1 100644
--- a/src/web/html/wizard.html
+++ b/src/web/html/wizard.html
@@ -231,7 +231,7 @@
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/"}, "{#STOP_WIZARD}")))
)
- v = setInterval(() => {getAjax('/api/setup/getip', printIp)}, 2500);
+ v = setInterval(() => {getAjax('/api/setup/getip', printIp)}, 1000);
}
function redirect() {
@@ -270,6 +270,9 @@
getAjax("/api/setup", ((o) => c.append(step1(o.eth))));
/*ELSE*/
function nets(obj) {
+ if(!obj.success)
+ return;
+
var e = document.getElementById("net");
if(obj.networks.length > 0) {
var a = []
@@ -280,12 +283,10 @@
}
e.replaceChildren(...a)
}
- getAjax("/api/setup", ((o) => {}), "POST", JSON.stringify({cmd: "scan_wifi"}));
}
- getAjax("/api/setup", ((o) => {}), "POST", JSON.stringify({cmd: "scan_wifi"}));
c.append(step1())
- v = setInterval(() => {getAjax('/api/setup/networks', nets)}, 2500);
+ v = setInterval(() => {getAjax('/api/setup/networks', nets)}, 1000);
/*ENDIF_ETHERNET*/
diff --git a/src/web/web.h b/src/web/web.h
index 419d6826..56ff577e 100644
--- a/src/web/web.h
+++ b/src/web/web.h
@@ -402,6 +402,7 @@ class Web {
void showNotFound(AsyncWebServerRequest *request) {
checkProtection(request);
+ //DBGPRINTLN(request->url());
request->redirect("/wizard");
}