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 _

  • SalamanderMA
    link
    fedilink
    arrow-up
    11
    ·
    7 hours ago

    Wuhuu! Not yet! I do have a few ideas on how to implement that. Since the size of messages is limited to 200 characters, and since trying to transmit too much data via meshtastic wouldn’t be very efficient, I am brainstorming about how to implement notifications and fetching in a somewhat compatible manner.

    One approach would be via some interface that displays the minimum amount of data (for example, first few letters of a post’s title, community, username). The user would “fetch” specific pieces of data, which then gets stored into the phone’s memory and this way one can populate the application with content without overloading the mesh.

    It’s not something I am too seriously considering actually making, I am just having a bit of fun.

    • juddy@mastodon.social
      link
      fedilink
      arrow-up
      1
      ·
      6 hours ago

      @Sal @squirrel I did something like this a few weeks ago wuth mosquitto and the mastodon client. (Also Jira)

      I think messages bled to msh because someone messaged my node to call me a wanker.

      • SalamanderMA
        link
        fedilink
        arrow-up
        1
        ·
        5 hours ago

        Where you able to interpret the MQTT messages directly from the computer? I have been trying to transform the messages that are output when using mosquitto_sub into the original protobuf packets, but I am having issues with that step.

        I think messages bled to msh because someone messaged my node to call me a wanker.

        Ah, might be! 😅 Were you using a public MQTT server? Or were you downlinking a lot of toots and ‘spamming’ them via RF?

          • SalamanderMA
            link
            fedilink
            arrow-up
            2
            ·
            4 hours ago

            Cool, thanks for sharing!

            Where I run into problems is in the following step:

            def on_mqtt_message(client, userdata, msg):
                try:
                    message = msg.payload.decode("utf-8", errors="replace")
            
            

            If the message is published by a meshtastic client, then my “message” looks something like:

            ̴=����*!�_��i��}M������jUJC�'�!���c�^5yk�=C��gE�����������LongFast?`

            So, I think that the UTF-8 decoding does not work on the raw payload, and that the payload needs to be processed into a mesh.protobuf. At least that is what I understand so far.

            The messages that you published via MQTT were messages sent from the Meshtastic client, or were they messages that you posted using mosquitto_pub? If this did work on packets that the meshtastic client published to MQTT then I must be overlooking something… Again, thanks for sharing!

              • SalamanderMA
                link
                fedilink
                arrow-up
                1
                ·
                edit-2
                3 hours ago

                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()
                
                
              • SalamanderMA
                link
                fedilink
                arrow-up
                1
                ·
                4 hours ago

                Interesting! Thanks, I need to continue testing/studying.