From e71758457b0088ecd51cddf22387b66565d5a5b9 Mon Sep 17 00:00:00 2001 From: Kevin Hester Date: Sat, 10 Apr 2021 10:55:56 +0800 Subject: [PATCH] use production mqtt server --- bin/mqtt-listen.sh | 2 +- bin/mqtt-send-status.sh | 2 +- docs/software/mqtt.md | 10 ++++++---- src/mqtt/MQTT.cpp | 7 +++---- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/bin/mqtt-listen.sh b/bin/mqtt-listen.sh index 112d42bd..73ccb50a 100755 --- a/bin/mqtt-listen.sh +++ b/bin/mqtt-listen.sh @@ -1,3 +1,3 @@ -mosquitto_sub -h test.mosquitto.org -v -t mesh/stat/\# -t mesh/json/\# +mosquitto_sub -h mqtt.meshtastic.org -v -t \$SYS/\# -t msh/+/stat/\# -t msh/+/json/\# # mosquitto_sub -h test.mosquitto.org -v -t mesh/\# -F "%j" diff --git a/bin/mqtt-send-status.sh b/bin/mqtt-send-status.sh index d1456023..4df8a895 100755 --- a/bin/mqtt-send-status.sh +++ b/bin/mqtt-send-status.sh @@ -1 +1 @@ -mosquitto_pub -h test.mosquitto.org -t mesh/stat/FakeNode -m online -d +mosquitto_pub -h mqtt.meshtastic.org -u meshdev -P large4cats -t msh/1/stat/FakeNode -m online -d diff --git a/docs/software/mqtt.md b/docs/software/mqtt.md index 80daf06a..62d8d66d 100644 --- a/docs/software/mqtt.md +++ b/docs/software/mqtt.md @@ -72,15 +72,17 @@ Any gateway-device will contact the MQTT broker. ### Topics -* The "/mesh/crypt/CHANNELID/NODEID" [topic](https://www.hivemq.com/blog/mqtt-essentials-part-5-mqtt-topics-best-practices/) will be used for (encrypted) messages sent from/to a mesh. +* The "/msh/1/c/CHANNELID/NODEID" [topic](https://www.hivemq.com/blog/mqtt-essentials-part-5-mqtt-topics-best-practices/) will be used for (encrypted) messages sent from/to a mesh. (The "1" in this path is for protocol version 1, other values are reserved. "c" is for "enCrypted") Gateway nodes will foward any MeshPacket from a local mesh channel with uplink_enabled. The packet (encapsulated in a ServiceEnvelope) will remain encrypted with the key for the specified channel. -For any channels in the gateway node with downlink_enabled, the gateway node will forward packets from MQTT to the local mesh. It will do this by subscribing to mesh/crypt/CHANNELID/# and forwarding relevant packets. +For any channels in the gateway node with downlink_enabled, the gateway node will forward packets from MQTT to the local mesh. It will do this by subscribing to msh/1/c/CHANNELID/# and forwarding relevant packets. -* If the channelid 'well known'/public it could be decrypted by a web service (if the web service was provided with the associated channel key), in which case it will be decrypted by a web service and appear at "mesh/clear/CHANNELID/NODEID/PORTID". +* If the channelid 'well known'/public it could be decrypted by a web service (if the web service was provided with the associated channel key), in which case it will be decrypted by a web service and appear at "msh/1/CLEAR/CHANNELID/NODEID/PORTID". -* If it was possible to republish on mesh/clear/... and the PORTID is wellknown (i.e. the protobufs needed for decoding it are in the master github), it will be decoded and republished as JSON on mesh/json/CHANNELID/NODEID/PortName. This is to facilitate the development of third party apps to visualize 'live' node positions and 'texts' (for users that have opted to send on those explicitly public channels). +* If it was possible to republish on msh/1/CLEAR/... and the PORTID is wellknown (i.e. the protobufs needed for decoding it are in the master github), it will be decoded and republished as JSON on msh/1/JSON/CHANNELID/NODEID/PortName. This is to facilitate the development of third party apps to visualize 'live' node positions and 'texts' (for users that have opted to send on those explicitly public channels). + +Note: Normally "CLEAR" is simply "clear" (for cleartext), but during development we might run **multiple** testing services, and in that case those service might appear using a different string here (i.e. "cleardev" etc...). Similarly normally "JSON" is "json", but other values might be used. FIXME, consider how text message global mirroring could scale (or not) FIXME, possibly don't global mirror text messages - instead rely on matrix/riot? diff --git a/src/mqtt/MQTT.cpp b/src/mqtt/MQTT.cpp index 2a6a221d..8a27eb4c 100644 --- a/src/mqtt/MQTT.cpp +++ b/src/mqtt/MQTT.cpp @@ -9,8 +9,8 @@ MQTT *mqtt; -String statusTopic = "mesh/stat/"; -String cryptTopic = "mesh/crypt/"; // mesh/crypt/CHANNELID/NODEID +String statusTopic = "msh/1/stat/"; +String cryptTopic = "msh/1/c/"; // msh/1/c/CHANNELID/NODEID void MQTT::mqttCallback(char *topic, byte *payload, unsigned int length) { @@ -68,8 +68,7 @@ void MQTT::reconnect() DEBUG_MSG("Connecting to MQTT server\n", serverAddr); auto myStatus = (statusTopic + owner.id); - // bool connected = pubSub.connect(nodeId.c_str(), "meshdev", "apes4cats", myStatus.c_str(), 1, true, "offline"); - bool connected = pubSub.connect(owner.id, myStatus.c_str(), 1, true, "offline"); + bool connected = pubSub.connect(owner.id, "meshdev", "large4cats", myStatus.c_str(), 1, true, "offline"); if (connected) { DEBUG_MSG("MQTT connected\n"); enabled = true; // Start running background process again