fix(mqtt): honor preset retain policy for status publishes
publishStatusToSlot hardcoded the retain flag to true, ignoring the preset's allow_retain field that the packets and neighbors paths already respect. The waev preset (allow_retain=false, MeshCore topic style) has therefore been publishing retained status to a broker that rejects the retain flag; the same would now apply to meshrank, which just gained status publishing. Use slot.preset->allow_retain, defaulting to true for custom slots to preserve their existing behavior.
This commit is contained in:
1 parent
b3bd5ecd3c
commit
028a5dcadd
2 files changed
+7
-3
No files matched your search
@@ -2080,7 +2080,11 @@ void MQTTBridge::publishStatusToSlot(int index) {
|
||||
);
|
||||
|
||||
if (len > 0) {
|
||||
int result = slot.client->publish(status_topic, 1, true, json_buffer, strlen(json_buffer));
|
||||
// Honor the preset's retain policy, as the packets/neighbors paths do —
|
||||
// brokers that set allow_retain=false (meshrank, waev) reject retained
|
||||
// publishes. Custom slots keep the long-standing retained status behavior.
|
||||
bool use_retain = slot.preset ? slot.preset->allow_retain : true;
|
||||
int result = slot.client->publish(status_topic, 1, use_retain, json_buffer, strlen(json_buffer));
|
||||
if (result <= 0) {
|
||||
MQTT_DEBUG_PRINTLN("MQTT%d status publish failed", index + 1);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user