Merge pull request #1280 from michaelkleinhenz/txt-mqtt

Plaintext publish to MQTT
pull/1283/head
Jm Casler 2022-03-08 15:35:46 -08:00 zatwierdzone przez GitHub
commit f5369c3f1b
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
1 zmienionych plików z 9 dodań i 0 usunięć

Wyświetl plik

@ -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);
}
}
}