From 5294ae3009d858a5459b486d4ca1094b136433ca Mon Sep 17 00:00:00 2001 From: geronet1 Date: Fri, 29 Mar 2024 22:20:47 +0100 Subject: [PATCH 001/107] =?UTF-8?q?MQTT=20JSON=20Payload=20pro=20Kanal=20u?= =?UTF-8?q?nd=20total,=20ausw=C3=A4hlbar=20NodeRED=20Beispiel=20Bug=20#152?= =?UTF-8?q?2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/config/settings.h | 4 + src/publisher/pubMqtt.h | 2 +- src/publisher/pubMqttIvData.h | 63 ++- src/web/RestApi.h | 3 +- src/web/html/setup.html | 5 + src/web/lang.json | 5 + src/web/web.h | 1 + tools/NodeRED/flows-mqtt-json-example.json | 466 +++++++++++++++++++++ 8 files changed, 537 insertions(+), 12 deletions(-) create mode 100644 tools/NodeRED/flows-mqtt-json-example.json diff --git a/src/config/settings.h b/src/config/settings.h index 8f20ba8f..016af2e3 100644 --- a/src/config/settings.h +++ b/src/config/settings.h @@ -151,6 +151,7 @@ typedef struct { char user[MQTT_USER_LEN]; char pwd[MQTT_PWD_LEN]; char topic[MQTT_TOPIC_LEN]; + bool json; uint16_t interval; } cfgMqtt_t; @@ -477,6 +478,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.json = 0; // off mCfg.inst.sendInterval = SEND_INTERVAL; mCfg.inst.rstYieldMidNight = false; @@ -732,11 +734,13 @@ class settings { obj[F("user")] = mCfg.mqtt.user; obj[F("pwd")] = mCfg.mqtt.pwd; obj[F("topic")] = mCfg.mqtt.topic; + obj[F("json")] = mCfg.mqtt.json; obj[F("intvl")] = mCfg.mqtt.interval; } else { getVal(obj, F("port"), &mCfg.mqtt.port); getVal(obj, F("intvl"), &mCfg.mqtt.interval); + getVal(obj, F("json"), &mCfg.mqtt.json); getChar(obj, F("broker"), mCfg.mqtt.broker, MQTT_ADDR_LEN); getChar(obj, F("user"), mCfg.mqtt.user, MQTT_USER_LEN); getChar(obj, F("clientId"), mCfg.mqtt.clientId, MQTT_CLIENTID_LEN); diff --git a/src/publisher/pubMqtt.h b/src/publisher/pubMqtt.h index 2d393b8b..14445a2b 100644 --- a/src/publisher/pubMqtt.h +++ b/src/publisher/pubMqtt.h @@ -62,7 +62,7 @@ class PubMqtt { mUptime = uptime; mIntervalTimeout = 1; - SendIvData.setup(sys, utcTs, &mSendList); + SendIvData.setup(sys, cfg_mqtt->json, utcTs, &mSendList); SendIvData.setPublishFunc([this](const char *subTopic, const char *payload, bool retained, uint8_t qos) { publish(subTopic, payload, retained, true, qos); }); diff --git a/src/publisher/pubMqttIvData.h b/src/publisher/pubMqttIvData.h index 6ddd63a9..6ac59cca 100644 --- a/src/publisher/pubMqttIvData.h +++ b/src/publisher/pubMqttIvData.h @@ -24,8 +24,9 @@ class PubMqttIvData { public: PubMqttIvData() : mTotal{}, mSubTopic{}, mVal{} {} - void setup(HMSYSTEM *sys, uint32_t *utcTs, std::queue *sendList) { + void setup(HMSYSTEM *sys, bool json, uint32_t *utcTs, std::queue *sendList) { mSys = sys; + mJson = json; mUtcTimestamp = utcTs; mSendList = sendList; mState = IDLE; @@ -197,18 +198,43 @@ class PubMqttIvData { 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))); + if (!mJson) { + 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))); + } } - uint8_t qos = (FLD_ACT_ACTIVE_PWR_LIMIT == rec->assign[mPos].fieldId) ? QOS_2 : QOS_0; - if((FLD_EVT != rec->assign[mPos].fieldId) - && (FLD_LAST_ALARM_CODE != rec->assign[mPos].fieldId)) - mPublish(mSubTopic.data(), mVal.data(), retained, qos); + if (InverterDevInform_All == mCmd || InverterDevInform_Simple == mCmd || !mJson) { + uint8_t qos = (FLD_ACT_ACTIVE_PWR_LIMIT == rec->assign[mPos].fieldId) ? QOS_2 : QOS_0; + if((FLD_EVT != rec->assign[mPos].fieldId) + && (FLD_LAST_ALARM_CODE != rec->assign[mPos].fieldId)) + mPublish(mSubTopic.data(), mVal.data(), retained, qos); + } } mPos++; } else { if (MqttSentStatus::LAST_SUCCESS_SENT == rec->mqttSentStatus) { + if (mJson) { + DynamicJsonDocument doc(300); + std::array buf; + int ch = rec->assign[0].ch; + + for (mPos = 0; mPos <= rec->length; mPos++) { + if (rec->assign[mPos].ch != ch) { + // if next channel.. publish + serializeJson(doc, buf.data(), buf.size()); + doc.clear(); + snprintf(mSubTopic.data(), mSubTopic.size(), "%s/ch%d", mIv->config->name, ch); + mPublish(mSubTopic.data(), buf.data(), false, QOS_0); + ch = rec->assign[mPos].ch; + } + if (mPos == rec->length) + break; + + doc[fields[rec->assign[mPos].fieldId]] = ah::round3(mIv->getValue(mPos, rec)); + } + } + sendRadioStat(rec->length); rec->mqttSentStatus = MqttSentStatus::DATA_SENT; } @@ -265,11 +291,27 @@ class PubMqttIvData { retained = false; break; } - snprintf(mSubTopic.data(), mSubTopic.size(), "total/%s", fields[fieldId]); - snprintf(mVal.data(), mVal.size(), "%g", ah::round3(mTotal[mPos])); - mPublish(mSubTopic.data(), mVal.data(), retained, QOS_0); + if (!mJson) { + snprintf(mSubTopic.data(), mSubTopic.size(), "total/%s", fields[fieldId]); + snprintf(mVal.data(), mVal.size(), "%g", ah::round3(mTotal[mPos])); + mPublish(mSubTopic.data(), mVal.data(), retained, QOS_0); + } mPos++; } else { + if (mJson) { + int type[5] = {FLD_PAC, FLD_YT, FLD_YD, FLD_PDC, FLD_MP}; + snprintf(mVal.data(), mVal.size(), "{"); + + for (mPos = 0; mPos < 5; mPos++) { + snprintf(mSubTopic.data(), mSubTopic.size(), "\"%s\":%g", fields[type[mPos]], ah::round3(mTotal[mPos])); + strcat(mVal.data(), mSubTopic.data()); + if (mPos < 4) + strcat(mVal.data(), ","); + else + strcat(mVal.data(), "}"); + } + mPublish(F("total"), mVal.data(), true, QOS_0); + } mSendList->pop(); mSendTotals = false; mState = IDLE; @@ -294,6 +336,7 @@ class PubMqttIvData { std::array mSubTopic; std::array mVal; + bool mJson; std::queue *mSendList = nullptr; }; diff --git a/src/web/RestApi.h b/src/web/RestApi.h index 8087883e..31104af0 100644 --- a/src/web/RestApi.h +++ b/src/web/RestApi.h @@ -80,7 +80,7 @@ class RestApi { mHeapFrag = ESP.getHeapFragmentation(); #endif - AsyncJsonResponse* response = new AsyncJsonResponse(false, 6000); + AsyncJsonResponse* response = new AsyncJsonResponse(false, 8000); JsonObject root = response->getRoot(); String path = request->url().substring(5); @@ -709,6 +709,7 @@ class RestApi { obj[F("user")] = String(mConfig->mqtt.user); obj[F("pwd")] = (strlen(mConfig->mqtt.pwd) > 0) ? F("{PWD}") : String(""); obj[F("topic")] = String(mConfig->mqtt.topic); + obj[F("json")] = (bool) mConfig->mqtt.json; obj[F("interval")] = String(mConfig->mqtt.interval); } diff --git a/src/web/html/setup.html b/src/web/html/setup.html index fb1eff97..0e248c08 100644 --- a/src/web/html/setup.html +++ b/src/web/html/setup.html @@ -242,6 +242,10 @@
Topic
+
+
{#MQTT_JSON}
+
+

{#MQTT_NOTE}

{#INTERVAL}
@@ -931,6 +935,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("mqttJson")[0].checked = obj["json"]; } function parseNtp(obj) { diff --git a/src/web/lang.json b/src/web/lang.json index ee942608..70ca2015 100644 --- a/src/web/lang.json +++ b/src/web/lang.json @@ -418,6 +418,11 @@ "en": "Password (optional)", "de": "Passwort (optional)" }, + { + "token": "MQTT_JSON", + "en": "Payload as JSON", + "de": "Ausgabe als JSON" + }, { "token": "MQTT_NOTE", "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)", diff --git a/src/web/web.h b/src/web/web.h index 419d6826..bd806b84 100644 --- a/src/web/web.h +++ b/src/web/web.h @@ -574,6 +574,7 @@ class Web { if (request->arg("mqttPwd") != "{PWD}") request->arg("mqttPwd").toCharArray(mConfig->mqtt.pwd, MQTT_PWD_LEN); request->arg("mqttTopic").toCharArray(mConfig->mqtt.topic, MQTT_TOPIC_LEN); + mConfig->mqtt.json = (request->arg("mqttJson") == "on"); mConfig->mqtt.port = request->arg("mqttPort").toInt(); mConfig->mqtt.interval = request->arg("mqttInterval").toInt(); diff --git a/tools/NodeRED/flows-mqtt-json-example.json b/tools/NodeRED/flows-mqtt-json-example.json new file mode 100644 index 00000000..5e2e09a1 --- /dev/null +++ b/tools/NodeRED/flows-mqtt-json-example.json @@ -0,0 +1,466 @@ +[ + { + "id": "67bced2c4e728783", + "type": "mqtt in", + "z": "5de5756d190f9086", + "name": "", + "topic": "hoymiles/+", + "qos": "0", + "datatype": "auto-detect", + "broker": "319864a4e0fd913f", + "nl": false, + "rap": true, + "rh": 0, + "inputs": 0, + "x": 80, + "y": 2100, + "wires": [ + [ + "a55632ad0dff0b69" + ] + ] + }, + { + "id": "a7f0d307d7cf77e2", + "type": "mqtt in", + "z": "5de5756d190f9086", + "name": "", + "topic": "hoymiles/X/#", + "qos": "0", + "datatype": "auto-detect", + "broker": "319864a4e0fd913f", + "nl": false, + "rap": true, + "rh": 0, + "inputs": 0, + "x": 90, + "y": 2260, + "wires": [ + [ + "7e17e5a3f4df3011", + "1a8cca488d53394a" + ] + ] + }, + { + "id": "7e17e5a3f4df3011", + "type": "debug", + "z": "5de5756d190f9086", + "name": "Inverter X", + "active": false, + "tosidebar": true, + "console": false, + "tostatus": false, + "complete": "payload", + "targetType": "msg", + "statusVal": "", + "statusType": "auto", + "x": 340, + "y": 2260, + "wires": [] + }, + { + "id": "fb7357db50501627", + "type": "change", + "z": "5de5756d190f9086", + "name": "Tags setzen", + "rules": [ + { + "t": "set", + "p": "payload", + "pt": "msg", + "to": "(\t $a := $split(topic, '/');\t [\t payload,\t {\t \"device\":$a[0],\t \"name\":$a[1],\t \"channel\":$a[2]\t }\t ]\t)\t", + "tot": "jsonata" + }, + { + "t": "delete", + "p": "topic", + "pt": "msg" + } + ], + "action": "", + "property": "", + "from": "", + "to": "", + "reg": false, + "x": 610, + "y": 2360, + "wires": [ + [ + "91a4607dfda84b67" + ] + ] + }, + { + "id": "670eb9fbb5c31b2c", + "type": "debug", + "z": "5de5756d190f9086", + "name": "InfluxDB", + "active": false, + "tosidebar": true, + "console": false, + "tostatus": false, + "complete": "payload", + "targetType": "msg", + "statusVal": "", + "statusType": "auto", + "x": 940, + "y": 2360, + "wires": [] + }, + { + "id": "1a8cca488d53394a", + "type": "switch", + "z": "5de5756d190f9086", + "name": "", + "property": "$split(topic, '/')[2]", + "propertyType": "jsonata", + "rules": [ + { + "t": "eq", + "v": "available", + "vt": "str" + }, + { + "t": "eq", + "v": "last_success", + "vt": "str" + }, + { + "t": "regex", + "v": "(ch[0-6])\\b", + "vt": "str", + "case": false + }, + { + "t": "eq", + "v": "radio_stat", + "vt": "str" + }, + { + "t": "eq", + "v": "firmware", + "vt": "str" + }, + { + "t": "eq", + "v": "hardware", + "vt": "str" + }, + { + "t": "eq", + "v": "alarm", + "vt": "str" + } + ], + "checkall": "true", + "repair": false, + "outputs": 7, + "x": 330, + "y": 2380, + "wires": [ + [ + "845aeb93e39092c5" + ], + [ + "241a8e70e9fde93c" + ], + [ + "fb7357db50501627" + ], + [ + "9d38f021308664c1" + ], + [ + "a508355f0cc87966" + ], + [ + "d2c9aa1a8978aca6" + ], + [ + "b27032beb597d5a7" + ] + ] + }, + { + "id": "845aeb93e39092c5", + "type": "debug", + "z": "5de5756d190f9086", + "name": "available", + "active": true, + "tosidebar": false, + "console": false, + "tostatus": true, + "complete": "payload", + "targetType": "msg", + "statusVal": "payload", + "statusType": "auto", + "x": 600, + "y": 2240, + "wires": [] + }, + { + "id": "241a8e70e9fde93c", + "type": "debug", + "z": "5de5756d190f9086", + "name": "last_success", + "active": true, + "tosidebar": false, + "console": false, + "tostatus": true, + "complete": "payload", + "targetType": "msg", + "statusVal": "payload", + "statusType": "auto", + "x": 610, + "y": 2300, + "wires": [] + }, + { + "id": "9d38f021308664c1", + "type": "debug", + "z": "5de5756d190f9086", + "name": "radio_stat", + "active": false, + "tosidebar": true, + "console": false, + "tostatus": false, + "complete": "payload", + "targetType": "msg", + "statusVal": "", + "statusType": "auto", + "x": 600, + "y": 2400, + "wires": [] + }, + { + "id": "a508355f0cc87966", + "type": "debug", + "z": "5de5756d190f9086", + "name": "firmware", + "active": false, + "tosidebar": true, + "console": false, + "tostatus": false, + "complete": "payload", + "targetType": "msg", + "statusVal": "", + "statusType": "auto", + "x": 600, + "y": 2440, + "wires": [] + }, + { + "id": "d2c9aa1a8978aca6", + "type": "debug", + "z": "5de5756d190f9086", + "name": "hardware", + "active": false, + "tosidebar": true, + "console": false, + "tostatus": false, + "complete": "payload", + "targetType": "msg", + "statusVal": "", + "statusType": "auto", + "x": 600, + "y": 2480, + "wires": [] + }, + { + "id": "b27032beb597d5a7", + "type": "debug", + "z": "5de5756d190f9086", + "name": "alarm", + "active": false, + "tosidebar": true, + "console": false, + "tostatus": false, + "complete": "payload", + "targetType": "msg", + "statusVal": "", + "statusType": "auto", + "x": 590, + "y": 2520, + "wires": [] + }, + { + "id": "d814738cf55ad663", + "type": "debug", + "z": "5de5756d190f9086", + "name": "total", + "active": false, + "tosidebar": true, + "console": false, + "tostatus": false, + "complete": "payload", + "targetType": "msg", + "statusVal": "", + "statusType": "auto", + "x": 590, + "y": 2160, + "wires": [] + }, + { + "id": "a55632ad0dff0b69", + "type": "switch", + "z": "5de5756d190f9086", + "name": "", + "property": "$split(topic, '/')[1]", + "propertyType": "jsonata", + "rules": [ + { + "t": "eq", + "v": "uptime", + "vt": "str" + }, + { + "t": "eq", + "v": "wifi_rssi", + "vt": "str" + }, + { + "t": "eq", + "v": "status", + "vt": "str" + }, + { + "t": "eq", + "v": "total", + "vt": "str" + } + ], + "checkall": "true", + "repair": false, + "outputs": 4, + "x": 330, + "y": 2100, + "wires": [ + [ + "1fbb0674d2576ee7" + ], + [ + "e6be1c98ac55f511" + ], + [ + "f9c2d3b30e34fdda" + ], + [ + "d814738cf55ad663" + ] + ] + }, + { + "id": "f9c2d3b30e34fdda", + "type": "debug", + "z": "5de5756d190f9086", + "name": "status", + "active": false, + "tosidebar": false, + "console": false, + "tostatus": true, + "complete": "payload", + "targetType": "msg", + "statusVal": "payload", + "statusType": "auto", + "x": 590, + "y": 2100, + "wires": [] + }, + { + "id": "e6be1c98ac55f511", + "type": "debug", + "z": "5de5756d190f9086", + "name": "wifi_rssi", + "active": false, + "tosidebar": false, + "console": false, + "tostatus": true, + "complete": "payload", + "targetType": "msg", + "statusVal": "payload", + "statusType": "auto", + "x": 600, + "y": 2040, + "wires": [] + }, + { + "id": "1fbb0674d2576ee7", + "type": "debug", + "z": "5de5756d190f9086", + "name": "uptime", + "active": false, + "tosidebar": false, + "console": false, + "tostatus": true, + "complete": "payload", + "targetType": "msg", + "statusVal": "payload", + "statusType": "auto", + "x": 590, + "y": 1980, + "wires": [] + }, + { + "id": "91a4607dfda84b67", + "type": "change", + "z": "5de5756d190f9086", + "name": "Lösche", + "rules": [ + { + "t": "delete", + "p": "payload[0].YieldDay", + "pt": "msg" + }, + { + "t": "delete", + "p": "payload[0].MaxPower", + "pt": "msg" + }, + { + "t": "delete", + "p": "payload[0].ALARM_MES_ID", + "pt": "msg" + } + ], + "action": "", + "property": "", + "from": "", + "to": "", + "reg": false, + "x": 780, + "y": 2360, + "wires": [ + [ + "670eb9fbb5c31b2c" + ] + ] + }, + { + "id": "319864a4e0fd913f", + "type": "mqtt-broker", + "name": "broker", + "broker": "localhost", + "port": "1883", + "clientid": "", + "autoConnect": true, + "usetls": false, + "protocolVersion": "4", + "keepalive": "60", + "cleansession": true, + "birthTopic": "", + "birthQos": "0", + "birthPayload": "", + "birthMsg": {}, + "closeTopic": "", + "closeQos": "0", + "closePayload": "", + "closeMsg": {}, + "willTopic": "", + "willQos": "0", + "willPayload": "", + "willMsg": {}, + "userProps": "", + "sessionExpiry": "" + } +] \ No newline at end of file From 59b1fe866f9851e5f865b2ba25516409fba26985 Mon Sep 17 00:00:00 2001 From: geronet1 Date: Sun, 31 Mar 2024 21:20:35 +0200 Subject: [PATCH 002/107] mqtt->rssi nicht in /ch0/, mqtt->json kein YieldDay/YieldTotal einzeln --- .../htmlPreprocessorDefines.cpython-311.pyc | Bin 0 -> 2235 bytes src/publisher/pubMqtt.h | 3 +++ src/publisher/pubMqttIvData.h | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 scripts/__pycache__/htmlPreprocessorDefines.cpython-311.pyc diff --git a/scripts/__pycache__/htmlPreprocessorDefines.cpython-311.pyc b/scripts/__pycache__/htmlPreprocessorDefines.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..8b8e34409896b76a6d2fa979407131efe3b7e1f0 GIT binary patch literal 2235 zcma)7-EY%Y6u;LWiIWtPEUh46Dk)t>%~pz_v`7PGL53D}{+ zTlUb>(ygV*AWs==io_C%!AOr|3XctXLtc|jZNYc*vy;NtvP5KIS&>#F31K!VN(muy zKbaX5m9)hOa+JhUiY(k$HsW6qDMgY|NtTmjPFjs6B>8+QW3Un-NkTYK%EBuT0m-2T zr`0h&9rkFk)j0bJ~Dy7XGcb) z56Lj=mOV17(iK|=*Wr4-m(K&v-r4PNy|^r=aw6q#Z>#q1*}8QiVq(}1Cd+Q;kM!Gi zgx{ZmKjtmIH+n6q>?+l(0V5SsJdKF+5E4H`;K^@CdU81Gtq6YeVG$&5#n*9G2=6J_hnw959uDK)%3a}b3Am8n=wq~qH@2RR6t++EBdC8!J(ts{Jgm^W$I zLgBeD=I_1!2gYkN?+qHJ1`cfvj)rb7hxp(|OqOGbwO}$OC4#aNQKStip$zdZgWXI^ zX~}ThjIAbbTP#H+!w!`yM&faUj!OxHF=tS-8!07Y&}))n(5bXyRj*--q(G<0I}AFO zNC93}40|e~C=y8+c+;ShY3L;Dl9V!-IF!GE9~)Sb%{mIU1~D_*V59e?=sFn&-rSWX zI0^Iw?%1}w#`)`RQYomKs-F&;Y?=96_YRc&1%LVTns=z~9jYw7@}8}F z&*~m;i7l|&rX_bri`P8Eb&hkXf6RdlJRZsA(?mC`ZBxbmy?Jfrs zvv*m2RRpHDud4WPK6d|HRHR}N?}F@})z?5AWvLzn1qiAa0l7?vw|HS(I5&D@5>i)% ztX21unjigkW^Coc*fnA7-rZ068^SqZd}~~o7KVf|VeJ3m01~eA6fs+~m0LVb0w#aT zB!fU?(^E*r{VZgn$;3l40!!vAUj(xMV;X+4_;fM1*l@ZvT3fCL=4;M{x^p2n+i-a_ zpBAm2`m*K<*InT%6SgAC+sH>CZBR*>c!06$#d5(?|0}XkmeqIM^hQ!l$EE9J6p&^K s%L0%ljWO1dBWFEbOkd7=nhb?qP1Gh_0K1#0O|H`T7KX(BPik5J7Z*a)+W-In literal 0 HcmV?d00001 diff --git a/src/publisher/pubMqtt.h b/src/publisher/pubMqtt.h index 14445a2b..a9a91974 100644 --- a/src/publisher/pubMqtt.h +++ b/src/publisher/pubMqtt.h @@ -559,6 +559,9 @@ class PubMqtt { } void sendData(Inverter<> *iv, uint8_t curInfoCmd) { + if (cfg_mqtt->json) + return; + record_t<> *rec = iv->getRecordStruct(curInfoCmd); uint32_t lastTs = iv->getLastTs(rec); diff --git a/src/publisher/pubMqttIvData.h b/src/publisher/pubMqttIvData.h index 6ac59cca..6c1e433d 100644 --- a/src/publisher/pubMqttIvData.h +++ b/src/publisher/pubMqttIvData.h @@ -115,7 +115,7 @@ class PubMqttIvData { mPublish(mSubTopic.data(), mVal.data(), true, QOS_0); if((mIv->ivGen == IV_HMS) || (mIv->ivGen == IV_HMT)) { - snprintf(mSubTopic.data(), mSubTopic.size(), "%s/ch0/rssi", mIv->config->name); + snprintf(mSubTopic.data(), mSubTopic.size(), "%s/rssi", mIv->config->name); snprintf(mVal.data(), mVal.size(), "%d", mIv->rssi); mPublish(mSubTopic.data(), mVal.data(), false, QOS_0); } From d664221e5400be354df1eca5b81ef7db3eebfe38 Mon Sep 17 00:00:00 2001 From: geronet1 Date: Sun, 31 Mar 2024 21:32:57 +0200 Subject: [PATCH 003/107] mCfgMqtt statt cfg_mqtt --- src/publisher/pubMqtt.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/publisher/pubMqtt.h b/src/publisher/pubMqtt.h index a9a91974..159c7939 100644 --- a/src/publisher/pubMqtt.h +++ b/src/publisher/pubMqtt.h @@ -559,7 +559,7 @@ class PubMqtt { } void sendData(Inverter<> *iv, uint8_t curInfoCmd) { - if (cfg_mqtt->json) + if (mCfgMqtt->json) return; record_t<> *rec = iv->getRecordStruct(curInfoCmd); From 42ee440e114fa54e6679e6edbe42213ccccce6fa Mon Sep 17 00:00:00 2001 From: geronet1 Date: Mon, 1 Apr 2024 15:55:09 +0200 Subject: [PATCH 004/107] MaxTemp Berechnung und Anzeige --- src/hm/hmDefines.h | 17 ++++++++++------- src/hm/hmInverter.h | 29 ++++++++++++++++++++++++++++- src/hms/hmsDefines.h | 12 ++++++++---- src/web/RestApi.h | 5 +++-- src/web/html/visualization.html | 4 +++- 5 files changed, 52 insertions(+), 15 deletions(-) diff --git a/src/hm/hmDefines.h b/src/hm/hmDefines.h index 6ba92774..c6ca7066 100644 --- a/src/hm/hmDefines.h +++ b/src/hm/hmDefines.h @@ -24,20 +24,20 @@ enum {FLD_UDC = 0, FLD_IDC, FLD_PDC, FLD_YD, FLD_YW, FLD_YT, FLD_IRR, FLD_Q, FLD_EVT, FLD_FW_VERSION, FLD_FW_BUILD_YEAR, FLD_FW_BUILD_MONTH_DAY, FLD_FW_BUILD_HOUR_MINUTE, FLD_BOOTLOADER_VER, FLD_ACT_ACTIVE_PWR_LIMIT, FLD_PART_NUM, FLD_HW_VERSION, FLD_GRID_PROFILE_CODE, - FLD_GRID_PROFILE_VERSION, /*FLD_ACT_REACTIVE_PWR_LIMIT, FLD_ACT_PF,*/ FLD_LAST_ALARM_CODE, FLD_MP}; + FLD_GRID_PROFILE_VERSION, /*FLD_ACT_REACTIVE_PWR_LIMIT, FLD_ACT_PF,*/ FLD_LAST_ALARM_CODE, FLD_MP, FLD_MT}; const char* const fields[] = {"U_DC", "I_DC", "P_DC", "YieldDay", "YieldWeek", "YieldTotal", "U_AC", "U_AC_1N", "U_AC_2N", "U_AC_3N", "UAC_12", "UAC_23", "UAC_31", "I_AC", "IAC_1", "I_AC_2", "I_AC_3", "P_AC", "F_AC", "Temp", "PF_AC", "Efficiency", "Irradiation","Q_AC", "ALARM_MES_ID","FWVersion","FWBuildYear","FWBuildMonthDay","FWBuildHourMinute","BootloaderVersion", "active_PowerLimit", "HWPartNumber", "HWVersion", "GridProfileCode", - "GridProfileVersion", /*"reactivePowerLimit","Powerfactor",*/ "LastAlarmCode", "MaxPower"}; + "GridProfileVersion", /*"reactivePowerLimit","Powerfactor",*/ "LastAlarmCode", "MaxPower", "MaxTemp"}; const char* const notAvail = "n/a"; const uint8_t fieldUnits[] = {UNIT_V, UNIT_A, UNIT_W, UNIT_WH, UNIT_KWH, UNIT_KWH, UNIT_V, UNIT_V, UNIT_V, UNIT_V, UNIT_V, UNIT_V, UNIT_V, UNIT_A, UNIT_A, UNIT_A, UNIT_A, UNIT_W, UNIT_HZ, UNIT_C, UNIT_NONE, UNIT_PCT, UNIT_PCT, UNIT_VAR, - UNIT_NONE, UNIT_NONE, UNIT_NONE, UNIT_NONE, UNIT_NONE, UNIT_NONE, UNIT_PCT, UNIT_NONE, UNIT_NONE, UNIT_NONE, UNIT_NONE, UNIT_NONE, UNIT_W}; + UNIT_NONE, UNIT_NONE, UNIT_NONE, UNIT_NONE, UNIT_NONE, UNIT_NONE, UNIT_PCT, UNIT_NONE, UNIT_NONE, UNIT_NONE, UNIT_NONE, UNIT_NONE, UNIT_W, UNIT_C}; // mqtt discovery device classes enum {DEVICE_CLS_NONE = 0, DEVICE_CLS_CURRENT, DEVICE_CLS_ENERGY, DEVICE_CLS_PWR, DEVICE_CLS_VOLTAGE, DEVICE_CLS_FREQ, DEVICE_CLS_TEMP}; @@ -68,7 +68,7 @@ const byteAssign_fieldDeviceClass deviceFieldAssignment[] = { #define DEVICE_CLS_ASSIGN_LIST_LEN (sizeof(deviceFieldAssignment) / sizeof(byteAssign_fieldDeviceClass)) // indices to calculation functions, defined in hmInverter.h -enum {CALC_YT_CH0 = 0, CALC_YD_CH0, CALC_UDC_CH, CALC_PDC_CH0, CALC_EFF_CH0, CALC_IRR_CH, CALC_MPAC_CH0, CALC_MPDC_CH}; +enum {CALC_YT_CH0 = 0, CALC_YD_CH0, CALC_UDC_CH, CALC_PDC_CH0, CALC_EFF_CH0, CALC_IRR_CH, CALC_MPAC_CH0, CALC_MPDC_CH, CALC_MT_CH0}; enum {CMD_CALC = 0xffff}; @@ -173,7 +173,8 @@ const byteAssign_t hm1chAssignment[] = { { FLD_YT, UNIT_KWH, CH0, CALC_YT_CH0, 0, CMD_CALC }, { FLD_PDC, UNIT_W, CH0, CALC_PDC_CH0, 0, CMD_CALC }, { FLD_EFF, UNIT_PCT, CH0, CALC_EFF_CH0, 0, CMD_CALC }, - { FLD_MP, UNIT_W, CH0, CALC_MPAC_CH0, 0, CMD_CALC } + { FLD_MP, UNIT_W, CH0, CALC_MPAC_CH0, 0, CMD_CALC }, + { FLD_MT, UNIT_C, CH0, CALC_MT_CH0, 0, CMD_CALC } }; #define HM1CH_LIST_LEN (sizeof(hm1chAssignment) / sizeof(byteAssign_t)) #define HM1CH_PAYLOAD_LEN 30 @@ -211,7 +212,8 @@ const byteAssign_t hm2chAssignment[] = { { FLD_YT, UNIT_KWH, CH0, CALC_YT_CH0, 0, CMD_CALC }, { FLD_PDC, UNIT_W, CH0, CALC_PDC_CH0, 0, CMD_CALC }, { FLD_EFF, UNIT_PCT, CH0, CALC_EFF_CH0, 0, CMD_CALC }, - { FLD_MP, UNIT_W, CH0, CALC_MPAC_CH0, 0, CMD_CALC } + { FLD_MP, UNIT_W, CH0, CALC_MPAC_CH0, 0, CMD_CALC }, + { FLD_MT, UNIT_C, CH0, CALC_MT_CH0, 0, CMD_CALC } }; #define HM2CH_LIST_LEN (sizeof(hm2chAssignment) / sizeof(byteAssign_t)) @@ -266,7 +268,8 @@ const byteAssign_t hm4chAssignment[] = { { FLD_YT, UNIT_KWH, CH0, CALC_YT_CH0, 0, CMD_CALC }, { FLD_PDC, UNIT_W, CH0, CALC_PDC_CH0, 0, CMD_CALC }, { FLD_EFF, UNIT_PCT, CH0, CALC_EFF_CH0, 0, CMD_CALC }, - { FLD_MP, UNIT_W, CH0, CALC_MPAC_CH0, 0, CMD_CALC } + { FLD_MP, UNIT_W, CH0, CALC_MPAC_CH0, 0, CMD_CALC }, + { FLD_MT, UNIT_C, CH0, CALC_MT_CH0, 0, CMD_CALC } }; #define HM4CH_LIST_LEN (sizeof(hm4chAssignment) / sizeof(byteAssign_t)) #define HM4CH_PAYLOAD_LEN 62 diff --git a/src/hm/hmInverter.h b/src/hm/hmInverter.h index 1d7e6620..6754fd45 100644 --- a/src/hm/hmInverter.h +++ b/src/hm/hmInverter.h @@ -53,6 +53,9 @@ static T calcIrradiation(Inverter<> *iv, uint8_t arg0); template static T calcMaxPowerAcCh0(Inverter<> *iv, uint8_t arg0); +template +static T calcMaxTempCh0(Inverter<> *iv, uint8_t arg0); + template static T calcMaxPowerDc(Inverter<> *iv, uint8_t arg0); @@ -107,7 +110,8 @@ const calcFunc_t calcFunctions[] = { { CALC_EFF_CH0, &calcEffiencyCh0 }, { CALC_IRR_CH, &calcIrradiation }, { CALC_MPAC_CH0, &calcMaxPowerAcCh0 }, - { CALC_MPDC_CH, &calcMaxPowerDc } + { CALC_MPDC_CH, &calcMaxPowerDc }, + { CALC_MT_CH0, &calcMaxTempCh0 } }; template @@ -147,6 +151,7 @@ class Inverter { HeuristicInv heuristics; // heuristic information / logic uint8_t curCmtFreq = 0; // current used CMT frequency, used to check if freq. was changed during runtime uint32_t tsMaxAcPower = 0; // holds the timestamp when the MaxAC power was seen + uint32_t tsMaxTemp = 0; // holds the timestamp when the max temp was seen bool commEnabled = true; // 'pause night communication' sets this field to false public: @@ -951,6 +956,28 @@ static T calcMaxPowerAcCh0(Inverter<> *iv, uint8_t arg0) { return acMaxPower; } +template +static T calcMaxTempCh0(Inverter<> *iv, uint8_t arg0) { + DPRINTLN(DBG_VERBOSE, F("hmInverter.h:calcMaxTempCh0")); + T maxTemp = 0.0; + if(NULL != iv) { + record_t<> *rec = iv->getRecordStruct(RealTimeRunData_Debug); + T Temp = iv->getChannelFieldValue(arg0, FLD_T, rec); + + for(uint8_t i = 0; i < rec->length; i++) { + if((FLD_MT == rec->assign[i].fieldId) && (0 == rec->assign[i].ch)) { + maxTemp = iv->getValue(i, rec); + } + } + if(Temp > maxTemp) { + iv->tsMaxTemp = *iv->timestamp; + return Temp; + } + } + return maxTemp; +} + + template static T calcMaxPowerDc(Inverter<> *iv, uint8_t arg0) { DPRINTLN(DBG_VERBOSE, F("hmInverter.h:calcMaxPowerDc")); diff --git a/src/hms/hmsDefines.h b/src/hms/hmsDefines.h index 61275dc1..c71aa796 100644 --- a/src/hms/hmsDefines.h +++ b/src/hms/hmsDefines.h @@ -33,7 +33,8 @@ const byteAssign_t hms1chAssignment[] = { { FLD_YT, UNIT_KWH, CH0, CALC_YT_CH0, 0, CMD_CALC }, { FLD_PDC, UNIT_W, CH0, CALC_PDC_CH0, 0, CMD_CALC }, { FLD_EFF, UNIT_PCT, CH0, CALC_EFF_CH0, 0, CMD_CALC }, - { FLD_MP, UNIT_W, CH0, CALC_MPAC_CH0, 0, CMD_CALC } + { FLD_MP, UNIT_W, CH0, CALC_MPAC_CH0, 0, CMD_CALC }, + { FLD_MT, UNIT_C, CH0, CALC_MT_CH0, 0, CMD_CALC } }; #define HMS1CH_LIST_LEN (sizeof(hms1chAssignment) / sizeof(byteAssign_t)) #define HMS1CH_PAYLOAD_LEN 30 @@ -70,7 +71,8 @@ const byteAssign_t hms2chAssignment[] = { { FLD_YT, UNIT_KWH, CH0, CALC_YT_CH0, 0, CMD_CALC }, { FLD_PDC, UNIT_W, CH0, CALC_PDC_CH0, 0, CMD_CALC }, { FLD_EFF, UNIT_PCT, CH0, CALC_EFF_CH0, 0, CMD_CALC }, - { FLD_MP, UNIT_W, CH0, CALC_MPAC_CH0, 0, CMD_CALC } + { FLD_MP, UNIT_W, CH0, CALC_MPAC_CH0, 0, CMD_CALC }, + { FLD_MT, UNIT_C, CH0, CALC_MT_CH0, 0, CMD_CALC } }; #define HMS2CH_LIST_LEN (sizeof(hms2chAssignment) / sizeof(byteAssign_t)) #define HMS2CH_PAYLOAD_LEN 42 @@ -123,7 +125,8 @@ const byteAssign_t hms4chAssignment[] = { { FLD_YT, UNIT_KWH, CH0, CALC_YT_CH0, 0, CMD_CALC }, { FLD_PDC, UNIT_W, CH0, CALC_PDC_CH0, 0, CMD_CALC }, { FLD_EFF, UNIT_PCT, CH0, CALC_EFF_CH0, 0, CMD_CALC }, - { FLD_MP, UNIT_W, CH0, CALC_MPAC_CH0, 0, CMD_CALC } + { FLD_MP, UNIT_W, CH0, CALC_MPAC_CH0, 0, CMD_CALC }, + { FLD_MT, UNIT_C, CH0, CALC_MT_CH0, 0, CMD_CALC } }; #define HMS4CH_LIST_LEN (sizeof(hms4chAssignment) / sizeof(byteAssign_t)) #define HMS4CH_PAYLOAD_LEN 66 @@ -199,7 +202,8 @@ const byteAssign_t hmt6chAssignment[] = { { FLD_YT, UNIT_KWH, CH0, CALC_YT_CH0, 0, CMD_CALC }, { FLD_PDC, UNIT_W, CH0, CALC_PDC_CH0, 0, CMD_CALC }, { FLD_EFF, UNIT_PCT, CH0, CALC_EFF_CH0, 0, CMD_CALC }, - { FLD_MP, UNIT_W, CH0, CALC_MPAC_CH0, 0, CMD_CALC } + { FLD_MP, UNIT_W, CH0, CALC_MPAC_CH0, 0, CMD_CALC }, + { FLD_MT, UNIT_C, CH0, CALC_MT_CH0, 0, CMD_CALC } }; #define HMT6CH_LIST_LEN (sizeof(hmt6chAssignment) / sizeof(byteAssign_t)) #define HMT6CH_PAYLOAD_LEN 98 diff --git a/src/web/RestApi.h b/src/web/RestApi.h index 31104af0..3a578add 100644 --- a/src/web/RestApi.h +++ b/src/web/RestApi.h @@ -602,6 +602,7 @@ class RestApi { obj[F("alarm_cnt")] = iv->alarmCnt; obj[F("rssi")] = iv->rssi; obj[F("ts_max_ac_pwr")] = iv->tsMaxAcPower; + obj[F("ts_max_temp")] = iv->tsMaxTemp; JsonArray ch = obj.createNestedArray("ch"); @@ -1110,9 +1111,9 @@ class RestApi { private: constexpr static uint8_t acList[] = {FLD_UAC, FLD_IAC, FLD_PAC, FLD_F, FLD_PF, FLD_T, FLD_YT, - FLD_YD, FLD_PDC, FLD_EFF, FLD_Q, FLD_MP}; + FLD_YD, FLD_PDC, FLD_EFF, FLD_Q, FLD_MP, FLD_MT}; constexpr static uint8_t acListHmt[] = {FLD_UAC_1N, FLD_IAC_1, FLD_PAC, FLD_F, FLD_PF, FLD_T, - FLD_YT, FLD_YD, FLD_PDC, FLD_EFF, FLD_Q, FLD_MP}; + FLD_YT, FLD_YD, FLD_PDC, FLD_EFF, FLD_Q, FLD_MP, FLD_MT}; constexpr static uint8_t dcList[] = {FLD_UDC, FLD_IDC, FLD_PDC, FLD_YD, FLD_YT, FLD_IRR, FLD_MP}; private: diff --git a/src/web/html/visualization.html b/src/web/html/visualization.html index cfc84e72..6c3bb67f 100644 --- a/src/web/html/visualization.html +++ b/src/web/html/visualization.html @@ -120,6 +120,7 @@ } var maxAcPwr = toIsoDateStr(new Date(obj.ts_max_ac_pwr * 1000)); + var maxTemp = toIsoDateStr(new Date(obj.ts_max_temp * 1000)); return ml("div", {class: "row mt-2"}, ml("div", {class: "col"}, [ ml("div", {class: "p-2 " + clh}, @@ -134,7 +135,8 @@ ml("div", {class: "col a-c"}, ml("span", { class: "pointer", onclick: function() { getAjax("/api/inverter/alarm/" + obj.id, parseIvAlarm); }}, ("{#ALARMS}: " + obj.alarm_cnt))), - ml("div", {class: "col a-r mx-2 mx-md-1"}, String(obj.ch[0][5].toFixed(1)) + t.innerText) + ml("div", {class: "col a-r mx-2 mx-md-1 tooltip", data: maxTemp}, String(obj.ch[0][5].toFixed(1)) + t.innerText + "
" + + "Max:" + String(obj.ch[0][12].toFixed(1)) + t.innerText) ]) ), ml("div", {class: "p-2 " + clbg}, [ From f105e25d3c040922956921c2750292cac8ce43b4 Mon Sep 17 00:00:00 2001 From: lumapu Date: Thu, 4 Apr 2024 01:47:24 +0200 Subject: [PATCH 005/107] 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 006/107] 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 007/107] 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 008/107] 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 009/107] 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 010/107] 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 011/107] 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 012/107] 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 013/107] 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 014/107] 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 015/107] 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 016/107] 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 017/107] 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 From 58c57524fb0393cc09721f7312e6d81ad96cc9d9 Mon Sep 17 00:00:00 2001 From: lumapu Date: Tue, 9 Apr 2024 22:15:02 +0200 Subject: [PATCH 018/107] fix NRF24 patch --- patches/RF24_Hal.patch | 95 +++++++++++++++++++++++---------------- src/CHANGES.md | 6 +++ src/defines.h | 2 +- src/network/AhoyNetwork.h | 4 +- src/platformio.ini | 3 +- 5 files changed, 68 insertions(+), 42 deletions(-) diff --git a/patches/RF24_Hal.patch b/patches/RF24_Hal.patch index ed2c5bec..88a53bf9 100644 --- a/patches/RF24_Hal.patch +++ b/patches/RF24_Hal.patch @@ -1,5 +1,5 @@ diff --git a/RF24.cpp b/RF24.cpp -index 2e500b6..af00758 100644 +index 9e5b4a8..af00758 100644 --- a/RF24.cpp +++ b/RF24.cpp @@ -12,228 +12,24 @@ @@ -605,7 +605,8 @@ index 2e500b6..af00758 100644 /****************************************************************************/ -bool RF24::begin(_SPI* spiBus, rf24_gpio_pin_t _cepin, rf24_gpio_pin_t _cspin) --{ ++bool RF24::begin(RF24_hal* _hal) + { - ce_pin = _cepin; - csn_pin = _cspin; - return begin(spiBus); @@ -616,8 +617,7 @@ index 2e500b6..af00758 100644 -/****************************************************************************/ - -bool RF24::begin(rf24_gpio_pin_t _cepin, rf24_gpio_pin_t _cspin) -+bool RF24::begin(RF24_hal* _hal) - { +-{ - ce_pin = _cepin; - csn_pin = _cspin; + hal = _hal; @@ -670,12 +670,17 @@ index 2e500b6..af00758 100644 bool RF24::_init_pins() { if (!isValid()) { -@@ -1028,41 +527,7 @@ bool RF24::_init_pins() +@@ -1028,46 +527,7 @@ bool RF24::_init_pins() return false; } -#if defined(RF24_LINUX) - +- #if defined(MRAA) +- GPIO(); +- gpio.begin(ce_pin, csn_pin); +- #endif +- - pinMode(ce_pin, OUTPUT); - ce(LOW); - delay(100); @@ -713,7 +718,7 @@ index 2e500b6..af00758 100644 } /****************************************************************************/ -@@ -1146,7 +611,7 @@ bool RF24::isChipConnected() +@@ -1151,7 +611,7 @@ bool RF24::isChipConnected() bool RF24::isValid() { @@ -722,7 +727,7 @@ index 2e500b6..af00758 100644 } /****************************************************************************/ -@@ -1670,15 +1135,8 @@ void RF24::closeReadingPipe(uint8_t pipe) +@@ -1675,15 +1135,8 @@ void RF24::closeReadingPipe(uint8_t pipe) void RF24::toggle_features(void) { @@ -740,7 +745,7 @@ index 2e500b6..af00758 100644 } /****************************************************************************/ -@@ -1866,6 +1324,11 @@ uint8_t RF24::getARC(void) +@@ -1871,6 +1324,11 @@ uint8_t RF24::getARC(void) return read_register(OBSERVE_TX) & 0x0F; } @@ -753,7 +758,7 @@ index 2e500b6..af00758 100644 bool RF24::setDataRate(rf24_datarate_e speed) diff --git a/RF24.h b/RF24.h -index c029c8e..c9d612a 100644 +index dbd32ae..74ae35d 100644 --- a/RF24.h +++ b/RF24.h @@ -16,12 +16,7 @@ @@ -770,7 +775,7 @@ index c029c8e..c9d612a 100644 /** * @defgroup PALevel Power Amplifier level -@@ -115,26 +110,8 @@ typedef enum +@@ -115,29 +110,8 @@ typedef enum class RF24 { private: @@ -779,15 +784,18 @@ index c029c8e..c9d612a 100644 -#elif defined(SPI_UART) - SPIUARTClass uspi; -#endif -+ RF24_hal *hal; - +- -#if defined(RF24_LINUX) || defined(XMEGA_D3) /* XMEGA can use SPI class */ - SPI spi; -#endif // defined (RF24_LINUX) || defined (XMEGA_D3) -#if defined(RF24_SPI_PTR) - _SPI* _spi; -#endif // defined (RF24_SPI_PTR) -- +-#if defined(MRAA) +- GPIO gpio; +-#endif ++ RF24_hal *hal; + - rf24_gpio_pin_t ce_pin; /* "Chip Enable" pin, activates the RX or TX role */ - rf24_gpio_pin_t csn_pin; /* SPI Chip select */ - uint32_t spi_speed; /* SPI Bus Speed */ @@ -798,7 +806,7 @@ index c029c8e..c9d612a 100644 uint8_t status; /* The status byte returned from every SPI transaction */ uint8_t payload_size; /* Fixed size of payloads */ uint8_t pipe0_reading_address[5]; /* Last address set on pipe 0 for reading. */ -@@ -143,16 +120,6 @@ private: +@@ -146,16 +120,6 @@ private: bool _is_p0_rx; /* For keeping track of pipe 0's usage in user-triggered RX mode. */ protected: @@ -815,7 +823,7 @@ index c029c8e..c9d612a 100644 /** Whether ack payloads are enabled. */ bool ack_payloads_enabled; /** The address width to use (3, 4 or 5 bytes). */ -@@ -195,30 +162,15 @@ public: +@@ -198,30 +162,15 @@ public: * * See [Related Pages](pages.html) for device specific information * @@ -850,7 +858,7 @@ index c029c8e..c9d612a 100644 #if defined(RF24_LINUX) virtual ~RF24() {}; -@@ -240,58 +192,16 @@ public: +@@ -243,58 +192,16 @@ public: */ bool begin(void); @@ -861,16 +869,15 @@ index c029c8e..c9d612a 100644 - * @note This function assumes the `SPI::begin()` method was called before to - * calling this function. - * - * @warning This function is for the Arduino platforms only - * +- * @warning This function is for the Arduino platforms only +- * - * @param spiBus A pointer or reference to an instantiated SPI bus object. - * The `_SPI` datatype is a "wrapped" definition that will represent - * various SPI implementations based on the specified platform. - * @see Review the [Arduino support page](md_docs_arduino.html). -+ * @param _hal A pointer to the device specific hardware abstraction layer - * - * @return same result as begin() - */ +- * +- * @return same result as begin() +- */ - bool begin(_SPI* spiBus); - - /** @@ -880,8 +887,8 @@ index c029c8e..c9d612a 100644 - * @note This function assumes the `SPI::begin()` method was called before to - * calling this function. - * -- * @warning This function is for the Arduino platforms only -- * + * @warning This function is for the Arduino platforms only + * - * @param spiBus A pointer or reference to an instantiated SPI bus object. - * The `_SPI` datatype is a "wrapped" definition that will represent - * various SPI implementations based on the specified platform. @@ -889,7 +896,8 @@ index c029c8e..c9d612a 100644 - * @param _cspin The pin attached to Chip Select (often labeled CSN) on the radio module. - * - For the Arduino Due board, the [Arduino Due extended SPI feature](https://www.arduino.cc/en/Reference/DueExtendedSPI) - * is not supported. This means that the Due's pins 4, 10, or 52 are not mandated options (can use any digital output pin) for the radio's CSN pin. -- * ++ * @param _hal A pointer to the device specific hardware abstraction layer + * - * @see Review the [Arduino support page](md_docs_arduino.html). - * - * @return same result as begin() @@ -904,14 +912,14 @@ index c029c8e..c9d612a 100644 - * @param _cspin The pin attached to Chip Select (often labeled CSN) on the radio module. - * - For the Arduino Due board, the [Arduino Due extended SPI feature](https://www.arduino.cc/en/Reference/DueExtendedSPI) - * is not supported. This means that the Due's pins 4, 10, or 52 are not mandated options (can use any digital output pin) for the radio's CSN pin. -- * @return same result as begin() -- */ + * @return same result as begin() + */ - bool begin(rf24_gpio_pin_t _cepin, rf24_gpio_pin_t _cspin); + bool begin(RF24_hal* _hal); /** * Checks if the chip is connected to the SPI bus -@@ -664,12 +574,12 @@ public: +@@ -667,12 +574,12 @@ public: * This function uses much less ram than other `*print*Details()` methods. * * @code @@ -926,7 +934,17 @@ index c029c8e..c9d612a 100644 * cause undefined behavior. * * Registers names and/or data corresponding to the index of the `encoded_details` array: -@@ -1641,6 +1551,7 @@ public: +@@ -704,9 +611,6 @@ public: + * | 35 | FIFO_STATUS | + * | 36 | DYNPD | + * | 37 | FEATURE | +- * | 38-39 | ce_pin | +- * | 40-41 | csn_pin | +- * | 42 | SPI speed (in MHz) or'd with (isPlusVariant << 4) | + */ + void encodeRadioDetails(uint8_t* encoded_status); + +@@ -1644,6 +1548,7 @@ public: * @return Returns values from 0 to 15. */ uint8_t getARC(void); @@ -934,7 +952,7 @@ index c029c8e..c9d612a 100644 /** * Set the transmission @ref Datarate -@@ -1893,17 +1804,6 @@ private: +@@ -1896,18 +1801,6 @@ private: */ bool _init_pins(); @@ -949,16 +967,17 @@ index c029c8e..c9d612a 100644 - * @param mode HIGH to take this unit off the SPI bus, LOW to put it on - */ - void csn(bool mode); - +- /** * Set chip enable -@@ -2412,4 +2312,4 @@ private: - * Use `ctrl+c` to quit at any time. - */ - --#endif // __RF24_H__ -\ No newline at end of file -+#endif // __RF24_H__ + * +diff --git a/RF24_hal.cpp b/RF24_hal.cpp +new file mode 100644 +index 0000000..3cc78e4 +--- /dev/null ++++ b/RF24_hal.cpp +@@ -0,0 +1 @@ ++#include "RF24_hal.h" diff --git a/RF24_hal.h b/RF24_hal.h new file mode 100644 index 0000000..baceab3 diff --git a/src/CHANGES.md b/src/CHANGES.md index 61b6cc12..b1e93d32 100644 --- a/src/CHANGES.md +++ b/src/CHANGES.md @@ -1,5 +1,11 @@ # Development Changes +## 0.8.109 - 2024-04-09 +* fix hal patch + +## 0.8.108 - 2024-04-09 +* point to git SHA for `NRF24` library + ## 0.8.107 - 2024-04-08 * fix boot loop on `reboot on midnight` feature #1542, #1599, #1566, #1571 * fix German translation #1569 diff --git a/src/defines.h b/src/defines.h index 60af67f6..7e050bb4 100644 --- a/src/defines.h +++ b/src/defines.h @@ -13,7 +13,7 @@ //------------------------------------- #define VERSION_MAJOR 0 #define VERSION_MINOR 8 -#define VERSION_PATCH 107 +#define VERSION_PATCH 108 //------------------------------------- typedef struct { uint8_t ch; diff --git a/src/network/AhoyNetwork.h b/src/network/AhoyNetwork.h index c0ea55c2..b5778f7d 100644 --- a/src/network/AhoyNetwork.h +++ b/src/network/AhoyNetwork.h @@ -93,8 +93,8 @@ class AhoyNetwork { bool getAvailNetworks(JsonObject obj) { if(!mScanActive) { mScanActive = true; - //if(NetworkState::GOT_IP != mStatus) - // WiFi.disconnect(); + if(NetworkState::GOT_IP != mStatus) + WiFi.disconnect(); WiFi.scanNetworks(true, true); return false; } diff --git a/src/platformio.ini b/src/platformio.ini index a831f7c2..53a56dd1 100644 --- a/src/platformio.ini +++ b/src/platformio.ini @@ -26,7 +26,8 @@ extra_scripts = lib_deps = https://github.com/esphome/ESPAsyncWebServer @ ^3.1.0 - https://github.com/nRF24/RF24 @ 1.4.8 + https://github.com/nRF24/RF24.git#v1.4.8 + paulstoffregen/Time @ ^1.6.1 https://github.com/bertmelis/espMqttClient#v1.6.0 bblanchon/ArduinoJson @ ^6.21.3 From 77914076604823bc0c4d6d4b3ddba07bbd1aa1a4 Mon Sep 17 00:00:00 2001 From: Sebastian Rothe Date: Thu, 11 Apr 2024 00:33:19 +0200 Subject: [PATCH 019/107] 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 @@
From c58e29c6a908634eca44aea3586bbf9ab04972f8 Mon Sep 17 00:00:00 2001 From: lumapu Date: Thu, 11 Apr 2024 20:37:06 +0200 Subject: [PATCH 020/107] 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 021/107] 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 022/107] 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 023/107] 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; } From 1a9da99f74b418183ffd671d14727cddb11cde1e Mon Sep 17 00:00:00 2001 From: geronet1 Date: Fri, 12 Apr 2024 11:46:46 +0200 Subject: [PATCH 024/107] =?UTF-8?q?Total=20Summe=20in=20=C3=9Cbersicht?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/web/html/index.html | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/web/html/index.html b/src/web/html/index.html index 954ee012..a811dd2a 100644 --- a/src/web/html/index.html +++ b/src/web/html/index.html @@ -14,6 +14,7 @@

System Infos: +

@@ -111,6 +112,8 @@ function parseIv(obj, ts) { var p = div(["none"]); + var total = 0; + var count = 0; for(var i of obj) { var icon = iconSuccess; var cl = "icon-success"; @@ -131,7 +134,9 @@ avail += "{#NOT_PRODUCING}"; else { icon = iconSuccessFull; - avail += "{#PRODUCING} " + i.cur_pwr + "W"; + avail += "{#PRODUCING} " + i.cur_pwr + " W"; + total += i.cur_pwr; + count += 1; } } @@ -149,6 +154,12 @@ } } document.getElementById("iv").replaceChildren(p); + + if (count > 1) { + p.append(svg(iconInfo, 30, 30, "icon icon-info"), span("Total: " + total + " W"), br()); + document.getElementById("total").replaceChildren(p); + document.getElementById("total").appendChild(div(["class=\"hr\""])); + } } function parseWarn(warn) { @@ -165,7 +176,7 @@ p.append(svg(iconInfo, 30, 30, "icon icon-info"), span("{#UPDATE_AVAIL}: " + release), br()); else if(getVerInt("{#VERSION}") > getVerInt(release)) p.append(svg(iconInfo, 30, 30, "icon icon-info"), span("{#USING_DEV_VERSION} {#VERSION}. {#DEV_ISSUE_RELEASE_VERSION}: " + release), br()); - else + else p.append(svg(iconInfo, 30, 30, "icon icon-info"), span("{#RELEASE_INSTALLED}: " + release), br()); } From 806e264dc6490e293ccd5e09f916899efcee792b Mon Sep 17 00:00:00 2001 From: Patrick Bollmann Date: Sat, 13 Apr 2024 19:43:50 +0200 Subject: [PATCH 025/107] Disable upload and import buttons when no file is selected --- src/web/html/colorBright.css | 1 + src/web/html/colorDark.css | 1 + src/web/html/setup.html | 24 ++++++++++++++++++++++-- src/web/html/style.css | 8 +++++++- src/web/html/update.html | 25 +++++++++++++++++++++++-- 5 files changed, 54 insertions(+), 5 deletions(-) diff --git a/src/web/html/colorBright.css b/src/web/html/colorBright.css index aedd05d4..ebf4f12a 100644 --- a/src/web/html/colorBright.css +++ b/src/web/html/colorBright.css @@ -12,6 +12,7 @@ --nav-bg: #333; --primary: #006ec0; + --primary-disabled: #ccc; --primary-hover: #044e86; --secondary: #0072c8; --nav-active: #555; diff --git a/src/web/html/colorDark.css b/src/web/html/colorDark.css index b5b1a72b..23e7a2cf 100644 --- a/src/web/html/colorDark.css +++ b/src/web/html/colorDark.css @@ -12,6 +12,7 @@ --nav-bg: #333; --primary: #004d87; + --primary-disabled: #ccc; --primary-hover: #023155; --secondary: #0072c8; --nav-active: #555; diff --git a/src/web/html/setup.html b/src/web/html/setup.html index e0c1693a..a7e4d983 100644 --- a/src/web/html/setup.html +++ b/src/web/html/setup.html @@ -321,8 +321,8 @@
-
-
+
+
@@ -612,6 +612,26 @@ var obj = {cmd: "discovery_cfg", token: "*"} getAjax("/api/setup", apiCbMqtt, "POST", JSON.stringify(obj)); } + // Wait for the DOM to be fully loaded + document.addEventListener('DOMContentLoaded', () => { + // Get references to the file input and button elements + const fileInput = document.querySelector('#importFileInput'); + const button = document.querySelector('#importButton'); + // Initially disable the button + button.disabled = true; + button.title = "Please select a file first"; + // Listen for changes on the file input + fileInput.addEventListener('change', () => { + // Enable or disable the button based on whether a file is selected + if (fileInput.value) { + button.disabled = false; + button.title = ""; // Clear the tooltip when a file is selected + } else { + button.disabled = true; + button.title = "Please select a file first"; // Show the tooltip when no file is selected + } + }); + }); function hide() { document.getElementById("form").submit(); diff --git a/src/web/html/style.css b/src/web/html/style.css index 60805e19..2866dda1 100644 --- a/src/web/html/style.css +++ b/src/web/html/style.css @@ -563,7 +563,13 @@ input.btn { cursor: pointer; } -input.btn:hover { +input.btn:disabled { + background-color: var(--primary-disabled); + color: #888; + cursor: not-allowed; +} + +input.btn:not(:disabled):hover { background-color: #044e86; } diff --git a/src/web/html/update.html b/src/web/html/update.html index ebdbb7ab..a72c6536 100644 --- a/src/web/html/update.html +++ b/src/web/html/update.html @@ -12,8 +12,8 @@ {#SELECT_FILE} (*.bin)

{#INSTALLED_VERSION}:

- - + +
@@ -23,6 +23,27 @@
{#HTML_FOOTER}