fix: publish offline status and reconnect when mqtt.iata changes

This commit is contained in:
Jared Dohrman
2026-04-30 16:56:23 +10:00
parent 14d517d29c
commit 27c86b8e5a
4 changed files with 19 additions and 6 deletions
+1 -1
View File
@@ -51,7 +51,7 @@ Notes:
- `letsmesh-eu` and `letsmesh-us` remain off by default unless already configured in saved prefs
- if `mqtt.iata` is `UNSET`, `eastmesh-au`, `letsmesh-eu`, and `letsmesh-us` will not connect even if they are toggled on
- turning off a connected broker publishes a retained MQTT status update with `"status":"offline"` before the client disconnects
- changing `mqtt.iata` away from a configured value also publishes retained offline status to the old status topic before switching topics
- changing `mqtt.iata` away from a configured value also publishes retained offline status to the old status topic, restarts connected broker clients, and reconnects under the new topic path
Legacy dotted aliases are also accepted:
+1 -1
View File
@@ -222,7 +222,7 @@ Notes:
- the current MQTT server states are loaded when the page opens
- you can toggle each MQTT server on or off from this panel
- turning off a connected MQTT server publishes retained offline status before the client disconnects
- changing `mqtt.iata` away from a configured value publishes retained offline status to the old status topic before the new topic is used
- changing `mqtt.iata` away from a configured value publishes retained offline status to the old status topic, restarts connected broker clients, and reconnects under the new topic path
- if all three servers are enabled at once, the panel shows a warning recommending two at most
## `/stats` Overview
+1 -1
View File
@@ -570,7 +570,7 @@ releases:
text: "Published explicit retained offline status before a connected broker is toggled off, matching operator expectations without relying on last-will behavior that only fires on unclean disconnects."
- type: fixed
area: mqtt
text: "Published retained offline status to the old status topic before `mqtt.iata` changes, preventing stale online status from remaining under the previous IATA path."
text: "Published retained offline status to the old status topic before `mqtt.iata` changes, then restarted connected broker clients so they reconnect and publish online status under the new IATA path."
- type: docs
area: mqtt
text: "Updated the CLI and web-panel docs to describe retained offline status publishing for broker toggles and IATA changes."
+16 -3
View File
@@ -1164,17 +1164,30 @@ bool MQTTUplink::setIata(const char* iata) {
for (size_t i = 0; cleaned[i] != 0; ++i) {
cleaned[i] = toupper(static_cast<unsigned char>(cleaned[i]));
}
if (strcmp(cleaned, _prefs.iata) != 0 && !isUnsetIataValue(_prefs.iata)) {
bool changed = strcmp(cleaned, _prefs.iata) != 0;
if (changed && !isUnsetIataValue(_prefs.iata)) {
publishStatus(false);
}
if (strcmp(cleaned, MQTT_UNSET_IATA) == 0) {
StrHelper::strncpy(_prefs.iata, MQTT_UNSET_IATA, sizeof(_prefs.iata));
refreshIdentityStrings();
return savePrefs();
bool saved = savePrefs();
if (changed) {
for (BrokerState& broker : _brokers) {
destroyBroker(broker);
}
}
return saved;
}
StrHelper::strncpy(_prefs.iata, cleaned, sizeof(_prefs.iata));
refreshIdentityStrings();
return savePrefs();
bool saved = savePrefs();
if (changed) {
for (BrokerState& broker : _brokers) {
destroyBroker(broker);
}
}
return saved;
}
bool MQTTUplink::setOwnerPublicKey(const char* owner_public_key) {