Add RAK4631 Ethernet Gateway with working JSON output to MQTT

This commit is contained in:
beegee-tokyo
2024-09-09 11:56:37 +08:00
parent e470619e3d
commit a5b79528b3
7 changed files with 712 additions and 8 deletions

View File

@@ -379,13 +379,13 @@ void MQTT::sendSubscriptions()
std::string topic = cryptTopic + channels.getGlobalId(i) + "/+";
LOG_INFO("Subscribing to %s\n", topic.c_str());
pubSub.subscribe(topic.c_str(), 1); // FIXME, is QOS 1 right?
#ifndef ARCH_NRF52 // JSON is not supported on nRF52, see issue #2804
// #ifndef ARCH_NRF52 // JSON is not supported on nRF52, see issue #2804 ### Fixed by using ArduinoJSON ###
if (moduleConfig.mqtt.json_enabled == true) {
std::string topicDecoded = jsonTopic + channels.getGlobalId(i) + "/+";
LOG_INFO("Subscribing to %s\n", topicDecoded.c_str());
pubSub.subscribe(topicDecoded.c_str(), 1); // FIXME, is QOS 1 right?
}
#endif // ARCH_NRF52
// #endif // ARCH_NRF52
}
}
#if !MESHTASTIC_EXCLUDE_PKI
@@ -480,7 +480,7 @@ void MQTT::publishQueuedMessages()
publish(topic.c_str(), bytes, numBytes, false);
#ifndef ARCH_NRF52 // JSON is not supported on nRF52, see issue #2804
// #ifndef ARCH_NRF52 // JSON is not supported on nRF52, see issue #2804 ### Fixed by using ArduinoJson ###
if (moduleConfig.mqtt.json_enabled) {
// handle json topic
auto jsonString = MeshPacketSerializer::JsonSerialize(env->packet);
@@ -496,7 +496,7 @@ void MQTT::publishQueuedMessages()
publish(topicJson.c_str(), jsonString.c_str(), false);
}
}
#endif // ARCH_NRF52
// #endif // ARCH_NRF52
mqttPool.release(env);
}
}
@@ -562,7 +562,7 @@ void MQTT::onSend(const meshtastic_MeshPacket &mp, const meshtastic_MeshPacket &
publish(topic.c_str(), bytes, numBytes, false);
#ifndef ARCH_NRF52 // JSON is not supported on nRF52, see issue #2804
// #ifndef ARCH_NRF52 // JSON is not supported on nRF52, see issue #2804 ### Fixed by using ArduinoJson ###
if (moduleConfig.mqtt.json_enabled) {
// handle json topic
auto jsonString = MeshPacketSerializer::JsonSerialize((meshtastic_MeshPacket *)&mp_decoded);
@@ -573,7 +573,7 @@ void MQTT::onSend(const meshtastic_MeshPacket &mp, const meshtastic_MeshPacket &
publish(topicJson.c_str(), jsonString.c_str(), false);
}
}
#endif // ARCH_NRF52
// #endif // ARCH_NRF52
} else {
LOG_INFO("MQTT not connected, queueing packet\n");
if (mqttQueue.numFree() == 0) {