Browse Source

0.8.102 - 2024-04-01

* fix NTP for `opendtufusion` #1542
* fix scan WiFi in AP mode
pull/1552/head
lumapu 10 months ago
parent
commit
bcc52c793c
  1. 2
      scripts/htmlPreprocessorDefines.py
  2. 4
      src/CHANGES.md
  3. 2
      src/app.cpp
  4. 8
      src/app.h
  5. 2
      src/appInterface.h
  6. 2
      src/defines.h
  7. 16
      src/network/AhoyNetwork.h
  8. 7
      src/network/AhoyWifiAp.h
  9. 6
      src/network/AhoyWifiEsp32.h
  10. 2
      src/network/AhoyWifiEsp8266.h
  11. 8
      src/utils/improv.h
  12. 15
      src/web/RestApi.h
  13. 9
      src/web/html/wizard.html
  14. 1
      src/web/web.h

2
scripts/htmlPreprocessorDefines.py

@ -35,6 +35,6 @@ def check(inp, lst, pattern):
return out return out
def conv(inp, lst): def conv(inp, lst):
print(lst) #print(lst)
out = check(inp, lst, r'\/\*(?:IF_|ELS|ENDIF_)([A-Z0-9\-_]+)?\*\/') out = check(inp, lst, r'\/\*(?:IF_|ELS|ENDIF_)([A-Z0-9\-_]+)?\*\/')
return check(out, lst, r'\<\!\-\-(?:IF_|ELS|ENDIF_)([A-Z0-9\-_]+)?\-\-\>') return check(out, lst, r'\<\!\-\-(?:IF_|ELS|ENDIF_)([A-Z0-9\-_]+)?\-\-\>')

4
src/CHANGES.md

@ -1,5 +1,9 @@
# Development Changes # 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 ## 0.8.101 - 2024-03-28
* updated converter scripts to include all enabled features again (redundant scan of build flags) #1534 * updated converter scripts to include all enabled features again (redundant scan of build flags) #1534

2
src/app.cpp

@ -62,7 +62,6 @@ void app::setup() {
#endif // ETHERNET #endif // ETHERNET
mNetwork->setup(mConfig, &mTimestamp, [this](bool gotIp) { this->onNetwork(gotIp); }, [this](bool gotTime) { this->onNtpUpdate(gotTime); }); mNetwork->setup(mConfig, &mTimestamp, [this](bool gotIp) { this->onNetwork(gotIp); }, [this](bool gotTime) { this->onNtpUpdate(gotTime); });
mNetwork->begin(); mNetwork->begin();
everySec(std::bind(&AhoyNetwork::tickNetworkLoop, mNetwork), "net");
esp_task_wdt_reset(); esp_task_wdt_reset();
@ -176,6 +175,7 @@ void app::regularTickers(void) {
DPRINTLN(DBG_DEBUG, F("regularTickers")); DPRINTLN(DBG_DEBUG, F("regularTickers"));
everySec(std::bind(&WebType::tickSecond, &mWeb), "webSc"); everySec(std::bind(&WebType::tickSecond, &mWeb), "webSc");
everySec([this]() { mProtection->tickSecond(); }, "prot"); everySec([this]() { mProtection->tickSecond(); }, "prot");
everySec([this]() {mNetwork->tickNetworkLoop(); }, "net");
// Plugins // Plugins
#if defined(PLUGIN_DISPLAY) #if defined(PLUGIN_DISPLAY)

8
src/app.h

@ -167,10 +167,6 @@ class app : public IApp, public ah::Scheduler {
} }
#if !defined(ETHERNET) #if !defined(ETHERNET)
void scanAvailNetworks() override {
mNetwork->scanAvailNetworks();
}
bool getAvailNetworks(JsonObject obj) override { bool getAvailNetworks(JsonObject obj) override {
return mNetwork->getAvailNetworks(obj); return mNetwork->getAvailNetworks(obj);
} }
@ -179,10 +175,6 @@ class app : public IApp, public ah::Scheduler {
mNetwork->begin(); mNetwork->begin();
} }
/*void setStopApAllowedMode(bool allowed) override {
mWifi.setStopApAllowedMode(allowed);
}*/
bool getWasInCh12to14(void) const override { bool getWasInCh12to14(void) const override {
#if defined(ESP8266) #if defined(ESP8266)
return mNetwork->getWasInCh12to14(); return mNetwork->getWasInCh12to14();

2
src/appInterface.h

@ -26,10 +26,8 @@ class IApp {
virtual const char *getVersionModules() = 0; virtual const char *getVersionModules() = 0;
#if !defined(ETHERNET) #if !defined(ETHERNET)
virtual void scanAvailNetworks() = 0;
virtual bool getAvailNetworks(JsonObject obj) = 0; virtual bool getAvailNetworks(JsonObject obj) = 0;
virtual void setupStation(void) = 0; virtual void setupStation(void) = 0;
//virtual void setStopApAllowedMode(bool allowed) = 0;
virtual bool getWasInCh12to14(void) const = 0; virtual bool getWasInCh12to14(void) const = 0;
#endif /* defined(ETHERNET) */ #endif /* defined(ETHERNET) */
virtual String getIp(void) = 0; virtual String getIp(void) = 0;

2
src/defines.h

@ -13,7 +13,7 @@
//------------------------------------- //-------------------------------------
#define VERSION_MAJOR 0 #define VERSION_MAJOR 0
#define VERSION_MINOR 8 #define VERSION_MINOR 8
#define VERSION_PATCH 101 #define VERSION_PATCH 102
//------------------------------------- //-------------------------------------
typedef struct { typedef struct {
uint8_t ch; uint8_t ch;

16
src/network/AhoyNetwork.h

@ -86,19 +86,20 @@ class AhoyNetwork {
} }
#if !defined(ETHERNET) #if !defined(ETHERNET)
void scanAvailNetworks(void) { bool getAvailNetworks(JsonObject obj) {
JsonArray nets = obj.createNestedArray(F("networks"));
if(!mScanActive) { if(!mScanActive) {
mScanActive = true; 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(); int n = WiFi.scanComplete();
if (n < 0) if (WIFI_SCAN_RUNNING == n)
return false; return false;
if(n > 0) { if(n > 0) {
int sort[n]; int sort[n];
sortRSSI(&sort[0], n); sortRSSI(&sort[0], n);
@ -174,7 +175,6 @@ class AhoyNetwork {
private: private:
void sendNTPpacket(void) { void sendNTPpacket(void) {
//DPRINTLN(DBG_VERBOSE, F("wifi::sendNTPpacket"));
uint8_t buf[NTP_PACKET_SIZE]; uint8_t buf[NTP_PACKET_SIZE];
memset(buf, 0, NTP_PACKET_SIZE); memset(buf, 0, NTP_PACKET_SIZE);

7
src/network/AhoyWifiAp.h

@ -22,6 +22,12 @@ class AhoyWifiAp {
void tickLoop() { void tickLoop() {
if(mEnabled) if(mEnabled)
mDns.processNextRequest(); mDns.processNextRequest();
if (WiFi.softAPgetStationNum() != mLast) {
mLast = WiFi.softAPgetStationNum();
if(mLast > 0)
DBGPRINTLN(F("AP client connected"));
}
} }
void enable() { void enable() {
@ -68,6 +74,7 @@ class AhoyWifiAp {
DNSServer mDns; DNSServer mDns;
IPAddress mIp; IPAddress mIp;
bool mEnabled = false; bool mEnabled = false;
uint8_t mLast = 0;
}; };
#endif /*__AHOY_WIFI_AP_H__*/ #endif /*__AHOY_WIFI_AP_H__*/

6
src/network/AhoyWifiEsp32.h

@ -28,7 +28,7 @@ class AhoyWifi : public AhoyNetwork {
WiFi.setSortMethod(WIFI_CONNECT_AP_BY_SIGNAL); WiFi.setSortMethod(WIFI_CONNECT_AP_BY_SIGNAL);
WiFi.begin(mConfig->sys.stationSsid, mConfig->sys.stationPwd, WIFI_ALL_CHANNEL_SCAN); 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); DBGPRINT(mConfig->sys.stationSsid);
#endif #endif
} }
@ -44,10 +44,6 @@ class AhoyWifi : public AhoyNetwork {
mOnNetworkCB(false); mOnNetworkCB(false);
mAp.enable(); mAp.enable();
} }
if (WiFi.softAPgetStationNum() > 0) {
DBGPRINTLN(F("AP client connected"));
}
break; break;
case NetworkState::CONNECTED: case NetworkState::CONNECTED:

2
src/network/AhoyWifiEsp8266.h

@ -96,6 +96,8 @@ class AhoyWifi : public AhoyNetwork {
mOnNetworkCB(true); mOnNetworkCB(true);
} }
MDNS.update();
if(WiFi.channel() > 11) if(WiFi.channel() > 11)
mWasInCh12to14 = true; mWasInCh12to14 = true;
break; break;

8
src/utils/improv.h

@ -147,10 +147,12 @@ class Improv {
} }
void getNetworks(void) { void getNetworks(void) {
if(!mScanRunning)
mApp->scanAvailNetworks();
JsonObject obj; JsonObject obj;
if(!mScanRunning) {
mApp->getAvailNetworks(obj);
return;
}
if(!mApp->getAvailNetworks(obj)) if(!mApp->getAvailNetworks(obj))
return; return;

15
src/web/RestApi.h

@ -100,7 +100,7 @@ class RestApi {
else if(path == "setup") getSetup(request, root); else if(path == "setup") getSetup(request, root);
#if !defined(ETHERNET) #if !defined(ETHERNET)
else if(path == "setup/networks") getNetworks(root); else if(path == "setup/networks") getNetworks(root);
else if(path == "setup/getip") getWifiIp(root); else if(path == "setup/getip") getIp(root);
#endif /* !defined(ETHERNET) */ #endif /* !defined(ETHERNET) */
else if(path == "live") getLive(request,root); else if(path == "live") getLive(request,root);
else if (path == "powerHistory") getPowerHistory(request, root); else if (path == "powerHistory") getPowerHistory(request, root);
@ -891,12 +891,13 @@ class RestApi {
#if !defined(ETHERNET) #if !defined(ETHERNET)
void getNetworks(JsonObject obj) { 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(); obj[F("ip")] = mApp->getIp();
} }
#endif /* !defined(ETHERNET) */
void getLive(AsyncWebServerRequest *request, JsonObject obj) { void getLive(AsyncWebServerRequest *request, JsonObject obj) {
getGeneric(request, obj.createNestedObject(F("generic"))); getGeneric(request, obj.createNestedObject(F("generic")));
@ -1031,11 +1032,6 @@ class RestApi {
if(isProtected(jsonIn, jsonOut, clientIP)) if(isProtected(jsonIn, jsonOut, clientIP))
return false; 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")]) if(F("set_time") == jsonIn[F("cmd")])
mApp->setTimestamp(jsonIn[F("val")]); mApp->setTimestamp(jsonIn[F("val")]);
else if(F("sync_ntp") == jsonIn[F("cmd")]) 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<const char*>()); snprintf(mConfig->sys.stationSsid, SSID_LEN, "%s", jsonIn[F("ssid")].as<const char*>());
snprintf(mConfig->sys.stationPwd, PWD_LEN, "%s", jsonIn[F("pwd")].as<const char*>()); snprintf(mConfig->sys.stationPwd, PWD_LEN, "%s", jsonIn[F("pwd")].as<const char*>());
mApp->saveSettings(false); // without reboot mApp->saveSettings(false); // without reboot
//mApp->setStopApAllowedMode(false);
mApp->setupStation(); mApp->setupStation();
} }
#else #else

9
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 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}"))) 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() { function redirect() {
@ -270,6 +270,9 @@
getAjax("/api/setup", ((o) => c.append(step1(o.eth)))); getAjax("/api/setup", ((o) => c.append(step1(o.eth))));
/*ELSE*/ /*ELSE*/
function nets(obj) { function nets(obj) {
if(!obj.success)
return;
var e = document.getElementById("net"); var e = document.getElementById("net");
if(obj.networks.length > 0) { if(obj.networks.length > 0) {
var a = [] var a = []
@ -280,12 +283,10 @@
} }
e.replaceChildren(...a) 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()) c.append(step1())
v = setInterval(() => {getAjax('/api/setup/networks', nets)}, 2500); v = setInterval(() => {getAjax('/api/setup/networks', nets)}, 1000);
/*ENDIF_ETHERNET*/ /*ENDIF_ETHERNET*/
</script> </script>

1
src/web/web.h

@ -402,6 +402,7 @@ class Web {
void showNotFound(AsyncWebServerRequest *request) { void showNotFound(AsyncWebServerRequest *request) {
checkProtection(request); checkProtection(request);
//DBGPRINTLN(request->url());
request->redirect("/wizard"); request->redirect("/wizard");
} }

Loading…
Cancel
Save