Made a python script to create posts via meshtastic messages. If you can see this, the test worked! Posting from the park with no mobile data _
Made a python script to create posts via meshtastic messages. If you can see this, the test worked! Posting from the park with no mobile data _
@Sal https://mastodon.social/@juddy/113605744069861333
I took some inspiration from your code and looked into how to decode the mesh.protobuf packets and managed to decode the MQTT messages! From the raw byte stream I had to remove the first two bytes of the payload and then process it as a MeshPacket to get the data in its readable form.
Once processed, the payload from MQTT looks like this:
from: 1501080443 to: 3294953195 channel: 8 encrypted: "u\003\221n\354U\373\257\006[" id: 882625294 rx_time: 1739046557 hop_limit: 3 priority: HIGH hop_start: 3
So, looking at your code, I think that what happened was that the messages were being posted to Mastodon only due to the on_receive() function. The MQTT messages would also trigger this function call when the node downlinks the MQTT message.
What is useful about triggering the messages directly from the MQTT stream is that it is then possible to create a general application that listens to one or multiple MQTT servers without the need for a node to downlink.
Here is the MeshPacket code:
import mesh_pb2 import paho.mqtt.client as mqtt # MQTT Config MQTT_BROKER = "MQTT IP" MQTT_PORT = 1883 MQTT_TOPIC = "#" def onMessage(client, userdata, msg): print(f"Received message on {msg.topic}") proto_msg = mesh_pb2.MeshPacket() print("Raw:\n\n") print(msg.payload) proto_msg.ParseFromString(msg.payload[2::]) print("\n\nParsed:\n\n") print(proto_msg) client = mqtt.Client() client.on_message = onMessage client.connect(MQTT_BROKER, MQTT_PORT, 60) client.subscribe(MQTT_TOPIC) client.loop_forever()
Interesting! Thanks, I need to continue testing/studying.