Browse Source

0.8.110

* add disable retain flag #1582
pull/1586/head
lumapu 9 months ago
parent
commit
e76722ad33
  1. 2
      src/CHANGES.md
  2. 4
      src/config/settings.h
  3. 3
      src/publisher/pubMqtt.h
  4. 1
      src/web/RestApi.h
  5. 9
      src/web/html/setup.html
  6. 5
      src/web/lang.json
  7. 1
      src/web/web.h

2
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

4
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<uint16_t>(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<bool>(obj, F("retain"), &mCfg.mqtt.enableRetain);
}
}

3
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++;

1
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) {

9
src/web/html/setup.html

@ -246,6 +246,10 @@
<span id="apiResultMqtt"></span>
</div>
</div>
<div class="row mb-3">
<div class="col-8 col-sm-3">{#RETAIN}</div>
<div class="col-4 col-sm-9"><input type="checkbox" name="retain"/></div>
</div>
</fieldset>
</div>
@ -282,7 +286,7 @@
<div id="screenSaver"></div>
<div class="row mb-3" id="luminanceOption">
<div class="col-12 col-sm-3 my-2">{#DISP_LUMINANCE}</div>
<div class="col-12 col-sm-9"><input type="number" name="disp_cont" min="0" max="255"></select></div>
<div class="col-12 col-sm-9"><input type="number" name="disp_cont" min="0" max="255"></div>
</div>
<p class="des">{#DISP_PINOUT}</p>
<div id="dispPins"></div>
@ -291,7 +295,7 @@
<p class="des">{#GRAPH_OPTIONS}</p>
<div class="row mb-3">
<div class="col-12 col-sm-3 my-2">{#GRAPH_SHOW_RATIO}</div>
<div class="col-12 col-sm-9"><input type="number" name="disp_graph_ratio" min="0" max="100"></select></div>
<div class="col-12 col-sm-9"><input type="number" name="disp_graph_ratio" min="0" max="100"></div>
</div>
<div id="graphSize"></div>
</div>
@ -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) {

5
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 &Auml;nderung gab. Ein Wert von '0' deaktiviert das fixe Intervall, die Wechselrichterdaten werden &uuml;bertragen, sobald neue zur Verf&uuml;gung stehen. (Standard: 0)"
},
{
"token": "RETAIN",
"en": "enable retain flag",
"de": "'Retain Flag' aktivieren"
},
{
"token": "DISPLAY_CONFIG",
"en": "Display Config",

1
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");

Loading…
Cancel
Save