From d0741a91e8d0e9edcff94c16d3e0a86c5b83e0fc Mon Sep 17 00:00:00 2001 From: rejoe2 Date: Mon, 1 Apr 2024 13:42:48 +0200 Subject: [PATCH 01/20] shorten last cmt waiting time after last frame is received. Works, see around this discord post: https://discord.com/channels/984173303147155506/1029761098381017098/1220679912587792404 --- src/hms/hmsRadio.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hms/hmsRadio.h b/src/hms/hmsRadio.h index d074442b..54975197 100644 --- a/src/hms/hmsRadio.h +++ b/src/hms/hmsRadio.h @@ -183,7 +183,7 @@ class CmtRadio : public Radio { if(p.packet[9] > ALL_FRAMES) { // indicates last frame setExpectedFrames(p.packet[9] - ALL_FRAMES); - mRadioWaitTime.startTimeMonitor(DURATION_PAUSE_LASTFR); // let the inverter first get back to rx mode? + mRadioWaitTime.startTimeMonitor(2); // let the inverter first get back to rx mode? } } From bcc52c793c6c9e582dbadd725cfbda36bbcc8130 Mon Sep 17 00:00:00 2001 From: lumapu Date: Mon, 1 Apr 2024 14:54:08 +0200 Subject: [PATCH 02/20] 0.8.102 - 2024-04-01 * fix NTP for `opendtufusion` #1542 * fix scan WiFi in AP mode --- scripts/htmlPreprocessorDefines.py | 2 +- src/CHANGES.md | 4 ++++ src/app.cpp | 2 +- src/app.h | 8 -------- src/appInterface.h | 2 -- src/defines.h | 2 +- src/network/AhoyNetwork.h | 16 ++++++++-------- src/network/AhoyWifiAp.h | 7 +++++++ src/network/AhoyWifiEsp32.h | 6 +----- src/network/AhoyWifiEsp8266.h | 2 ++ src/utils/improv.h | 8 +++++--- src/web/RestApi.h | 15 +++++---------- src/web/html/wizard.html | 9 +++++---- src/web/web.h | 1 + 14 files changed, 41 insertions(+), 43 deletions(-) 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"); } From 1033ddc11aa06a288f87095ed9166c6bebb15ccf Mon Sep 17 00:00:00 2001 From: Sebastian Rothe Date: Mon, 1 Apr 2024 16:48:38 +0200 Subject: [PATCH 03/20] Fix typos and spelling --- .github/ISSUE_TEMPLATE/report.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/report.yaml b/.github/ISSUE_TEMPLATE/report.yaml index 9a2824c4..19b71de2 100644 --- a/.github/ISSUE_TEMPLATE/report.yaml +++ b/.github/ISSUE_TEMPLATE/report.yaml @@ -12,7 +12,7 @@ body: Wir lesen auch gerne Deutsch, bitte fülle die u.a. Fragen aus damit wir Dir bestmöglich helfen können Danke! Bitte unser FAQ als Hilfestellung prüfen: https://ahoydtu.de/faq - Please read, copy & fill in the template from our Posting Guide lines into your Support Forum post. + Please read, then copy & fill in the template from our Posting Guide lines into your Support Forum post. We do enjoy the english language, but we need a couple of things to best support you in your goal, please fill in all / most of the details given below. Thanks! Check our FAQ: https://ahoydtu.de/faq - type: markdown @@ -35,7 +35,7 @@ body: label: Assembly description: options: - - I did the assebly by myself + - I did the assembly by myself - the DTU was already assembled validations: required: true @@ -84,7 +84,7 @@ body: label: Connection picture description: options: - - label: I will attach/upload an Image of my wiring + - label: I will attach/upload an image of my wiring validations: required: true - type: markdown From 4d5ae72cb6d1050ac81ed4f21e9b62328561527d Mon Sep 17 00:00:00 2001 From: lumapu Date: Mon, 1 Apr 2024 17:02:43 +0200 Subject: [PATCH 04/20] 0.8.102 * fix MDNS #1538 * improved Wizard * improved MqTT on devcontrol e.g. set power limit --- .gitignore | 1 + src/.gitignore | 2 ++ src/CHANGES.md | 3 ++ src/app.cpp | 55 ++++++++++++++++++++--------------- src/app.h | 11 +++++-- src/appInterface.h | 3 +- src/network/AhoyNetwork.h | 7 ++++- src/network/AhoyWifiAp.h | 3 ++ src/network/AhoyWifiEsp32.h | 6 +++- src/network/AhoyWifiEsp8266.h | 4 +++ src/web/RestApi.h | 2 +- src/web/html/setup.html | 28 +----------------- src/web/html/wizard.html | 9 +++--- src/web/lang.json | 20 ++++--------- src/web/web.h | 9 ++++-- 15 files changed, 86 insertions(+), 77 deletions(-) diff --git a/.gitignore b/.gitignore index 21ae2a57..b5c699cc 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,4 @@ src/web/html/tmp/* src/output.map /.venv +/scripts/__pycache__/htmlPreprocessorDefines.cpython-311.pyc diff --git a/src/.gitignore b/src/.gitignore index 89cc49cb..30f1d1ca 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -3,3 +3,5 @@ .vscode/c_cpp_properties.json .vscode/launch.json .vscode/ipch +scripts/__pycache__/* +*.pyc diff --git a/src/CHANGES.md b/src/CHANGES.md index 5cc43614..1ba9edd1 100644 --- a/src/CHANGES.md +++ b/src/CHANGES.md @@ -3,6 +3,9 @@ ## 0.8.102 - 2024-04-01 * fix NTP for `opendtufusion` #1542 * fix scan WiFi in AP mode +* fix MDNS #1538 +* improved Wizard +* improved MqTT on devcontrol e.g. set power limit ## 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 ae50ba49..5166c035 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -403,29 +403,7 @@ void app::tickSend(void) { for (uint8_t i = 0; i < MAX_NUM_INVERTERS; i++) { Inverter<> *iv = mSys.getInverterByPos(i); - if(NULL == iv) - continue; - - if(iv->config->enabled) { - if(!iv->commEnabled) { - DPRINT_IVID(DBG_INFO, iv->id); - DBGPRINTLN(F("no communication to the inverter (night time)")); - continue; - } - - if(!iv->radio->isChipConnected()) - continue; - - if(InverterStatus::OFF != iv->status) - notAvail = false; - - iv->tickSend([this, iv](uint8_t cmd, bool isDevControl) { - if(isDevControl) - mCommunication.addImportant(iv, cmd); - else - mCommunication.add(iv, cmd); - }); - } + sendIv(iv); } if(mAllIvNotAvail != notAvail) @@ -435,6 +413,37 @@ void app::tickSend(void) { updateLed(); } +//----------------------------------------------------------------------------- +bool app::sendIv(Inverter<> *iv) { + bool notAvail = true; + if(NULL == iv) + return notAvail; + + if(!iv->config->enabled) + return notAvail; + + if(!iv->commEnabled) { + DPRINT_IVID(DBG_INFO, iv->id); + DBGPRINTLN(F("no communication to the inverter (night time)")); + return notAvail; + } + + if(!iv->radio->isChipConnected()) + return notAvail; + + if(InverterStatus::OFF != iv->status) + notAvail = false; + + iv->tickSend([this, iv](uint8_t cmd, bool isDevControl) { + if(isDevControl) + mCommunication.addImportant(iv, cmd); + else + mCommunication.add(iv, cmd); + }); + + return notAvail; +} + //----------------------------------------------------------------------------- void app:: zeroIvValues(bool checkAvail, bool skipYieldDay) { Inverter<> *iv; diff --git a/src/app.h b/src/app.h index 300c1c25..8fe9420d 100644 --- a/src/app.h +++ b/src/app.h @@ -188,6 +188,10 @@ class app : public IApp, public ah::Scheduler { return mNetwork->getIp(); } + bool isApActive(void) override { + return mNetwork->isApActive(); + } + void setRebootFlag() override { once(std::bind(&app::tickReboot, this), 3, "rboot"); } @@ -386,8 +390,10 @@ class app : public IApp, public ah::Scheduler { bool mNtpReceived = false; void updateNtp(void); - void triggerTickSend() override { - once(std::bind(&app::tickSend, this), 0, "tSend"); + void triggerTickSend(uint8_t id) override { + once([this, id]() { + sendIv(mSys.getInverterByPos(id)); + }, 0, "devct"); } void tickCalcSunrise(void); @@ -396,6 +402,7 @@ class app : public IApp, public ah::Scheduler { void tickSunrise(void); void tickComm(void); void tickSend(void); + bool sendIv(Inverter<> *iv); void tickMinute(void); void tickZeroValues(void); void tickMidnight(void); diff --git a/src/appInterface.h b/src/appInterface.h index 49470e02..a1f5cd0e 100644 --- a/src/appInterface.h +++ b/src/appInterface.h @@ -31,6 +31,7 @@ class IApp { virtual bool getWasInCh12to14(void) const = 0; #endif /* defined(ETHERNET) */ virtual String getIp(void) = 0; + virtual bool isApActive(void) = 0; virtual uint32_t getUptime() = 0; virtual uint32_t getTimestamp() = 0; @@ -42,7 +43,7 @@ class IApp { virtual void getSchedulerInfo(uint8_t *max) = 0; virtual void getSchedulerNames() = 0; - virtual void triggerTickSend() = 0; + virtual void triggerTickSend(uint8_t id) = 0; virtual bool getRebootRequestState() = 0; virtual bool getSettingsValid() = 0; diff --git a/src/network/AhoyNetwork.h b/src/network/AhoyNetwork.h index c98d9866..55c5d193 100644 --- a/src/network/AhoyNetwork.h +++ b/src/network/AhoyNetwork.h @@ -85,13 +85,18 @@ class AhoyNetwork { return false; } + bool isApActive() { + return mAp.isEnabled(); + } + #if !defined(ETHERNET) bool getAvailNetworks(JsonObject obj) { JsonArray nets = obj.createNestedArray(F("networks")); if(!mScanActive) { mScanActive = true; - WiFi.disconnect(); + if(NetworkState::GOT_IP != mStatus) + WiFi.disconnect(); WiFi.scanNetworks(true, true); return false; } diff --git a/src/network/AhoyWifiAp.h b/src/network/AhoyWifiAp.h index 56ff63d7..ce2bbd1b 100644 --- a/src/network/AhoyWifiAp.h +++ b/src/network/AhoyWifiAp.h @@ -54,6 +54,9 @@ class AhoyWifiAp { if(!mEnabled) return; + if(WiFi.softAPgetStationNum() > 0) + return; + mDns.stop(); WiFi.softAPdisconnect(); #if defined(ETHERNET) diff --git a/src/network/AhoyWifiEsp32.h b/src/network/AhoyWifiEsp32.h index 58f5dc5d..41956dfc 100644 --- a/src/network/AhoyWifiEsp32.h +++ b/src/network/AhoyWifiEsp32.h @@ -43,6 +43,7 @@ class AhoyWifi : public AhoyNetwork { mConnected = false; mOnNetworkCB(false); mAp.enable(); + MDNS.end(); } break; @@ -50,11 +51,14 @@ class AhoyWifi : public AhoyNetwork { break; case NetworkState::GOT_IP: - if(!mConnected) { + if(mAp.isEnabled()) mAp.disable(); + + if(!mConnected) { mConnected = true; ah::welcome(WiFi.localIP().toString(), F("Station")); MDNS.begin(mConfig->sys.deviceName); + MDNS.addServiceTxt("http", "tcp", "path", "/"); mOnNetworkCB(true); } break; diff --git a/src/network/AhoyWifiEsp8266.h b/src/network/AhoyWifiEsp8266.h index 93597f72..2497448b 100644 --- a/src/network/AhoyWifiEsp8266.h +++ b/src/network/AhoyWifiEsp8266.h @@ -39,6 +39,7 @@ class AhoyWifi : public AhoyNetwork { mConnected = false; mOnNetworkCB(false); mAp.enable(); + MDNS.end(); } if (WiFi.softAPgetStationNum() > 0) { @@ -93,6 +94,9 @@ class AhoyWifi : public AhoyNetwork { mConnected = true; ah::welcome(WiFi.localIP().toString(), F("Station")); MDNS.begin(mConfig->sys.deviceName); + MDNSResponder::hMDNSService hRes = MDNS.addService(NULL, "http", "tcp", 80); + MDNS.addServiceTxt(hRes, "path", "/"); + MDNS.announce(); mOnNetworkCB(true); } diff --git a/src/web/RestApi.h b/src/web/RestApi.h index 0f256f25..a9756944 100644 --- a/src/web/RestApi.h +++ b/src/web/RestApi.h @@ -1011,7 +1011,7 @@ class RestApi { accepted = iv->setDevControlRequest(ActivePowerContr); if(accepted) - mApp->triggerTickSend(); + mApp->triggerTickSend(iv->id); } else if(F("dev") == jsonIn[F("cmd")]) { DPRINTLN(DBG_INFO, F("dev cmd")); iv->setDevCommand(jsonIn[F("val")].as()); diff --git a/src/web/html/setup.html b/src/web/html/setup.html index fb1eff97..51d48f7c 100644 --- a/src/web/html/setup.html +++ b/src/web/html/setup.html @@ -57,22 +57,9 @@
{#AP_PWD}
-
-
{#SEARCH_NETWORKS}
-
-
- -
-
{#AVAIL_NETWORKS}
-
- -
-
SSID
-
+
{#SSID_HIDDEN}
@@ -606,12 +593,6 @@ setTimeout(function() {getAjax('/api/index', apiCbNtp2)}, 2000) } - function scan() { - var obj = {cmd: "scan_wifi", token: "*"} - getAjax("/api/setup", apiCbWifi, "POST", JSON.stringify(obj)); - setTimeout(function() {getAjax('/api/setup/networks', listNetworks)}, 5000); - } - function syncTime() { var obj = {cmd: "sync_ntp", token: "*"} getAjax("/api/setup", apiCbNtp, "POST", JSON.stringify(obj)) @@ -1319,13 +1300,6 @@ s.appendChild(opt("-1", "{#NO_NETWORK_FOUND}")); } - function selNet() { - var s = document.getElementById("networks"); - var e = document.getElementsByName("ssid")[0]; - if(-1 != s.value) - e.value = s.value; - } - getAjax("/api/setup", parse); diff --git a/src/web/html/wizard.html b/src/web/html/wizard.html index d57562d1..1fc8503c 100644 --- a/src/web/html/wizard.html +++ b/src/web/html/wizard.html @@ -218,7 +218,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/"}, "{#STOP_WIZARD}"))) + ml("div", {class: "row mt-5"}, ml("div", {class: "col a-c"}, ml("a", {href: "http://192.168.4.1/index"}, "{#STOP_WIZARD}"))) ]) } /*ENDIF_ETHERNET*/ @@ -229,9 +229,9 @@ 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/"}, "{#STOP_WIZARD}"))) + ml("div", {class: "row mt-5"}, ml("div", {class: "col a-c"}, ml("a", {href: "http://192.168.4.1/index"}, "{#STOP_WIZARD}"))) ) - v = setInterval(() => {getAjax('/api/setup/getip', printIp)}, 1000); + v = setInterval(() => {getAjax('/api/setup/getip', printIp)}, 300); } function redirect() { @@ -286,7 +286,8 @@ } c.append(step1()) - v = setInterval(() => {getAjax('/api/setup/networks', nets)}, 1000); + getAjax('/api/setup/networks', nets) + v = setInterval(() => {getAjax('/api/setup/networks', nets)}, 1000) /*ENDIF_ETHERNET*/ diff --git a/src/web/lang.json b/src/web/lang.json index ee942608..57ded1dd 100644 --- a/src/web/lang.json +++ b/src/web/lang.json @@ -81,7 +81,7 @@ { "token": "BTN_NEXT", "en": "next >>", - "de": "prüfen >>" + "de": "prüfen >>" }, { "token": "BTN_REBOOT", @@ -91,7 +91,7 @@ { "token": "TEST_CONNECTION", "en": "Test Connection", - "de": "Verbindung wird überprüft" + "de": "Verbindung wird überprüft" }, { "token": "TRY_TO_CONNECT", @@ -259,19 +259,9 @@ "de": "Netzwerke suchen" }, { - "token": "BTN_SCAN", - "en": "scan", - "de": "Suche starten" - }, - { - "token": "AVAIL_NETWORKS", - "en": "Avail Networks", - "de": "Verfügbare Netzwerke" - }, - { - "token": "NETWORK_NOT_SCANNED", - "en": "not scanned", - "de": "nicht gesucht" + "token": "SCAN_WIFI", + "en": "scan for WiFi networks", + "de": "nach WiFi Netzwerken suchen" }, { "token": "SSID_HIDDEN", diff --git a/src/web/web.h b/src/web/web.h index 56ff577e..4f93b905 100644 --- a/src/web/web.h +++ b/src/web/web.h @@ -57,7 +57,8 @@ class Web { mConfig = config; DPRINTLN(DBG_VERBOSE, F("app::setup-on")); - mWeb.on("/", HTTP_GET, std::bind(&Web::onIndex, this, std::placeholders::_1)); + mWeb.on("/", HTTP_GET, std::bind(&Web::onIndex, this, std::placeholders::_1, true)); + mWeb.on("/index", HTTP_GET, std::bind(&Web::onIndex, this, std::placeholders::_1, false)); mWeb.on("/login", HTTP_ANY, std::bind(&Web::onLogin, this, std::placeholders::_1)); mWeb.on("/logout", HTTP_GET, std::bind(&Web::onLogout, this, std::placeholders::_1)); mWeb.on("/colors.css", HTTP_GET, std::bind(&Web::onColor, this, std::placeholders::_1)); @@ -319,7 +320,11 @@ class Web { client->send("hello!", NULL, millis(), 1000); } - void onIndex(AsyncWebServerRequest *request) { + void onIndex(AsyncWebServerRequest *request, bool checkAp = true) { + if(mApp->isApActive() && checkAp) { + onWizard(request); + return; + } getPage(request, PROT_MASK_INDEX, index_html, index_html_len); } From 1e6f7c1247ddfbb51a78df92c07ad5d30e41c7b4 Mon Sep 17 00:00:00 2001 From: Sebastian Rothe Date: Mon, 1 Apr 2024 18:45:16 +0200 Subject: [PATCH 05/20] fix: get refresh property from object --- src/web/html/history.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/web/html/history.html b/src/web/html/history.html index 7ec9be7e..d21e6b96 100644 --- a/src/web/html/history.html +++ b/src/web/html/history.html @@ -150,11 +150,11 @@ parseRssi(obj.generic) window.setInterval("getAjax('/api/powerHistory', parsePowerHistory)", obj.refresh * 1000) setTimeout(() => { - window.setInterval("getAjax('/api/powerHistoryDay', parsePowerHistoryDay)", refresh * 1000) + window.setInterval("getAjax('/api/powerHistoryDay', parsePowerHistoryDay)", obj.refresh * 1000) }, 200) /*IF_ENABLE_HISTORY_YIELD_PER_DAY*/ setTimeout(() => { - window.setInterval("getAjax('/api/yieldDayHistory', parseYieldDayHistory)", refresh * 1000) + window.setInterval("getAjax('/api/yieldDayHistory', parseYieldDayHistory)", obj.refresh * 1000) }, 400) /*ENDIF_ENABLE_HISTORY_YIELD_PER_DAY*/ } From 1887d6cea5cc79b0d51ef767e880d6261e6aa700 Mon Sep 17 00:00:00 2001 From: lumapu Date: Tue, 2 Apr 2024 11:55:57 +0200 Subject: [PATCH 06/20] 0.8.103 * merge PR: fix: get refresh property from object #1552 * merge PR: fix typos and spelling in Github Issue template #1550 * merge PR: shorten last cmt waiting time #1549 --- src/CHANGES.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/CHANGES.md b/src/CHANGES.md index 1ba9edd1..3705c785 100644 --- a/src/CHANGES.md +++ b/src/CHANGES.md @@ -1,5 +1,10 @@ # Development Changes +## 0.8.103 - 2024-04-02 +* merge PR: fix: get refresh property from object #1552 +* merge PR: fix typos and spelling in Github Issue template #1550 +* merge PR: shorten last cmt waiting time #1549 + ## 0.8.102 - 2024-04-01 * fix NTP for `opendtufusion` #1542 * fix scan WiFi in AP mode From 7ee1f992cb4d3c59a9b7f1fdb5f4d797f4a24085 Mon Sep 17 00:00:00 2001 From: lumapu Date: Tue, 2 Apr 2024 13:09:19 +0200 Subject: [PATCH 07/20] 0.8.103 * fix cppcheck warnings * changed MqTT retained flags of some topics --- src/CHANGES.md | 2 ++ src/app.cpp | 17 +++++++++-------- src/app.h | 2 +- src/defines.h | 2 +- src/network/AhoyWifiEsp32.h | 10 ---------- src/publisher/pubMqtt.h | 4 ++-- src/publisher/pubMqttIvData.h | 2 -- src/web/RestApi.h | 2 +- 8 files changed, 16 insertions(+), 25 deletions(-) diff --git a/src/CHANGES.md b/src/CHANGES.md index 3705c785..73c5c5d4 100644 --- a/src/CHANGES.md +++ b/src/CHANGES.md @@ -4,6 +4,8 @@ * merge PR: fix: get refresh property from object #1552 * merge PR: fix typos and spelling in Github Issue template #1550 * merge PR: shorten last cmt waiting time #1549 +* fix cppcheck warnings +* changed MqTT retained flags of some topics ## 0.8.102 - 2024-04-01 * fix NTP for `opendtufusion` #1542 diff --git a/src/app.cpp b/src/app.cpp index 5166c035..f22e6906 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -56,9 +56,9 @@ void app::setup() { #ifdef ETHERNET delay(1000); - mNetwork = (AhoyNetwork*) new AhoyEthernet(); + mNetwork = static_cast(new AhoyEthernet()); #else - mNetwork = (AhoyNetwork*) new AhoyWifi(); + mNetwork = static_cast(new AhoyWifi()); #endif // ETHERNET mNetwork->setup(mConfig, &mTimestamp, [this](bool gotIp) { this->onNetwork(gotIp); }, [this](bool gotTime) { this->onNtpUpdate(gotTime); }); mNetwork->begin(); @@ -403,7 +403,8 @@ void app::tickSend(void) { for (uint8_t i = 0; i < MAX_NUM_INVERTERS; i++) { Inverter<> *iv = mSys.getInverterByPos(i); - sendIv(iv); + if(!sendIv(iv)) + notAvail = false; } if(mAllIvNotAvail != notAvail) @@ -415,22 +416,22 @@ void app::tickSend(void) { //----------------------------------------------------------------------------- bool app::sendIv(Inverter<> *iv) { - bool notAvail = true; if(NULL == iv) - return notAvail; + return true; if(!iv->config->enabled) - return notAvail; + return true; if(!iv->commEnabled) { DPRINT_IVID(DBG_INFO, iv->id); DBGPRINTLN(F("no communication to the inverter (night time)")); - return notAvail; + return true; } if(!iv->radio->isChipConnected()) - return notAvail; + return true; + bool notAvail = true; if(InverterStatus::OFF != iv->status) notAvail = false; diff --git a/src/app.h b/src/app.h index 8fe9420d..2fc37ea8 100644 --- a/src/app.h +++ b/src/app.h @@ -414,7 +414,7 @@ class app : public IApp, public ah::Scheduler { bool mShowRebootRequest = false; - AhoyNetwork *mNetwork; + AhoyNetwork *mNetwork = nullptr; WebType mWeb; RestApiType mApi; Protection *mProtection = nullptr; diff --git a/src/defines.h b/src/defines.h index ab7c860b..502568a8 100644 --- a/src/defines.h +++ b/src/defines.h @@ -13,7 +13,7 @@ //------------------------------------- #define VERSION_MAJOR 0 #define VERSION_MINOR 8 -#define VERSION_PATCH 102 +#define VERSION_PATCH 103 //------------------------------------- typedef struct { uint8_t ch; diff --git a/src/network/AhoyWifiEsp32.h b/src/network/AhoyWifiEsp32.h index 41956dfc..a3bbb9cf 100644 --- a/src/network/AhoyWifiEsp32.h +++ b/src/network/AhoyWifiEsp32.h @@ -68,16 +68,6 @@ class AhoyWifi : public AhoyNetwork { String getIp(void) override { return WiFi.localIP().toString(); } - - private: - void sortRSSI(int *sort, int n) { - for (int i = 0; i < n; i++) - sort[i] = i; - for (int i = 0; i < n; i++) - for (int j = i + 1; j < n; j++) - if (WiFi.RSSI(sort[j]) > WiFi.RSSI(sort[i])) - std::swap(sort[i], sort[j]); - } }; #endif /*ESP32 & !ETHERNET*/ diff --git a/src/publisher/pubMqtt.h b/src/publisher/pubMqtt.h index 2d393b8b..35dc2b71 100644 --- a/src/publisher/pubMqtt.h +++ b/src/publisher/pubMqtt.h @@ -251,8 +251,8 @@ class PubMqtt { void onConnect(bool sessionPreset) { DPRINTLN(DBG_INFO, F("MQTT connected")); - publish(subtopics[MQTT_VERSION], mVersion, true); - publish(subtopics[MQTT_DEVICE], mDevName, true); + publish(subtopics[MQTT_VERSION], mVersion, false); + publish(subtopics[MQTT_DEVICE], mDevName, false); publish(subtopics[MQTT_IP_ADDR], mApp->getIp().c_str(), true); tickerMinute(); publish(mLwtTopic.data(), mqttStr[MQTT_STR_LWT_CONN], true, false); diff --git a/src/publisher/pubMqttIvData.h b/src/publisher/pubMqttIvData.h index 6ddd63a9..cd212aa4 100644 --- a/src/publisher/pubMqttIvData.h +++ b/src/publisher/pubMqttIvData.h @@ -187,7 +187,6 @@ class PubMqttIvData { static_cast(mIv->getChannelFieldValue(CH0, FLD_FW_BUILD_MONTH_DAY, rec)), static_cast(mIv->getChannelFieldValue(CH0, FLD_FW_BUILD_HOUR_MINUTE, rec)), static_cast(mIv->getChannelFieldValue(CH0, FLD_BOOTLOADER_VER, rec))); - retained = true; } else if(InverterDevInform_Simple == mCmd) { snprintf(mSubTopic.data(), mSubTopic.size(), "%s/hardware", mIv->config->name); snprintf(mVal.data(), mVal.size(), "{\"part\":%d,\"version\":\"%d\",\"grid_profile_code\":%d,\"grid_profile_version\":%d}", @@ -195,7 +194,6 @@ class PubMqttIvData { static_cast(mIv->getChannelFieldValue(CH0, FLD_HW_VERSION, rec)), static_cast(mIv->getChannelFieldValue(CH0, FLD_GRID_PROFILE_CODE, rec)), static_cast(mIv->getChannelFieldValue(CH0, FLD_GRID_PROFILE_VERSION, rec))); - retained = true; } else { snprintf(mSubTopic.data(), mSubTopic.size(), "%s/ch%d/%s", mIv->config->name, rec->assign[mPos].ch, fields[rec->assign[mPos].fieldId]); snprintf(mVal.data(), mVal.size(), "%g", ah::round3(mIv->getValue(mPos, rec))); diff --git a/src/web/RestApi.h b/src/web/RestApi.h index a9756944..665a3333 100644 --- a/src/web/RestApi.h +++ b/src/web/RestApi.h @@ -166,7 +166,7 @@ class RestApi { #else DynamicJsonDocument json(12000); // does this work? I have no ESP32 :-( #endif - DeserializationError err = deserializeJson(json, (const char *)mTmpBuf, mTmpSize); + DeserializationError err = deserializeJson(json, static_cast(mTmpBuf, mTmpSize)); json.shrinkToFit(); JsonObject obj = json.as(); From f105e25d3c040922956921c2750292cac8ce43b4 Mon Sep 17 00:00:00 2001 From: lumapu Date: Thu, 4 Apr 2024 01:47:24 +0200 Subject: [PATCH 08/20] 0.8.104 * fix reboot on inverter save (ESP32) #1559 * fix NRF and Ethernet #1506 --- scripts/applyPatches.py | 2 +- src/CHANGES.md | 4 ++++ src/hm/hmRadio.h | 10 +++++----- src/network/AhoyWifiEsp32.h | 2 +- src/platformio.ini | 35 +++++++++++++++++++---------------- src/web/html/setup.html | 26 ++++++++++++-------------- 6 files changed, 42 insertions(+), 37 deletions(-) diff --git a/scripts/applyPatches.py b/scripts/applyPatches.py index 57f1fa23..91b3498c 100644 --- a/scripts/applyPatches.py +++ b/scripts/applyPatches.py @@ -31,5 +31,5 @@ applyPatch("ESPAsyncWebServer-esphome", "../patches/AsyncWeb_Prometheus.patch") if env['PIOENV'][:13] == "opendtufusion": applyPatch("GxEPD2", "../patches/GxEPD2_SW_SPI.patch") -if (env['PIOENV'][:13] == "opendtufusion"): # or (env['PIOENV'][:13] == "esp32-wroom32"): +if (env['PIOENV'][:13] == "opendtufusion") or (env['PIOENV'][:5] == "esp32"): applyPatch("RF24", "../patches/RF24_Hal.patch") diff --git a/src/CHANGES.md b/src/CHANGES.md index 73c5c5d4..bb9bc7d5 100644 --- a/src/CHANGES.md +++ b/src/CHANGES.md @@ -1,5 +1,9 @@ # Development Changes +## 0.8.104 - 2024-04-04 +* fix reboot on inverter save (ESP32) #1559 +* fix NRF and Ethernet #1506 + ## 0.8.103 - 2024-04-02 * merge PR: fix: get refresh property from object #1552 * merge PR: fix typos and spelling in Github Issue template #1550 diff --git a/src/hm/hmRadio.h b/src/hm/hmRadio.h index eb44dd8c..f187d4fa 100644 --- a/src/hm/hmRadio.h +++ b/src/hm/hmRadio.h @@ -10,7 +10,7 @@ #include "SPI.h" #include "radio.h" #include "../config/config.h" -#if defined(CONFIG_IDF_TARGET_ESP32S3) && defined(SPI_HAL) +#if defined(SPI_HAL) #include "nrfHal.h" #endif @@ -34,7 +34,7 @@ class HmRadio : public Radio { HmRadio() { mDtuSn = DTU_SN; mIrqRcvd = false; - #if defined(CONFIG_IDF_TARGET_ESP32S3) && defined(SPI_HAL) + #if defined(SPI_HAL) //mNrf24.reset(new RF24()); #else mNrf24.reset(new RF24(CE_PIN, CS_PIN, SPI_SPEED)); @@ -55,7 +55,7 @@ class HmRadio : public Radio { mDtuRadioId = ((uint64_t)(((mDtuSn >> 24) & 0xFF) | ((mDtuSn >> 8) & 0xFF00) | ((mDtuSn << 8) & 0xFF0000) | ((mDtuSn << 24) & 0xFF000000)) << 8) | 0x01; #ifdef ESP32 - #if defined(CONFIG_IDF_TARGET_ESP32S3) && defined(SPI_HAL) + #if defined(SPI_HAL) mNrfHal.init(mosi, miso, sclk, cs, ce, SPI_SPEED); mNrf24.reset(new RF24(&mNrfHal)); #else @@ -72,7 +72,7 @@ class HmRadio : public Radio { mSpi->begin(); #endif - #if defined(CONFIG_IDF_TARGET_ESP32S3) && defined(SPI_HAL) + #if defined(SPI_HAL) mNrf24->begin(); #else mNrf24->begin(mSpi.get(), ce, cs); @@ -432,7 +432,7 @@ class HmRadio : public Radio { std::unique_ptr mSpi; std::unique_ptr mNrf24; - #if defined(CONFIG_IDF_TARGET_ESP32S3) && defined(SPI_HAL) + #if defined(SPI_HAL) nrfHal mNrfHal; #endif Inverter<> *mLastIv = NULL; diff --git a/src/network/AhoyWifiEsp32.h b/src/network/AhoyWifiEsp32.h index a3bbb9cf..6ccb077a 100644 --- a/src/network/AhoyWifiEsp32.h +++ b/src/network/AhoyWifiEsp32.h @@ -58,7 +58,7 @@ class AhoyWifi : public AhoyNetwork { mConnected = true; ah::welcome(WiFi.localIP().toString(), F("Station")); MDNS.begin(mConfig->sys.deviceName); - MDNS.addServiceTxt("http", "tcp", "path", "/"); + //MDNS.addServiceTxt("http", "tcp", "path", "/"); mOnNetworkCB(true); } break; diff --git a/src/platformio.ini b/src/platformio.ini index cde08cb1..a831f7c2 100644 --- a/src/platformio.ini +++ b/src/platformio.ini @@ -148,17 +148,18 @@ monitor_filters = esp8266_exception_decoder [env:esp32-wroom32-minimal] -platform = espressif32@6.5.0 +platform = espressif32@6.6.0 board = lolin_d32 build_flags = ${env.build_flags} - -DUSE_HSPI_FOR_EPD + -DSPI_HAL monitor_filters = esp32_exception_decoder [env:esp32-wroom32] -platform = espressif32@6.5.0 +platform = espressif32@6.6.0 board = lolin_d32 build_flags = ${env:esp32-wroom32-minimal.build_flags} + -DUSE_HSPI_FOR_EPD -DENABLE_MQTT -DPLUGIN_DISPLAY -DENABLE_HISTORY @@ -166,7 +167,7 @@ monitor_filters = esp32_exception_decoder [env:esp32-wroom32-de] -platform = espressif32@6.5.0 +platform = espressif32@6.6.0 board = lolin_d32 build_flags = ${env:esp32-wroom32.build_flags} -DLANG_DE @@ -174,7 +175,7 @@ monitor_filters = esp32_exception_decoder [env:esp32-wroom32-prometheus] -platform = espressif32@6.5.0 +platform = espressif32@6.6.0 board = lolin_d32 build_flags = ${env:esp32-wroom32.build_flags} -DENABLE_PROMETHEUS_EP @@ -182,7 +183,7 @@ monitor_filters = esp32_exception_decoder [env:esp32-wroom32-prometheus-de] -platform = espressif32@6.5.0 +platform = espressif32@6.6.0 board = lolin_d32 build_flags = ${env:esp32-wroom32-prometheus.build_flags} -DLANG_DE @@ -199,7 +200,7 @@ build_flags = ${env:esp32-wroom32.build_flags} -DDEF_ETH_MISO_PIN=12 -DDEF_ETH_MOSI_PIN=13 -DDEF_ETH_IRQ_PIN=4 - -DDEF_ETH_RST_PIN=2 + -DDEF_ETH_RST_PIN=255 -DDEF_NRF_CS_PIN=5 -DDEF_NRF_CE_PIN=17 -DDEF_NRF_IRQ_PIN=16 @@ -218,10 +219,11 @@ monitor_filters = esp32_exception_decoder [env:esp32-s2-mini] -platform = espressif32@6.5.0 +platform = espressif32@6.6.0 board = lolin_s2_mini build_flags = ${env.build_flags} -DUSE_HSPI_FOR_EPD + -DSPI_HAL -DENABLE_MQTT -DPLUGIN_DISPLAY -DENABLE_HISTORY @@ -240,7 +242,7 @@ monitor_filters = esp32_exception_decoder [env:esp32-s2-mini-de] -platform = espressif32@6.5.0 +platform = espressif32@6.6.0 board = lolin_s2_mini build_flags = ${env:esp32-s2-mini.build_flags} -DLANG_DE @@ -248,10 +250,11 @@ monitor_filters = esp32_exception_decoder [env:esp32-c3-mini] -platform = espressif32@6.5.0 +platform = espressif32@6.6.0 board = lolin_c3_mini build_flags = ${env.build_flags} -DUSE_HSPI_FOR_EPD + -DSPI_HAL -DENABLE_MQTT -DPLUGIN_DISPLAY -DENABLE_HISTORY @@ -270,7 +273,7 @@ monitor_filters = esp32_exception_decoder [env:esp32-c3-mini-de] -platform = espressif32@6.5.0 +platform = espressif32@6.6.0 board = lolin_c3_mini build_flags = ${env:esp32-c3-mini.build_flags} -DLANG_DE @@ -278,7 +281,7 @@ monitor_filters = esp32_exception_decoder [env:opendtufusion-minimal] -platform = espressif32@6.5.0 +platform = espressif32@6.6.0 board = esp32-s3-devkitc-1 upload_protocol = esp-builtin build_flags = ${env.build_flags} @@ -303,7 +306,7 @@ monitor_filters = esp32_exception_decoder, colorize [env:opendtufusion] -platform = espressif32@6.5.0 +platform = espressif32@6.6.0 board = esp32-s3-devkitc-1 upload_protocol = esp-builtin build_flags = ${env:opendtufusion-minimal.build_flags} @@ -314,7 +317,7 @@ monitor_filters = esp32_exception_decoder, colorize [env:opendtufusion-de] -platform = espressif32@6.5.0 +platform = espressif32@6.6.0 board = esp32-s3-devkitc-1 upload_protocol = esp-builtin build_flags = ${env:opendtufusion.build_flags} @@ -323,7 +326,7 @@ monitor_filters = esp32_exception_decoder, colorize [env:opendtufusion-ethernet] -platform = espressif32@6.5.0 +platform = espressif32@6.6.0 board = esp32-s3-devkitc-1 upload_protocol = esp-builtin build_flags = ${env:opendtufusion-minimal.build_flags} @@ -342,7 +345,7 @@ monitor_filters = esp32_exception_decoder, colorize [env:opendtufusion-ethernet-de] -platform = espressif32@6.5.0 +platform = espressif32@6.6.0 board = esp32-s3-devkitc-1 upload_protocol = esp-builtin build_flags = ${env:opendtufusion-ethernet.build_flags} diff --git a/src/web/html/setup.html b/src/web/html/setup.html index 51d48f7c..122f5427 100644 --- a/src/web/html/setup.html +++ b/src/web/html/setup.html @@ -52,14 +52,18 @@
WiFi -
{#AP_PWD}
+ +
SSID
- +
+
+ {#SCAN_WIFI} +
{#SSID_HIDDEN}
@@ -69,6 +73,7 @@
{#PASSWORD}
+
{#STATIC_IP} @@ -652,9 +657,14 @@ } function parseSys(obj) { + /*IF_ETHERNET*/ + for(var i of [["device", "device_name"], ["ap_pwd", "ap_pwd"]]) + document.getElementsByName(i[0])[0].value = obj[i[1]]; + /*ELSE*/ for(var i of [["device", "device_name"], ["ssid", "ssid"], ["ap_pwd", "ap_pwd"]]) document.getElementsByName(i[0])[0].value = obj[i[1]]; document.getElementsByName("hidd")[0].checked = obj["hidd"]; + /*ENDIF_ETHERNET*/ document.getElementsByName("darkMode")[0].checked = obj["dark_mode"]; document.getElementsByName("schedReboot")[0].checked = obj["sched_reboot"]; e = document.getElementsByName("adminpwd")[0]; @@ -1288,18 +1298,6 @@ } } - function listNetworks(root) { - var s = document.getElementById("networks"); - selDelAllOpt(s); - if(root["networks"].length > 0) { - s.appendChild(opt("-1", "{#NETWORK_PLEASE_SELECT}")); - for(i = 0; i < root["networks"].length; i++) { - s.appendChild(opt(root["networks"][i]["ssid"], root["networks"][i]["ssid"] + " (" + root["networks"][i]["rssi"] + " dBm)")); - } - } else - s.appendChild(opt("-1", "{#NO_NETWORK_FOUND}")); - } - getAjax("/api/setup", parse); From 5a3228853664a3697135054a5ac685b246938fef Mon Sep 17 00:00:00 2001 From: lumapu Date: Thu, 4 Apr 2024 01:49:56 +0200 Subject: [PATCH 09/20] 0.8.104 --- src/defines.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/defines.h b/src/defines.h index 502568a8..d551ee8a 100644 --- a/src/defines.h +++ b/src/defines.h @@ -13,7 +13,7 @@ //------------------------------------- #define VERSION_MAJOR 0 #define VERSION_MINOR 8 -#define VERSION_PATCH 103 +#define VERSION_PATCH 104 //------------------------------------- typedef struct { uint8_t ch; From 29adc76936b12a2250ef3c0443a444a85f8c1195 Mon Sep 17 00:00:00 2001 From: lumapu Date: Fri, 5 Apr 2024 00:34:52 +0200 Subject: [PATCH 10/20] 0.8.105 * cleanup of `defines.h` --- scripts/convertHtml.py | 11 ++++++++ src/CHANGES.md | 3 ++ src/config/settings.h | 15 +++++++++- src/defines.h | 62 +---------------------------------------- src/hm/hmDefines.h | 35 +++++++++++++++++++++++ src/publisher/pubMqtt.h | 4 +++ 6 files changed, 68 insertions(+), 62 deletions(-) diff --git a/scripts/convertHtml.py b/scripts/convertHtml.py index 026c28da..9a83d081 100644 --- a/scripts/convertHtml.py +++ b/scripts/convertHtml.py @@ -27,11 +27,22 @@ def getFlagsOfEnv(env): elif len(flags[i]) > 0: build_flags = build_flags + [flags[i]] +def parseDefinesH(): + global build_flags + pattern = r'^\s*#\s*define\s+(\w+)' + + with open("defines.h", "r") as f: + for line in f: + match = re.match(pattern, line) + if match: + build_flags += [match.group(1)] + def get_build_flags(): getFlagsOfEnv("env:" + env['PIOENV']) config = configparser.ConfigParser() config.read('platformio.ini') + parseDefinesH() # translate board board = config["env:" + env['PIOENV']]['board'] diff --git a/src/CHANGES.md b/src/CHANGES.md index bb9bc7d5..a6f16b50 100644 --- a/src/CHANGES.md +++ b/src/CHANGES.md @@ -1,5 +1,8 @@ # Development Changes +## 0.8.105 - 2024-04-05 +* cleanup of `defines.h` + ## 0.8.104 - 2024-04-04 * fix reboot on inverter save (ESP32) #1559 * fix NRF and Ethernet #1506 diff --git a/src/config/settings.h b/src/config/settings.h index 8f20ba8f..2d1d2229 100644 --- a/src/config/settings.h +++ b/src/config/settings.h @@ -33,7 +33,6 @@ #define CONFIG_VERSION 11 - #define PROT_MASK_INDEX 0x0001 #define PROT_MASK_LIVE 0x0002 #define PROT_MASK_SERIAL 0x0004 @@ -55,6 +54,20 @@ #define DEF_PROT_MQTT 0x0000 +#define SSID_LEN 32 +#define PWD_LEN 64 +#define DEVNAME_LEN 16 +#define NTP_ADDR_LEN 32 // DNS Name + +#define MQTT_ADDR_LEN 64 // DNS Name +#define MQTT_CLIENTID_LEN 22 // number of chars is limited to 23 up to v3.1 of MQTT +#define MQTT_USER_LEN 65 // there is another byte necessary for \0 +#define MQTT_PWD_LEN 65 +#define MQTT_TOPIC_LEN 65 + +#define MQTT_MAX_PACKET_SIZE 384 + + typedef struct { uint8_t ip[4]; // ip address uint8_t mask[4]; // sub mask diff --git a/src/defines.h b/src/defines.h index d551ee8a..f3079aff 100644 --- a/src/defines.h +++ b/src/defines.h @@ -13,7 +13,7 @@ //------------------------------------- #define VERSION_MAJOR 0 #define VERSION_MINOR 8 -#define VERSION_PATCH 104 +#define VERSION_PATCH 105 //------------------------------------- typedef struct { uint8_t ch; @@ -23,41 +23,6 @@ typedef struct { uint16_t millis; } packet_t; -typedef enum { - InverterDevInform_Simple = 0, // 0x00 - InverterDevInform_All = 1, // 0x01 - GridOnProFilePara = 2, // 0x02 - HardWareConfig = 3, // 0x03 - SimpleCalibrationPara = 4, // 0x04 - SystemConfigPara = 5, // 0x05 - RealTimeRunData_Debug = 11, // 0x0b - RealTimeRunData_Reality = 12, // 0x0c - RealTimeRunData_A_Phase = 13, // 0x0d - RealTimeRunData_B_Phase = 14, // 0x0e - RealTimeRunData_C_Phase = 15, // 0x0f - AlarmData = 17, // 0x11, Alarm data - all unsent alarms - AlarmUpdate = 18, // 0x12, Alarm data - all pending alarms - RecordData = 19, // 0x13 - InternalData = 20, // 0x14 - GetLossRate = 21, // 0x15 - GetSelfCheckState = 30, // 0x1e - InitDataState = 0xff -} InfoCmdType; - -typedef enum { - TurnOn = 0, // 0x00 - TurnOff = 1, // 0x01 - Restart = 2, // 0x02 - Lock = 3, // 0x03 - Unlock = 4, // 0x04 - ActivePowerContr = 11, // 0x0b - ReactivePowerContr = 12, // 0x0c - PFSet = 13, // 0x0d - CleanState_LockAndAlarm = 20, // 0x14 - SelfInspection = 40, // 0x28, self-inspection of grid-connected protection files - Init = 0xff -} DevControlCmdType; - typedef enum { AbsolutNonPersistent = 0UL, // 0x0000 RelativNonPersistent = 1UL, // 0x0001 @@ -70,13 +35,6 @@ union serial_u { uint8_t b[8]; }; -#define MIN_SERIAL_INTERVAL 2 // 5 -#define MIN_SEND_INTERVAL 15 -#define MIN_MQTT_INTERVAL 60 - - -enum {MQTT_STATUS_OFFLINE = 0, MQTT_STATUS_PARTIAL, MQTT_STATUS_ONLINE}; - enum { DISP_TYPE_T0_NONE = 0, DISP_TYPE_T1_SSD1306_128X64 = 1, @@ -88,24 +46,6 @@ enum { DISP_TYPE_T10_EPAPER = 10 }; - -//------------------------------------- -// EEPROM -//------------------------------------- -#define SSID_LEN 32 -#define PWD_LEN 64 -#define DEVNAME_LEN 16 -#define NTP_ADDR_LEN 32 // DNS Name - -#define MQTT_ADDR_LEN 64 // DNS Name -#define MQTT_CLIENTID_LEN 22 // number of chars is limited to 23 up to v3.1 of MQTT -#define MQTT_USER_LEN 65 // there is another byte necessary for \0 -#define MQTT_PWD_LEN 65 -#define MQTT_TOPIC_LEN 65 - -#define MQTT_MAX_PACKET_SIZE 384 - - typedef struct { uint32_t rxFail; uint32_t rxFailNoAnswer; diff --git a/src/hm/hmDefines.h b/src/hm/hmDefines.h index 6ba92774..1dc3148d 100644 --- a/src/hm/hmDefines.h +++ b/src/hm/hmDefines.h @@ -9,6 +9,41 @@ #include "../utils/dbg.h" #include +typedef enum { + InverterDevInform_Simple = 0, // 0x00 + InverterDevInform_All = 1, // 0x01 + GridOnProFilePara = 2, // 0x02 + HardWareConfig = 3, // 0x03 + SimpleCalibrationPara = 4, // 0x04 + SystemConfigPara = 5, // 0x05 + RealTimeRunData_Debug = 11, // 0x0b + RealTimeRunData_Reality = 12, // 0x0c + RealTimeRunData_A_Phase = 13, // 0x0d + RealTimeRunData_B_Phase = 14, // 0x0e + RealTimeRunData_C_Phase = 15, // 0x0f + AlarmData = 17, // 0x11, Alarm data - all unsent alarms + AlarmUpdate = 18, // 0x12, Alarm data - all pending alarms + RecordData = 19, // 0x13 + InternalData = 20, // 0x14 + GetLossRate = 21, // 0x15 + GetSelfCheckState = 30, // 0x1e + InitDataState = 0xff +} InfoCmdType; + +typedef enum { + TurnOn = 0, // 0x00 + TurnOff = 1, // 0x01 + Restart = 2, // 0x02 + Lock = 3, // 0x03 + Unlock = 4, // 0x04 + ActivePowerContr = 11, // 0x0b + ReactivePowerContr = 12, // 0x0c + PFSet = 13, // 0x0d + CleanState_LockAndAlarm = 20, // 0x14 + SelfInspection = 40, // 0x28, self-inspection of grid-connected protection files + Init = 0xff +} DevControlCmdType; + // inverter generations enum {IV_MI = 0, IV_HM, IV_HMS, IV_HMT, IV_UNKNOWN}; const char* const generationNames[] = {"MI", "HM", "HMS", "HMT", "UNKNOWN"}; diff --git a/src/publisher/pubMqtt.h b/src/publisher/pubMqtt.h index 35dc2b71..2ba8ac1a 100644 --- a/src/publisher/pubMqtt.h +++ b/src/publisher/pubMqtt.h @@ -602,6 +602,10 @@ class PubMqtt { mLastAnyAvail = anyAvail; } + private: + enum {MQTT_STATUS_OFFLINE = 0, MQTT_STATUS_PARTIAL, MQTT_STATUS_ONLINE}; + + private: espMqttClient mClient; cfgMqtt_t *mCfgMqtt = nullptr; IApp *mApp; From da34e737c6453581d714f54afcc04e81ed72617e Mon Sep 17 00:00:00 2001 From: lumapu Date: Fri, 5 Apr 2024 00:49:27 +0200 Subject: [PATCH 11/20] 0.8.105 * fix compile of esp32-minimal --- src/CHANGES.md | 1 + src/plugins/Display/Display_ePaper.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/CHANGES.md b/src/CHANGES.md index a6f16b50..48534a7f 100644 --- a/src/CHANGES.md +++ b/src/CHANGES.md @@ -2,6 +2,7 @@ ## 0.8.105 - 2024-04-05 * cleanup of `defines.h` +* fix compile of esp32-minimal ## 0.8.104 - 2024-04-04 * fix reboot on inverter save (ESP32) #1559 diff --git a/src/plugins/Display/Display_ePaper.cpp b/src/plugins/Display/Display_ePaper.cpp index 6d9d929e..1b52703e 100644 --- a/src/plugins/Display/Display_ePaper.cpp +++ b/src/plugins/Display/Display_ePaper.cpp @@ -39,7 +39,7 @@ void DisplayEPaper::init(uint8_t type, uint8_t _CS, uint8_t _DC, uint8_t _RST, u #if defined(ESP32) && defined(USE_HSPI_FOR_EPD) hspi.begin(_SCK, _BUSY, _MOSI, _CS); _display->epd2.selectSPI(hspi, SPISettings(spiClk, MSBFIRST, SPI_MODE0)); -#elif defined(ESP32) +#elif defined(ESP32) && defined(PLUGIN_DISPLAY) _display->epd2.init(_SCK, _MOSI, 115200, true, 20, false); #endif _display->init(115200, true, 20, false); From 2d19138463b3b6b81fb4b21bb0c01d97c221f13c Mon Sep 17 00:00:00 2001 From: lumapu Date: Fri, 5 Apr 2024 23:38:28 +0200 Subject: [PATCH 12/20] 0.8.106 * fix bootloop with CMT and NRF on ESP32 #1566 #1562 --- src/CHANGES.md | 3 ++ src/app.cpp | 7 ++-- src/app.h | 4 +-- src/hm/{hmRadio.h => NrfRadio.h} | 61 ++++++++++++++++++++------------ src/hm/hmInverter.h | 2 +- src/hm/radio.h | 2 +- src/hms/cmt2300a.h | 4 +-- src/hms/hmsRadio.h | 8 ++--- src/plugins/Display/Display.h | 10 +++--- src/web/RestApi.h | 4 +-- 10 files changed, 61 insertions(+), 44 deletions(-) rename src/hm/{hmRadio.h => NrfRadio.h} (92%) diff --git a/src/CHANGES.md b/src/CHANGES.md index 48534a7f..bc4eb51f 100644 --- a/src/CHANGES.md +++ b/src/CHANGES.md @@ -1,5 +1,8 @@ # Development Changes +## 0.8.106 - 2024-04-05 +* fix bootloop with CMT and NRF on ESP32 #1566 #1562 + ## 0.8.105 - 2024-04-05 * cleanup of `defines.h` * fix compile of esp32-minimal diff --git a/src/app.cpp b/src/app.cpp index f22e6906..0577aa8f 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -45,9 +45,7 @@ void app::setup() { esp_task_wdt_reset(); - if(mConfig->nrf.enabled) { - mNrfRadio.setup(&mConfig->serial.debug, &mConfig->serial.privacyLog, &mConfig->serial.printWholeTrace, mConfig->nrf.pinIrq, mConfig->nrf.pinCe, mConfig->nrf.pinCs, mConfig->nrf.pinSclk, mConfig->nrf.pinMosi, mConfig->nrf.pinMiso); - } + mNrfRadio.setup(&mConfig->serial.debug, &mConfig->serial.privacyLog, &mConfig->serial.printWholeTrace, &mConfig->nrf); #if defined(ESP32) if(mConfig->cmt.enabled) { mCmtRadio.setup(&mConfig->serial.debug, &mConfig->serial.privacyLog, &mConfig->serial.printWholeTrace, mConfig->cmt.pinSclk, mConfig->cmt.pinSdio, mConfig->cmt.pinCsb, mConfig->cmt.pinFcsb, mConfig->sys.region); @@ -141,8 +139,7 @@ void app::setup() { void app::loop(void) { esp_task_wdt_reset(); - if(mConfig->nrf.enabled) - mNrfRadio.loop(); + mNrfRadio.loop(); #if defined(ESP32) if(mConfig->cmt.enabled) diff --git a/src/app.h b/src/app.h index 2fc37ea8..49d78f56 100644 --- a/src/app.h +++ b/src/app.h @@ -17,7 +17,7 @@ #include "defines.h" #include "appInterface.h" #include "hm/hmSystem.h" -#include "hm/hmRadio.h" +#include "hm/NrfRadio.h" #if defined(ESP32) #include "hms/hmsRadio.h" #endif @@ -409,7 +409,7 @@ class app : public IApp, public ah::Scheduler { void notAvailChanged(void); HmSystemType mSys; - HmRadio<> mNrfRadio; + NrfRadio<> mNrfRadio; Communication mCommunication; bool mShowRebootRequest = false; diff --git a/src/hm/hmRadio.h b/src/hm/NrfRadio.h similarity index 92% rename from src/hm/hmRadio.h rename to src/hm/NrfRadio.h index f187d4fa..2b228fb6 100644 --- a/src/hm/hmRadio.h +++ b/src/hm/NrfRadio.h @@ -8,8 +8,9 @@ #include #include "SPI.h" -#include "radio.h" +#include "Radio.h" #include "../config/config.h" +#include "../config/settings.h" #if defined(SPI_HAL) #include "nrfHal.h" #endif @@ -28,10 +29,10 @@ const char* const rf24AmpPowerNames[] = {"MIN", "LOW", "HIGH", "MAX"}; //----------------------------------------------------------------------------- // HM Radio class //----------------------------------------------------------------------------- -template -class HmRadio : public Radio { +template +class NrfRadio : public Radio { public: - HmRadio() { + NrfRadio() { mDtuSn = DTU_SN; mIrqRcvd = false; #if defined(SPI_HAL) @@ -40,12 +41,18 @@ class HmRadio : public Radio { mNrf24.reset(new RF24(CE_PIN, CS_PIN, SPI_SPEED)); #endif } - ~HmRadio() {} + ~NrfRadio() {} - void setup(bool *serialDebug, bool *privacyMode, bool *printWholeTrace, uint8_t irq = IRQ_PIN, uint8_t ce = CE_PIN, uint8_t cs = CS_PIN, uint8_t sclk = SCLK_PIN, uint8_t mosi = MOSI_PIN, uint8_t miso = MISO_PIN) { - DPRINTLN(DBG_VERBOSE, F("hmRadio.h:setup")); + void setup(bool *serialDebug, bool *privacyMode, bool *printWholeTrace, cfgNrf24_t *cfg) { + DPRINTLN(DBG_VERBOSE, F("NrfRadio::setup")); - pinMode(irq, INPUT_PULLUP); + mCfg = cfg; + //uint8_t irq = IRQ_PIN, uint8_t ce = CE_PIN, uint8_t cs = CS_PIN, uint8_t sclk = SCLK_PIN, uint8_t mosi = MOSI_PIN, uint8_t miso = MISO_PIN + + if(!mCfg->enabled) + return; + + pinMode(mCfg->pinIrq, INPUT_PULLUP); mSerialDebug = serialDebug; mPrivacyMode = privacyMode; @@ -56,7 +63,7 @@ class HmRadio : public Radio { #ifdef ESP32 #if defined(SPI_HAL) - mNrfHal.init(mosi, miso, sclk, cs, ce, SPI_SPEED); + mNrfHal.init(mCfg->pinMosi, mCfg->pinMiso, mCfg->pinSclk, mCfg->pinCs, mCfg->pinCe, SPI_SPEED); mNrf24.reset(new RF24(&mNrfHal)); #else #if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3 @@ -64,7 +71,7 @@ class HmRadio : public Radio { #else mSpi.reset(new SPIClass(VSPI)); #endif - mSpi->begin(sclk, miso, mosi, cs); + mSpi->begin(mCfg->pinSclk, mCfg->pinMiso, mCfg->pinMosi, mCfg->pinCs); #endif #else //the old ESP82xx cannot freely place their SPI pins @@ -75,7 +82,7 @@ class HmRadio : public Radio { #if defined(SPI_HAL) mNrf24->begin(); #else - mNrf24->begin(mSpi.get(), ce, cs); + mNrf24->begin(mSpi.get(), mCfg->pinCe, mCfg->pinCs); #endif mNrf24->setRetries(3, 15); // wait 3*250 = 750us, 16 * 250us -> 4000us = 4ms @@ -99,21 +106,24 @@ class HmRadio : public Radio { } // returns true if communication is active - bool loop(void) override { + void loop(void) { + if(!mCfg->enabled) + return; + if (!mIrqRcvd && !mNRFisInRX) - return false; // first quick check => nothing to do at all here + return; // first quick check => nothing to do at all here if(NULL == mLastIv) // prevent reading on NULL object! - return false; + return; if(!mIrqRcvd) { // no news from nRF, check timers if ((millis() - mTimeslotStart) < innerLoopTimeout) - return true; // nothing to do, still waiting + return; // nothing to do, still waiting if (mRadioWaitTime.isTimeout()) { // timeout reached! mNRFisInRX = false; rx_ready = false; - return false; + return; } // otherwise switch to next RX channel @@ -132,7 +142,7 @@ class HmRadio : public Radio { mNrf24->setChannel(mRfChLst[tempRxChIdx]); isRxInit = false; - return true; // communicating, but changed RX channel + return; // communicating, but changed RX channel } else { // here we got news from the nRF mIrqRcvd = false; @@ -145,7 +155,7 @@ class HmRadio : public Radio { if(mNRFisInRX) { DPRINTLN(DBG_WARN, F("unexpected tx irq!")); - return false; + return; } mNRFisInRX = true; @@ -181,18 +191,23 @@ class HmRadio : public Radio { } } rx_ready = false; // reset - return mNRFisInRX; + return; } } - return false; + return; } bool isChipConnected(void) const override { + if(!mCfg->enabled) + return false; return mNrf24->isChipConnected(); } void sendControlPacket(Inverter<> *iv, uint8_t cmd, uint16_t *data, bool isRetransmit) override { + if(!mCfg->enabled) + return; + DPRINT_IVID(DBG_INFO, iv->id); DBGPRINT(F("sendControlPacket cmd: ")); DBGHEXLN(cmd); @@ -279,13 +294,14 @@ class HmRadio : public Radio { } uint8_t getDataRate(void) const { - if(!mNrf24->isChipConnected()) + if(!isChipConnected()) return 3; // unknown return mNrf24->getDataRate(); } bool isPVariant(void) const { - return mNrf24->isPVariant(); + if(!isChipConnected()) + return mNrf24->isPVariant(); } private: @@ -413,6 +429,7 @@ class HmRadio : public Radio { } uint64_t mDtuRadioId = 0ULL; + cfgNrf24_t *mCfg = nullptr; const uint8_t mRfChLst[RF_CHANNELS] = {03, 23, 40, 61, 75}; // channel List:2403, 2423, 2440, 2461, 2475MHz uint8_t mTxChIdx = 0; uint8_t mRxChIdx = 0; diff --git a/src/hm/hmInverter.h b/src/hm/hmInverter.h index 1d7e6620..9053c19f 100644 --- a/src/hm/hmInverter.h +++ b/src/hm/hmInverter.h @@ -22,7 +22,7 @@ #include #include "../config/settings.h" -#include "radio.h" +#include "Radio.h" /** * For values which are of interest and not transmitted by the inverter can be * calculated automatically. diff --git a/src/hm/radio.h b/src/hm/radio.h index 31643980..12e80850 100644 --- a/src/hm/radio.h +++ b/src/hm/radio.h @@ -33,7 +33,7 @@ class Radio { virtual uint16_t getBaseFreqMhz() { return 0; } virtual uint16_t getBootFreqMhz() { return 0; } virtual std::pair getFreqRangeMhz(void) { return std::make_pair(0, 0); } - virtual bool loop(void) = 0; + virtual void loop(void) = 0; Radio() : mTxBuf{} {} diff --git a/src/hms/cmt2300a.h b/src/hms/cmt2300a.h index 23911b15..ed3aab54 100644 --- a/src/hms/cmt2300a.h +++ b/src/hms/cmt2300a.h @@ -6,7 +6,7 @@ #ifndef __CMT2300A_H__ #define __CMT2300A_H__ -#if defined(CONFIG_IDF_TARGET_ESP32S3) && defined(SPI_HAL) +#if defined(SPI_HAL) #include "cmtHal.h" #else #include "esp32_3wSpi.h" @@ -545,7 +545,7 @@ class Cmt2300a { } private: - #if defined(CONFIG_IDF_TARGET_ESP32S3) && defined(SPI_HAL) + #if defined(SPI_HAL) cmtHal mSpi; #else esp32_3wSpi mSpi; diff --git a/src/hms/hmsRadio.h b/src/hms/hmsRadio.h index 54975197..4b043ae2 100644 --- a/src/hms/hmsRadio.h +++ b/src/hms/hmsRadio.h @@ -7,7 +7,7 @@ #define __HMS_RADIO_H__ #include "cmt2300a.h" -#include "../hm/radio.h" +#include "../hm/Radio.h" //#define CMT_SWITCH_CHANNEL_CYCLE 5 @@ -24,16 +24,16 @@ class CmtRadio : public Radio { mTxBuf.fill(0); } - bool loop() override { + void loop() override { mCmt.loop(); if((!mIrqRcvd) && (!mRqstGetRx)) - return false; + return; getRx(); if(CmtStatus::SUCCESS == mCmt.goRx()) { mIrqRcvd = false; mRqstGetRx = false; } - return false; + return; } bool isChipConnected(void) const override { diff --git a/src/plugins/Display/Display.h b/src/plugins/Display/Display.h index e263d667..0ce1522c 100644 --- a/src/plugins/Display/Display.h +++ b/src/plugins/Display/Display.h @@ -7,7 +7,7 @@ #include #include "../../hm/hmSystem.h" -#include "../../hm/hmRadio.h" +#include "../../hm/NrfRadio.h" #include "../../utils/helper.h" #include "../plugin_lang.h" #include "Display_Mono.h" @@ -25,9 +25,9 @@ class Display { mMono = NULL; } - void setup(IApp *app, display_t *cfg, HMSYSTEM *sys, RADIO *hmradio, RADIO *hmsradio, uint32_t *utcTs) { + void setup(IApp *app, display_t *cfg, HMSYSTEM *sys, RADIO *nrfRadio, RADIO *hmsradio, uint32_t *utcTs) { mApp = app; - mHmRadio = hmradio; + mNrfRadio = nrfRadio; mHmsRadio = hmsradio; mCfg = cfg; mSys = sys; @@ -149,7 +149,7 @@ class Display { mDisplayData.totalYieldDay = totalYieldDay; mDisplayData.totalYieldTotal = totalYieldTotal; bool nrf_en = mApp->getNrfEnabled(); - bool nrf_ok = nrf_en && mHmRadio->isChipConnected(); + bool nrf_ok = nrf_en && mNrfRadio->isChipConnected(); #if defined(ESP32) bool cmt_en = mApp->getCmtEnabled(); bool cmt_ok = cmt_en && mHmsRadio->isChipConnected(); @@ -231,7 +231,7 @@ class Display { uint32_t *mUtcTs = nullptr; display_t *mCfg = nullptr; HMSYSTEM *mSys = nullptr; - RADIO *mHmRadio = nullptr; + RADIO *mNrfRadio = nullptr; RADIO *mHmsRadio = nullptr; uint16_t mRefreshCycle = 0; diff --git a/src/web/RestApi.h b/src/web/RestApi.h index 665a3333..fdc54fa4 100644 --- a/src/web/RestApi.h +++ b/src/web/RestApi.h @@ -40,7 +40,7 @@ class RestApi { mApp = app; mSrv = srv; mSys = sys; - mRadioNrf = (HmRadio<>*)mApp->getRadioObj(true); + mRadioNrf = (NrfRadio<>*)mApp->getRadioObj(true); #if defined(ESP32) mRadioCmt = (CmtRadio<>*)mApp->getRadioObj(false); #endif @@ -1112,7 +1112,7 @@ class RestApi { private: IApp *mApp = nullptr; HMSYSTEM *mSys = nullptr; - HmRadio<> *mRadioNrf = nullptr; + NrfRadio<> *mRadioNrf = nullptr; #if defined(ESP32) CmtRadio<> *mRadioCmt = nullptr; #endif From 00fce38db9877a58bb1c2c0cb0d499937c1a5ec8 Mon Sep 17 00:00:00 2001 From: lumapu Date: Fri, 5 Apr 2024 23:59:46 +0200 Subject: [PATCH 13/20] 0.8.106 * possible fix of #1553 --- src/CHANGES.md | 1 + src/app.h | 2 +- src/defines.h | 2 +- src/hms/{hmsRadio.h => CmtRadio.h} | 0 src/hms/cmt2300a.h | 4 +--- 5 files changed, 4 insertions(+), 5 deletions(-) rename src/hms/{hmsRadio.h => CmtRadio.h} (100%) diff --git a/src/CHANGES.md b/src/CHANGES.md index bc4eb51f..23b671b4 100644 --- a/src/CHANGES.md +++ b/src/CHANGES.md @@ -2,6 +2,7 @@ ## 0.8.106 - 2024-04-05 * fix bootloop with CMT and NRF on ESP32 #1566 #1562 +* possible fix of #1553 ## 0.8.105 - 2024-04-05 * cleanup of `defines.h` diff --git a/src/app.h b/src/app.h index 49d78f56..8861cb5b 100644 --- a/src/app.h +++ b/src/app.h @@ -19,7 +19,7 @@ #include "hm/hmSystem.h" #include "hm/NrfRadio.h" #if defined(ESP32) -#include "hms/hmsRadio.h" +#include "hms/CmtRadio.h" #endif #if defined(ENABLE_MQTT) #include "publisher/pubMqtt.h" diff --git a/src/defines.h b/src/defines.h index f3079aff..10c78548 100644 --- a/src/defines.h +++ b/src/defines.h @@ -13,7 +13,7 @@ //------------------------------------- #define VERSION_MAJOR 0 #define VERSION_MINOR 8 -#define VERSION_PATCH 105 +#define VERSION_PATCH 106 //------------------------------------- typedef struct { uint8_t ch; diff --git a/src/hms/hmsRadio.h b/src/hms/CmtRadio.h similarity index 100% rename from src/hms/hmsRadio.h rename to src/hms/CmtRadio.h diff --git a/src/hms/cmt2300a.h b/src/hms/cmt2300a.h index ed3aab54..61b26894 100644 --- a/src/hms/cmt2300a.h +++ b/src/hms/cmt2300a.h @@ -248,14 +248,12 @@ class Cmt2300a { } CmtStatus tx(uint8_t buf[], uint8_t len) { - if(mTxPending) - return CmtStatus::ERR_TX_PENDING; - if(mInRxMode) { mInRxMode = false; if(!cmtSwitchStatus(CMT2300A_GO_STBY, CMT2300A_STA_STBY)) return CmtStatus::ERR_SWITCH_STATE; } + mTxPending = false; // safety mSpi.writeReg(CMT2300A_CUS_INT1_CTL, CMT2300A_INT_SEL_TX_DONE); From 4de26c8bc419cc4d8eaa85d8d7c62553a6c7c74e Mon Sep 17 00:00:00 2001 From: lumapu Date: Sat, 6 Apr 2024 01:37:06 +0200 Subject: [PATCH 14/20] 0.8.106 * change MqTT return value of power limit acknowledge from `boolean` to `float`. The value returned is the same as it was set to confirm reception (not the read back value) --- src/CHANGES.md | 1 + src/publisher/pubMqtt.h | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/CHANGES.md b/src/CHANGES.md index 23b671b4..9f2f020d 100644 --- a/src/CHANGES.md +++ b/src/CHANGES.md @@ -3,6 +3,7 @@ ## 0.8.106 - 2024-04-05 * fix bootloop with CMT and NRF on ESP32 #1566 #1562 * possible fix of #1553 +* change MqTT return value of power limit acknowledge from `boolean` to `float`. The value returned is the same as it was set to confirm reception (not the read back value) ## 0.8.105 - 2024-04-05 * cleanup of `defines.h` diff --git a/src/publisher/pubMqtt.h b/src/publisher/pubMqtt.h index 2ba8ac1a..91227c05 100644 --- a/src/publisher/pubMqtt.h +++ b/src/publisher/pubMqtt.h @@ -243,7 +243,8 @@ class PubMqtt { void setPowerLimitAck(Inverter<> *iv) { if (NULL != iv) { snprintf(mSubTopic.data(), mSubTopic.size(), "%s/%s", iv->config->name, subtopics[MQTT_ACK_PWR_LMT]); - publish(mSubTopic.data(), "true", true, true, QOS_2); + snprintf(mVal.data(), mVal.size(), "%.1f", iv->powerLimit[0]/10.0); + publish(mSubTopic.data(), mVal.data(), true, true, QOS_2); } } From 6a5643209a4118df2971a03248a046dc84c59e49 Mon Sep 17 00:00:00 2001 From: lumapu Date: Sat, 6 Apr 2024 01:39:21 +0200 Subject: [PATCH 15/20] 0.8.106 * change case of `radio.h` to `Radio.h` --- src/hm/{radio.h => Radio.h} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/hm/{radio.h => Radio.h} (100%) diff --git a/src/hm/radio.h b/src/hm/Radio.h similarity index 100% rename from src/hm/radio.h rename to src/hm/Radio.h From 435aa1748af556c914e1d8f1e6043dee8566f1a1 Mon Sep 17 00:00:00 2001 From: lumapu Date: Sat, 6 Apr 2024 01:45:02 +0200 Subject: [PATCH 16/20] 0.8.106 fix compile --- src/config/config.h | 2 +- src/hm/NrfRadio.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/config/config.h b/src/config/config.h index a4b84934..3dfac72e 100644 --- a/src/config/config.h +++ b/src/config/config.h @@ -145,7 +145,7 @@ #ifndef DEF_MOTION_SENSOR_PIN #define DEF_MOTION_SENSOR_PIN DEF_PIN_OFF #endif -#else +#else // ESP8266 #ifndef DEF_NRF_CS_PIN #define DEF_NRF_CS_PIN 15 #endif diff --git a/src/hm/NrfRadio.h b/src/hm/NrfRadio.h index 2b228fb6..21d0c676 100644 --- a/src/hm/NrfRadio.h +++ b/src/hm/NrfRadio.h @@ -38,7 +38,7 @@ class NrfRadio : public Radio { #if defined(SPI_HAL) //mNrf24.reset(new RF24()); #else - mNrf24.reset(new RF24(CE_PIN, CS_PIN, SPI_SPEED)); + mNrf24.reset(new RF24(DEF_NRF_CE_PIN, DEF_NRF_CS_PIN, SPI_SPEED)); #endif } ~NrfRadio() {} From 12b4251da9773427aea6afc809900dc870bc1192 Mon Sep 17 00:00:00 2001 From: lumapu Date: Mon, 8 Apr 2024 23:04:50 +0200 Subject: [PATCH 17/20] 0.8.107 * fix boot loop on `reboot on midnight` feature #1542, #1599, #1566, #1571 --- src/CHANGES.md | 3 +++ src/app.cpp | 46 +++++++++++++++++++++------------------------- src/app.h | 2 +- src/defines.h | 2 +- src/platformio.ini | 2 +- src/web/lang.json | 2 +- 6 files changed, 28 insertions(+), 29 deletions(-) diff --git a/src/CHANGES.md b/src/CHANGES.md index 9f2f020d..b22ae189 100644 --- a/src/CHANGES.md +++ b/src/CHANGES.md @@ -1,5 +1,8 @@ # Development Changes +## 0.8.107 - 2024-04-08 +* fix boot loop on `reboot on midnight` feature #1542, #1599, #1566, #1571 + ## 0.8.106 - 2024-04-05 * fix bootloop with CMT and NRF on ESP32 #1566 #1562 * possible fix of #1553 diff --git a/src/app.cpp b/src/app.cpp index 0577aa8f..d00a95c2 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -162,7 +162,7 @@ void app::onNetwork(bool gotIp) { ah::Scheduler::resetTicker(); regularTickers(); //reinstall regular tickers every(std::bind(&app::tickSend, this), mConfig->inst.sendInterval, "tSend"); - mMqttReconnect = true; + mTickerInstallOnce = true; mSunrise = 0; // needs to be set to 0, to reinstall sunrise and ivComm tickers! once(std::bind(&app::tickNtpUpdate, this), 2, "ntp2"); } @@ -200,40 +200,37 @@ void app::onNtpUpdate(bool gotTime) { mCalculatedTimezoneOffset = (int8_t)((mConfig->sun.lon >= 0 ? mConfig->sun.lon + 7.5 : mConfig->sun.lon - 7.5) / 15) * 3600; tickCalcSunrise(); } -} -//----------------------------------------------------------------------------- -void app::updateNtp(void) { - #if defined(ENABLE_MQTT) - if (mMqttReconnect && mMqttEnabled) { - mMqtt.tickerSecond(); - everySec(std::bind(&PubMqttType::tickerSecond, &mMqtt), "mqttS"); - everyMin(std::bind(&PubMqttType::tickerMinute, &mMqtt), "mqttM"); - } - #endif /*ENABLE_MQTT*/ + if (mTickerInstallOnce) { + mTickerInstallOnce = false; + #if defined(ENABLE_MQTT) + if (mMqttEnabled) { + mMqtt.tickerSecond(); + everySec(std::bind(&PubMqttType::tickerSecond, &mMqtt), "mqttS"); + everyMin(std::bind(&PubMqttType::tickerMinute, &mMqtt), "mqttM"); + } + #endif /*ENABLE_MQTT*/ - // only install schedulers once even if NTP wasn't successful in first loop - if (mMqttReconnect) { // @TODO: mMqttReconnect is variable which scope has changed if (mConfig->inst.rstValsNotAvail) everyMin(std::bind(&app::tickMinute, this), "tMin"); - uint32_t localTime = gTimezone.toLocal(mTimestamp); - uint32_t midTrig = gTimezone.toUTC(localTime - (localTime % 86400) + 86400); // next midnight local time - onceAt(std::bind(&app::tickMidnight, this), midTrig, "midNi"); + if(mNtpReceived) { + uint32_t localTime = gTimezone.toLocal(mTimestamp); + uint32_t midTrig = gTimezone.toUTC(localTime - (localTime % 86400) + 86400); // next midnight local time + onceAt(std::bind(&app::tickMidnight, this), midTrig, "midNi"); - if (mConfig->sys.schedReboot) { - uint32_t rebootTrig = gTimezone.toUTC(localTime - (localTime % 86400) + 86410); // reboot 10 secs after midnght - if (rebootTrig <= mTimestamp) { //necessary for times other than midnight to prevent reboot loop - rebootTrig += 86400; + if (mConfig->sys.schedReboot) { + uint32_t rebootTrig = gTimezone.toUTC(localTime - (localTime % 86400) + 86410); // reboot 10 secs after midnght + onceAt(std::bind(&app::tickReboot, this), rebootTrig, "midRe"); } - onceAt(std::bind(&app::tickReboot, this), rebootTrig, "midRe"); } } +} +//----------------------------------------------------------------------------- +void app::updateNtp(void) { if(mNtpReceived) onNtpUpdate(true); - - mMqttReconnect = false; } //----------------------------------------------------------------------------- @@ -249,8 +246,6 @@ void app::tickNtpUpdate(void) { updateNtp(); - mMqttReconnect = false; - once(std::bind(&app::tickNtpUpdate, this), nxtTrig, "ntp"); } @@ -548,6 +543,7 @@ void app::resetSystem(void) { mNetworkConnected = false; mNtpReceived = false; + mTickerInstallOnce = false; } //----------------------------------------------------------------------------- diff --git a/src/app.h b/src/app.h index 8861cb5b..70a1fde2 100644 --- a/src/app.h +++ b/src/app.h @@ -447,7 +447,7 @@ class app : public IApp, public ah::Scheduler { #if defined(ENABLE_MQTT) PubMqttType mMqtt; #endif /*ENABLE_MQTT*/ - bool mMqttReconnect = false; + bool mTickerInstallOnce = false; bool mMqttEnabled = false; // sun diff --git a/src/defines.h b/src/defines.h index 10c78548..60af67f6 100644 --- a/src/defines.h +++ b/src/defines.h @@ -13,7 +13,7 @@ //------------------------------------- #define VERSION_MAJOR 0 #define VERSION_MINOR 8 -#define VERSION_PATCH 106 +#define VERSION_PATCH 107 //------------------------------------- typedef struct { uint8_t ch; diff --git a/src/platformio.ini b/src/platformio.ini index a831f7c2..a6537040 100644 --- a/src/platformio.ini +++ b/src/platformio.ini @@ -301,7 +301,7 @@ build_flags = ${env.build_flags} -DDEF_LED1=17 -DLED_ACTIVE_HIGH -DARDUINO_USB_MODE=1 - #-DARDUINO_USB_CDC_ON_BOOT=1 + -DARDUINO_USB_CDC_ON_BOOT=1 monitor_filters = esp32_exception_decoder, colorize diff --git a/src/web/lang.json b/src/web/lang.json index 57ded1dd..c37e1d92 100644 --- a/src/web/lang.json +++ b/src/web/lang.json @@ -96,7 +96,7 @@ { "token": "TRY_TO_CONNECT", "en": "AhoyDTU is trying to connect to your WiFi", - "de": "AhoyDTU versucht eine Verindung mit deinem Netzwerk herzustellen" + "de": "AhoyDTU versucht eine Verbindung mit Deinem Netzwerk herzustellen" }, { "token": "CONNECTING", From 36b17b14ae13e0582144fdae9618b8861fb4dfb2 Mon Sep 17 00:00:00 2001 From: lumapu Date: Mon, 8 Apr 2024 23:10:11 +0200 Subject: [PATCH 18/20] 0.8.107 * fix German translation #1569 --- src/CHANGES.md | 1 + src/web/lang.json | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/CHANGES.md b/src/CHANGES.md index b22ae189..d1069c8c 100644 --- a/src/CHANGES.md +++ b/src/CHANGES.md @@ -2,6 +2,7 @@ ## 0.8.107 - 2024-04-08 * fix boot loop on `reboot on midnight` feature #1542, #1599, #1566, #1571 +* fix German translation #1569 ## 0.8.106 - 2024-04-05 * fix bootloop with CMT and NRF on ESP32 #1566 #1562 diff --git a/src/web/lang.json b/src/web/lang.json index c37e1d92..ff0062ee 100644 --- a/src/web/lang.json +++ b/src/web/lang.json @@ -6,7 +6,7 @@ { "token": "NAV_WIZARD", "en": "Setup Wizard", - "de": "Daten" + "de": "Einrichtungsassitent" }, { "token": "NAV_LIVE", @@ -81,7 +81,7 @@ { "token": "BTN_NEXT", "en": "next >>", - "de": "prüfen >>" + "de": "speichern >>" }, { "token": "BTN_REBOOT", From a677079681d3a899c668a8289cb668d81bddb508 Mon Sep 17 00:00:00 2001 From: lumapu Date: Tue, 9 Apr 2024 00:13:34 +0200 Subject: [PATCH 19/20] 0.8.107 * improved `Wizard` --- src/CHANGES.md | 1 + src/network/AhoyNetwork.h | 7 +++-- src/network/AhoyWifiAp.h | 1 + src/web/RestApi.h | 1 + src/web/html/wizard.html | 57 ++++++++++++++++++++++----------------- src/web/web.h | 1 + 6 files changed, 39 insertions(+), 29 deletions(-) diff --git a/src/CHANGES.md b/src/CHANGES.md index d1069c8c..61b6cc12 100644 --- a/src/CHANGES.md +++ b/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 diff --git a/src/network/AhoyNetwork.h b/src/network/AhoyNetwork.h index 55c5d193..c0ea55c2 100644 --- a/src/network/AhoyNetwork.h +++ b/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) { diff --git a/src/network/AhoyWifiAp.h b/src/network/AhoyWifiAp.h index ce2bbd1b..994af3de 100644 --- a/src/network/AhoyWifiAp.h +++ b/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; diff --git a/src/web/RestApi.h b/src/web/RestApi.h index fdc54fa4..1ed5d204 100644 --- a/src/web/RestApi.h +++ b/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) */ diff --git a/src/web/html/wizard.html b/src/web/html/wizard.html index 1fc8503c..a6a29bbb 100644 --- a/src/web/html/wizard.html +++ b/src/web/html/wizard.html @@ -4,7 +4,7 @@ {#NAV_WIZARD} {#HTML_HEADER} - +
@@ -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*/ + } diff --git a/src/web/web.h b/src/web/web.h index 4f93b905..e88aa813 100644 --- a/src/web/web.h +++ b/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)); From 668e3e667d89f879e64e37d9940d89995c71f5c3 Mon Sep 17 00:00:00 2001 From: lumapu Date: Tue, 9 Apr 2024 00:16:31 +0200 Subject: [PATCH 20/20] 0.8.107 * fix serial console flag --- src/platformio.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/platformio.ini b/src/platformio.ini index a6537040..a831f7c2 100644 --- a/src/platformio.ini +++ b/src/platformio.ini @@ -301,7 +301,7 @@ build_flags = ${env.build_flags} -DDEF_LED1=17 -DLED_ACTIVE_HIGH -DARDUINO_USB_MODE=1 - -DARDUINO_USB_CDC_ON_BOOT=1 + #-DARDUINO_USB_CDC_ON_BOOT=1 monitor_filters = esp32_exception_decoder, colorize