From 95874f0c2437b0eff5b0a75c84979e88bedf9a04 Mon Sep 17 00:00:00 2001 From: agessaman Date: Sun, 22 Mar 2026 11:06:37 -0700 Subject: [PATCH] Enhance MQTT bridge implementation to support a new MeshRank preset, allowing for token-based authentication and custom topic templates. Update CLI commands for slot management, including new commands for setting tokens and topics. Improve documentation to reflect these changes and provide examples for configuring the new preset. --- MQTT_IMPLEMENTATION.md | 44 ++++- examples/simple_repeater/MyMesh.h | 5 + examples/simple_room_server/MyMesh.h | 55 ++++++ src/helpers/CommonCLI.cpp | 223 ++++++++++++------------ src/helpers/CommonCLI.h | 44 ++++- src/helpers/MQTTPresets.h | 21 ++- src/helpers/bridges/MQTTBridge.cpp | 252 +++++++++++++++++++++------ src/helpers/bridges/MQTTBridge.h | 10 ++ 8 files changed, 473 insertions(+), 181 deletions(-) diff --git a/MQTT_IMPLEMENTATION.md b/MQTT_IMPLEMENTATION.md index faf29c3c3..3b5bdbba4 100644 --- a/MQTT_IMPLEMENTATION.md +++ b/MQTT_IMPLEMENTATION.md @@ -82,6 +82,7 @@ The MQTT bridge uses a slot-based architecture with up to 3 concurrent connectio | `analyzer-us` | mqtt-us-v1.letsmesh.net:443 | JWT (Ed25519) | WSS | | `analyzer-eu` | mqtt-eu-v1.letsmesh.net:443 | JWT (Ed25519) | WSS | | `meshmapper` | mqtt.meshmapper.cc:443 | JWT (Ed25519) | WSS | +| `meshrank` | meshrank.net:8883 | None (token in topic) | MQTT over TLS | | `custom` | User-configured | Username/Password | MQTT or WSS | | `none` | (disabled) | — | — | @@ -166,20 +167,33 @@ Each slot (1-3) supports the following commands: - `get mqttN.port` - Get custom server port for slot N - `get mqttN.username` - Get custom username for slot N - `get mqttN.password` - Get custom password for slot N +- `get mqttN.token` - Get per-slot token (e.g., MeshRank account token) +- `get mqttN.topic` - Get custom topic template for slot N #### Set Commands - `set mqtt1.preset analyzer-us` - Set slot 1 to LetsMesh Analyzer US - `set mqtt1.preset analyzer-eu` - Set slot 1 to LetsMesh Analyzer EU - `set mqtt1.preset meshmapper` - Set slot 1 to MeshMapper +- `set mqtt1.preset meshrank` - Set slot 1 to MeshRank (requires token) - `set mqtt1.preset custom` - Set slot 1 to custom broker (configure server/port/username/password) - `set mqtt1.preset none` - Disable slot 1 - `set mqttN.server ` - Set custom server hostname for slot N - `set mqttN.port ` - Set custom server port for slot N (1-65535) - `set mqttN.username ` - Set custom username for slot N - `set mqttN.password ` - Set custom password for slot N +- `set mqttN.token ` - Set per-slot token (required for MeshRank preset) +- `set mqttN.topic