Skip to content

Commit

Permalink
0.8.110
Browse files Browse the repository at this point in the history
* add disable retain flag #1582
  • Loading branch information
lumapu committed Apr 11, 2024
1 parent 50f7d7e commit e76722a
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/config/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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);
}
}

Expand Down
3 changes: 3 additions & 0 deletions src/publisher/pubMqtt.h
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
Expand Down
1 change: 1 addition & 0 deletions src/web/RestApi.h
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
9 changes: 7 additions & 2 deletions src/web/html/setup.html
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down Expand Up @@ -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>
Expand All @@ -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>
Expand Down Expand Up @@ -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) {
Expand Down
5 changes: 5 additions & 0 deletions src/web/lang.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions src/web/web.h
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit e76722a

Please sign in to comment.