From 028a5dcaddd69b4be80cc595d33d450be1c46e8b Mon Sep 17 00:00:00 2001 From: agessaman Date: Fri, 17 Jul 2026 08:01:09 -0700 Subject: [PATCH] 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. --- MQTT_IMPLEMENTATION.md | 4 ++-- src/helpers/bridges/MQTTBridge.cpp | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/MQTT_IMPLEMENTATION.md b/MQTT_IMPLEMENTATION.md index 60ec72f7..f6f2a6b0 100644 --- a/MQTT_IMPLEMENTATION.md +++ b/MQTT_IMPLEMENTATION.md @@ -296,7 +296,7 @@ set mqtt3.preset meshrank set mqtt3.token FE1B34242C5938C39225310081FD6718 ``` -The token is generated on the MeshRank website and is tied to your account. MeshRank receives the same message types as any other preset (`status`, `packets`, `raw`, `neighbors`), each under `meshrank/uplink/{token}/{device_id}/`, subject to the usual `mqtt.status`/`mqtt.raw`/`mqtt.neighbors` toggles. +The token is generated on the MeshRank website and is tied to your account. MeshRank receives the same message types as any other preset (`status`, `packets`, `raw`, `neighbors`), each under `meshrank/uplink/{token}/{device_id}/`, subject to the usual `mqtt.status`/`mqtt.raw`/`mqtt.neighbors` toggles. Its broker does not accept the retain flag, so those publishes go out unretained. #### Example: Configure MeshMapper on Slot 3 ```bash @@ -500,7 +500,7 @@ The CLI commands are organized into two levels: The bridge publishes to four main topics with the following structure: ### Status Topic: `meshcore/{IATA}/{DEVICE_PUBLIC_KEY}/status` -Device connection status and metadata (retained messages). +Device connection status and metadata, QoS 1. Retained, except on presets whose broker rejects the retain flag (`meshrank`, `waev`). ### Packets Topic: `meshcore/{IATA}/{DEVICE_PUBLIC_KEY}/packets` Full packet data with RF characteristics and metadata. diff --git a/src/helpers/bridges/MQTTBridge.cpp b/src/helpers/bridges/MQTTBridge.cpp index 93959837..9a9d4628 100644 --- a/src/helpers/bridges/MQTTBridge.cpp +++ b/src/helpers/bridges/MQTTBridge.cpp @@ -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); }