From 77914076604823bc0c4d6d4b3ddba07bbd1aa1a4 Mon Sep 17 00:00:00 2001 From: Sebastian Rothe Date: Thu, 11 Apr 2024 00:33:19 +0200 Subject: [PATCH 1/5] fix: add missing closing tag fix typo --- src/web/html/update.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/web/html/update.html b/src/web/html/update.html index 52ace5f1..ebdbb7ab 100644 --- a/src/web/html/update.html +++ b/src/web/html/update.html @@ -17,7 +17,7 @@
- {#DOWNLOADS} + {#DOWNLOADS}
From c58e29c6a908634eca44aea3586bbf9ab04972f8 Mon Sep 17 00:00:00 2001 From: lumapu Date: Thu, 11 Apr 2024 20:37:06 +0200 Subject: [PATCH 2/5] 0.8.110 * revert CMT2300A changes #1553 --- src/CHANGES.md | 3 +++ src/defines.h | 2 +- src/hms/cmt2300a.h | 4 +++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/CHANGES.md b/src/CHANGES.md index b1e93d32..29a3fb41 100644 --- a/src/CHANGES.md +++ b/src/CHANGES.md @@ -1,5 +1,8 @@ # Development Changes +## 0.8.110 - 2024-04-11 +* revert CMT2300A changes #1553 + ## 0.8.109 - 2024-04-09 * fix hal patch diff --git a/src/defines.h b/src/defines.h index 7e050bb4..e7eecc00 100644 --- a/src/defines.h +++ b/src/defines.h @@ -13,7 +13,7 @@ //------------------------------------- #define VERSION_MAJOR 0 #define VERSION_MINOR 8 -#define VERSION_PATCH 108 +#define VERSION_PATCH 110 //------------------------------------- typedef struct { uint8_t ch; diff --git a/src/hms/cmt2300a.h b/src/hms/cmt2300a.h index 61b26894..ed3aab54 100644 --- a/src/hms/cmt2300a.h +++ b/src/hms/cmt2300a.h @@ -248,12 +248,14 @@ 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 e76722ad335c2e6765549657a331491249ff858c Mon Sep 17 00:00:00 2001 From: lumapu Date: Thu, 11 Apr 2024 21:34:05 +0200 Subject: [PATCH 3/5] 0.8.110 * add disable retain flag #1582 --- src/CHANGES.md | 2 ++ src/config/settings.h | 4 ++++ src/publisher/pubMqtt.h | 3 +++ src/web/RestApi.h | 1 + src/web/html/setup.html | 9 +++++++-- src/web/lang.json | 5 +++++ src/web/web.h | 1 + 7 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/CHANGES.md b/src/CHANGES.md index 29a3fb41..1ad0ee1e 100644 --- a/src/CHANGES.md +++ b/src/CHANGES.md @@ -2,6 +2,8 @@ ## 0.8.110 - 2024-04-11 * revert CMT2300A changes #1553 +* merged PR: fix closing tag #1584 +* add disable retain flag #1582 ## 0.8.109 - 2024-04-09 * fix hal patch diff --git a/src/config/settings.h b/src/config/settings.h index 2d1d2229..e97519a1 100644 --- a/src/config/settings.h +++ b/src/config/settings.h @@ -165,6 +165,7 @@ typedef struct { char pwd[MQTT_PWD_LEN]; char topic[MQTT_TOPIC_LEN]; uint16_t interval; + bool enableRetain; } cfgMqtt_t; typedef struct { @@ -490,6 +491,7 @@ class settings { snprintf(mCfg.mqtt.pwd, MQTT_PWD_LEN, "%s", DEF_MQTT_PWD); snprintf(mCfg.mqtt.topic, MQTT_TOPIC_LEN, "%s", DEF_MQTT_TOPIC); mCfg.mqtt.interval = 0; // off + mCfg.mqtt.enableRetain = true; mCfg.inst.sendInterval = SEND_INTERVAL; mCfg.inst.rstYieldMidNight = false; @@ -746,6 +748,7 @@ class settings { obj[F("pwd")] = mCfg.mqtt.pwd; obj[F("topic")] = mCfg.mqtt.topic; obj[F("intvl")] = mCfg.mqtt.interval; + obj[F("retain")] = mCfg.mqtt.enableRetain; } else { getVal(obj, F("port"), &mCfg.mqtt.port); @@ -755,6 +758,7 @@ class settings { getChar(obj, F("clientId"), mCfg.mqtt.clientId, MQTT_CLIENTID_LEN); getChar(obj, F("pwd"), mCfg.mqtt.pwd, MQTT_PWD_LEN); getChar(obj, F("topic"), mCfg.mqtt.topic, MQTT_TOPIC_LEN); + getVal(obj, F("retain"), &mCfg.mqtt.enableRetain); } } diff --git a/src/publisher/pubMqtt.h b/src/publisher/pubMqtt.h index 91227c05..8506a87c 100644 --- a/src/publisher/pubMqtt.h +++ b/src/publisher/pubMqtt.h @@ -205,6 +205,9 @@ class PubMqtt { else snprintf(mTopic.data(), mTopic.size(), "%s", subTopic); + if(!mCfgMqtt->enableRetain) + retained = false; + mClient.publish(mTopic.data(), qos, retained, payload); yield(); mTxCnt++; diff --git a/src/web/RestApi.h b/src/web/RestApi.h index 1ed5d204..968ea0e8 100644 --- a/src/web/RestApi.h +++ b/src/web/RestApi.h @@ -710,6 +710,7 @@ class RestApi { obj[F("pwd")] = (strlen(mConfig->mqtt.pwd) > 0) ? F("{PWD}") : String(""); obj[F("topic")] = String(mConfig->mqtt.topic); obj[F("interval")] = String(mConfig->mqtt.interval); + obj[F("retain")] = (bool)mConfig->mqtt.enableRetain; } void getNtp(JsonObject obj) { diff --git a/src/web/html/setup.html b/src/web/html/setup.html index 122f5427..e0c1693a 100644 --- a/src/web/html/setup.html +++ b/src/web/html/setup.html @@ -246,6 +246,10 @@ +
+
{#RETAIN}
+
+
@@ -282,7 +286,7 @@
{#DISP_LUMINANCE}
-
+

{#DISP_PINOUT}

@@ -291,7 +295,7 @@

{#GRAPH_OPTIONS}

{#GRAPH_SHOW_RATIO}
-
+
@@ -922,6 +926,7 @@ function parseMqtt(obj) { for(var i of [["Addr", "broker"], ["Port", "port"], ["ClientId", "clientId"], ["User", "user"], ["Pwd", "pwd"], ["Topic", "topic"], ["Interval", "interval"]]) document.getElementsByName("mqtt"+i[0])[0].value = obj[i[1]]; + document.getElementsByName("retain")[0].checked = obj.retain } function parseNtp(obj) { diff --git a/src/web/lang.json b/src/web/lang.json index ff0062ee..42669e28 100644 --- a/src/web/lang.json +++ b/src/web/lang.json @@ -413,6 +413,11 @@ "en": "Send Inverter data in a fixed interval, even if there is no change. A value of '0' disables the fixed interval. The data is published once it was successfully received from inverter. (default: 0)", "de": "Wechselrichterdaten in fixem Intervall schicken, auch wenn es keine Änderung gab. Ein Wert von '0' deaktiviert das fixe Intervall, die Wechselrichterdaten werden übertragen, sobald neue zur Verfügung stehen. (Standard: 0)" }, + { + "token": "RETAIN", + "en": "enable retain flag", + "de": "'Retain Flag' aktivieren" + }, { "token": "DISPLAY_CONFIG", "en": "Display Config", diff --git a/src/web/web.h b/src/web/web.h index e88aa813..7b73fe9f 100644 --- a/src/web/web.h +++ b/src/web/web.h @@ -583,6 +583,7 @@ class Web { request->arg("mqttTopic").toCharArray(mConfig->mqtt.topic, MQTT_TOPIC_LEN); mConfig->mqtt.port = request->arg("mqttPort").toInt(); mConfig->mqtt.interval = request->arg("mqttInterval").toInt(); + mConfig->mqtt.enableRetain = (request->arg("retain") == "on"); // serial console mConfig->serial.debug = (request->arg("serDbg") == "on"); From 1f86e4cedb9a50c6a91896d36d66ec9af15c90df Mon Sep 17 00:00:00 2001 From: lumapu Date: Thu, 11 Apr 2024 23:12:32 +0200 Subject: [PATCH 4/5] 0.8.110 * improved `Wizard --- src/CHANGES.md | 2 ++ src/app.h | 6 +++++- src/appInterface.h | 3 +++ src/network/AhoyNetwork.h | 14 +++++++++----- src/network/AhoyWifiAp.h | 1 + src/network/AhoyWifiEsp32.h | 1 + src/web/RestApi.h | 4 +++- src/web/lang.h | 18 ++++++++++++++++++ src/web/lang.json | 2 +- 9 files changed, 43 insertions(+), 8 deletions(-) diff --git a/src/CHANGES.md b/src/CHANGES.md index 1ad0ee1e..8a41bd80 100644 --- a/src/CHANGES.md +++ b/src/CHANGES.md @@ -4,6 +4,8 @@ * revert CMT2300A changes #1553 * merged PR: fix closing tag #1584 * add disable retain flag #1582 +* fix German translation #1569 +* improved `Wizard` ## 0.8.109 - 2024-04-09 * fix hal patch diff --git a/src/app.h b/src/app.h index 70a1fde2..a7be0a55 100644 --- a/src/app.h +++ b/src/app.h @@ -168,7 +168,7 @@ class app : public IApp, public ah::Scheduler { #if !defined(ETHERNET) bool getAvailNetworks(JsonObject obj) override { - return mNetwork->getAvailNetworks(obj); + return mNetwork->getAvailNetworks(obj, this); } void setupStation(void) override { @@ -204,6 +204,10 @@ class app : public IApp, public ah::Scheduler { return mVersionModules; } + void addOnce(ah::scdCb c, uint32_t timeout, const char *name) override { + once(c, timeout, name); + } + uint32_t getSunrise() override { return mSunrise; } diff --git a/src/appInterface.h b/src/appInterface.h index a1f5cd0e..a5f4d081 100644 --- a/src/appInterface.h +++ b/src/appInterface.h @@ -8,6 +8,7 @@ #include "defines.h" #include "ESPAsyncWebServer.h" +#include "utils/scheduler.h" // abstract interface to App. Make members of App accessible from child class // like web or API without forward declaration @@ -25,6 +26,8 @@ class IApp { virtual const char *getVersion() = 0; virtual const char *getVersionModules() = 0; + virtual void addOnce(ah::scdCb c, uint32_t timeout, const char *name) = 0; + #if !defined(ETHERNET) virtual bool getAvailNetworks(JsonObject obj) = 0; virtual void setupStation(void) = 0; diff --git a/src/network/AhoyNetwork.h b/src/network/AhoyNetwork.h index b5778f7d..75b262bf 100644 --- a/src/network/AhoyNetwork.h +++ b/src/network/AhoyNetwork.h @@ -90,12 +90,9 @@ class AhoyNetwork { } #if !defined(ETHERNET) - bool getAvailNetworks(JsonObject obj) { + bool getAvailNetworks(JsonObject obj, IApp *app) { if(!mScanActive) { - mScanActive = true; - if(NetworkState::GOT_IP != mStatus) - WiFi.disconnect(); - WiFi.scanNetworks(true, true); + app->addOnce([this]() {scan();}, 1, F("scan")); return false; } @@ -117,6 +114,13 @@ class AhoyNetwork { return true; } + + void scan(void) { + mScanActive = true; + if(NetworkState::GOT_IP != mStatus) + WiFi.disconnect(); + WiFi.scanNetworks(true, true); + } #endif protected: diff --git a/src/network/AhoyWifiAp.h b/src/network/AhoyWifiAp.h index 994af3de..669e8ec8 100644 --- a/src/network/AhoyWifiAp.h +++ b/src/network/AhoyWifiAp.h @@ -63,6 +63,7 @@ class AhoyWifiAp { #if defined(ETHERNET) WiFi.mode(WIFI_OFF); #else + WiFi.scanDelete(); WiFi.mode(WIFI_STA); #endif diff --git a/src/network/AhoyWifiEsp32.h b/src/network/AhoyWifiEsp32.h index 6ccb077a..98b7053c 100644 --- a/src/network/AhoyWifiEsp32.h +++ b/src/network/AhoyWifiEsp32.h @@ -30,6 +30,7 @@ class AhoyWifi : public AhoyNetwork { DBGPRINT(F("connect to network '")); DBGPRINT(mConfig->sys.stationSsid); + DBGPRINTLN(F("'")); #endif } diff --git a/src/web/RestApi.h b/src/web/RestApi.h index 968ea0e8..188afe23 100644 --- a/src/web/RestApi.h +++ b/src/web/RestApi.h @@ -489,7 +489,9 @@ class RestApi { void getHtmlFactory(AsyncWebServerRequest *request, JsonObject obj) { getGeneric(request, obj.createNestedObject(F("generic"))); - obj[F("html")] = F("Factory reset? yes no"); + char tmp[200]; + snprintf(tmp, 200, "%s %s %s", FACTORY_RESET, BTN_YES, BTN_NO); + obj[F("html")] = tmp; } void getHtmlFactoryTrue(AsyncWebServerRequest *request, JsonObject obj) { diff --git a/src/web/lang.h b/src/web/lang.h index fb5506ee..54ade94e 100644 --- a/src/web/lang.h +++ b/src/web/lang.h @@ -72,4 +72,22 @@ #define BTN_REBOOT "Reboot" #endif +#ifdef LANG_DE + #define BTN_REBOOT "Ahoy neustarten" +#else /*LANG_EN*/ + #define BTN_REBOOT "Reboot" +#endif + +#ifdef LANG_DE + #define BTN_YES "ja" +#else /*LANG_EN*/ + #define BTN_YES "yes" +#endif + +#ifdef LANG_DE + #define BTN_NO "nein" +#else /*LANG_EN*/ + #define BTN_NO "no" +#endif + #endif /*__LANG_H__*/ diff --git a/src/web/lang.json b/src/web/lang.json index 42669e28..34b10a25 100644 --- a/src/web/lang.json +++ b/src/web/lang.json @@ -106,7 +106,7 @@ { "token": "NETWORK_SUCCESS", "en": "success, got following IP in your network: ", - "de": "Verindung erfolgreich. AhoyDTU hat die folgende IP bekommen: " + "de": "Verbindung erfolgreich. AhoyDTU hat die folgende IP bekommen: " }, { "token": "BTN_FINISH", From 4587c1c2f7a508181235d1d234e86bb1631582ad Mon Sep 17 00:00:00 2001 From: lumapu Date: Thu, 11 Apr 2024 23:16:17 +0200 Subject: [PATCH 5/5] 0.8.110 * fix ESP8266 compile --- src/network/AhoyNetwork.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/network/AhoyNetwork.h b/src/network/AhoyNetwork.h index 75b262bf..889fde8e 100644 --- a/src/network/AhoyNetwork.h +++ b/src/network/AhoyNetwork.h @@ -92,7 +92,7 @@ class AhoyNetwork { #if !defined(ETHERNET) bool getAvailNetworks(JsonObject obj, IApp *app) { if(!mScanActive) { - app->addOnce([this]() {scan();}, 1, F("scan")); + app->addOnce([this]() {scan();}, 1, "scan"); return false; }