mirror of
https://github.com/agessaman/MeshCore.git
synced 2026-08-28 22:08:28 +00:00
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:
@@ -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.
|
||||
|
||||
@@ -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