From 428d062b9a3cfd4d0ffe0fb8850ca53d64aa8119 Mon Sep 17 00:00:00 2001 From: Michael Kleinhenz Date: Mon, 7 Mar 2022 20:45:50 +0100 Subject: [PATCH] Added txt message publishing on MQTT. --- src/mqtt/MQTT.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/mqtt/MQTT.cpp b/src/mqtt/MQTT.cpp index 26ef2a3e7..ffea9198b 100644 --- a/src/mqtt/MQTT.cpp +++ b/src/mqtt/MQTT.cpp @@ -13,6 +13,7 @@ MQTT *mqtt; String statusTopic = "msh/1/stat/"; String cryptTopic = "msh/1/c/"; // msh/1/c/CHANNELID/NODEID +String txtTopic = "msh/1/txt/"; // msh/1/txt/CHANNELID/NODEID void MQTT::mqttCallback(char *topic, byte *payload, unsigned int length) { @@ -193,5 +194,13 @@ void MQTT::onSend(const MeshPacket &mp, ChannelIndex chIndex) DEBUG_MSG("publish %s, %u bytes\n", topic.c_str(), numBytes); pubSub.publish(topic.c_str(), bytes, numBytes, false); + + // publish to txt topic for messages of type TEXT_MESSAGE_APP + if (mp.decoded.portnum == PortNum_TEXT_MESSAGE_APP) { + String plaintextTopic = txtTopic + channelId + "/" + owner.id; + DEBUG_MSG("publish txt %s, %u bytes\n", topic.c_str(), numBytes); + auto &p = mp.decoded; + pubSub.publish(plaintextTopic.c_str(), p.payload.bytes, p.payload.size, false); + } } }