geoffwhittington / meshtastic-bridge

MIT License
30 stars 6 forks source link

How to use? #1

Open D4rk4 opened 1 year ago

D4rk4 commented 1 year ago

Hello, I have a T-ECHO device without wifi, may I bridge this device connected to a serial port with a regular MQTT meshtastic server with two-way communication with other nodes? If yes, may you provide a config example for a device connected via /dev/ttyACM0?

geoffwhittington commented 1 year ago

Thank-you for your question. You have inspired me to add a couple of sample configs under the directory use-cases. With the latest 0.6 you should be able to connect with the following config.

In this example, the bridge listens for all radio messages on radio1 connected on /dev/ttyACM0. When a packet is detected it publishes only TEXT_MESSAGE_APP messages to a certain MQTT topic meshtastic/radio-network1. Simultaneously, it listens for all messages posted to the same topic on the same MQTT server. It simply forwards the packet to all radios in the mesh. If the MQTT message contains a full packet with a proper to you could leave out the to: in the yaml.

There are ways of rewriting the messages using the bridge but this should illustrate what you're requesting. As this is a work-in-progress I expect some feedback and we can iterate over what works/doesn't work. Thanks for trying this experimental bridge.

To run: copy this to config.yaml and run python main.py.

devices:
  - name: radio1
    serial: "/dev/ttyACM0"
mqtt_servers:
  - name: external
    server: broker.hivemq.com
    port: 1883
    topic: meshtastic/radio-network1
    pipelines:
      mqtt-to-radio:
        - radio_message_plugin:
            device: radio1
            to: "^all"
pipelines:
  pipeline1:
    - debugger:
        log_level: debug
  radio-to-mqtt:
    - message_filter:
        app:
          allow:
            - "TEXT_MESSAGE_APP"
    - mqtt_plugin:
        name: external
        topic: meshtastic/radio-network1