meshtastic_mqtt

- Unnamed repository; edit this file 'description' to name the repository.
git clone git://git.acid.vegas/-c.git
Log | Files | Refs | Archive | README | LICENSE

README.md (5572B)

      1 # Meshtastic MQTT Parser
      2 
      3 A lightweight Python library for parsing Meshtastic MQTT messages into JSON format. This tool makes it easy to build applications that interact with Meshtastic mesh networks via MQTT.
      4 
      5 ## Overview
      6 
      7 This library connects to a Meshtastic MQTT broker and decodes various message types into JSON format, making it simple to process Meshtastic mesh network data in your Python applications.
      8 
      9 ## Features
     10 
     11 - Connects to any Meshtastic MQTT broker
     12 - Decrypts encrypted messages
     13 - Parses all standard Meshtastic message types
     14 - Outputs clean JSON format
     15 - Message type filtering support
     16 - Simple command-line interface
     17 
     18 ## Installation
     19 
     20 Install from PyPI:
     21 
     22 ```bash
     23 pip install meshtastic-mqtt-json
     24 ```
     25 
     26 ## usage
     27 ```bash
     28 meshtastic_mqtt_json [options]
     29 ```
     30 
     31 ```python
     32 from meshtastic_mqtt_json import MeshtasticMQTT
     33 
     34 # Create client instance
     35 client = MeshtasticMQTT()
     36 
     37 # Register callbacks for specific message types
     38 def on_text_message(json_data):
     39     print(f'Received text message: {json_data["decoded"]["payload"]}')
     40 
     41 def on_position(json_data):
     42     print(f'Received position update: {json_data["decoded"]["payload"]}')
     43 
     44 client.register_callback('TEXT_MESSAGE_APP', on_text_message)
     45 client.register_callback('POSITION_APP', on_position)
     46 
     47 # Connect to MQTT broker
     48 client.connect(
     49     broker='mqtt.meshtastic.org',
     50     port=1883,
     51     root='msh/US/2/e/',
     52     channel='LongFast',
     53     username='meshdev',
     54     password='large4cats',
     55     key='AQ=='
     56 )
     57 ```
     58 
     59 ### Callback System
     60 The library provides a callback system that allows you to register handlers for specific message types. Each callback function receives a JSON object containing the parsed message data.
     61 
     62 ```python
     63 # Register a callback
     64 client.register_callback('MESSAGE_TYPE', callback_function)
     65 
     66 # Unregister a callback
     67 client.unregister_callback('MESSAGE_TYPE')
     68 ```
     69 
     70 The callback function should accept a single parameter that will receive the JSON data:
     71 ```python
     72 def my_callback(json_data):
     73     # json_data contains the parsed message
     74     print(json_data)
     75 ```
     76 
     77 If no callback is registered for a message type, the message will be printed to the console by default.
     78 
     79 ### Command Line Options
     80 | Option       | Description                   | Default               |
     81 | ------------ | ------------------------------|---------------------- |
     82 | `--broker`   | MQTT broker address           | `mqtt.meshtastic.org` |
     83 | `--port`     | MQTT broker port              | `1883`                |   
     84 | `--root`     | Root topic                    | `msh/US/2/e/`         |
     85 | `--channel`  | Channel name                  | `LongFast`            |
     86 | `--username` | MQTT username                 | `meshdev`             |
     87 | `--password` | MQTT password                 | `large4cats`          |
     88 | `--key`      | Encryption key                | `AQ==`                |
     89 | `--filter`   | Filter specific message types |                       |
     90 
     91 ### Filter Example
     92 ```bash
     93 python meshtastic_mqtt_json.py --filter "NODEINFO,POSITION,TEXT_MESSAGE"
     94 ```
     95 
     96 
     97 ## Supported Message Types
     98 
     99 The library supports parsing of the following Meshtastic message types:
    100 | Message Type                    | Description                   |
    101 | ------------------------------- | ----------------------------- |
    102 | **ADMIN_APP**                   | Administrative messages       |
    103 | **ATAK_FORWARDER**              | ATAK forwarding messages      |
    104 | **ATAK_PLUGIN**                 | ATAK plugin messages          |
    105 | **AUDIO_APP**                   | Audio messages                |
    106 | **DETECTION_SENSOR_APP**        | Sensor detection data         |
    107 | **IP_TUNNEL_APP**               | IP tunneling messages         |
    108 | **NEIGHBORINFO_APP**            | Neighbor information          |
    109 | **NODEINFO_APP**                | Node information and details  |
    110 | **PAXCOUNTER_APP**              | People counter data           |
    111 | **POSITION_APP**                | GPS position updates          |
    112 | **PRIVATE_APP**                 | Private messages              |
    113 | **RANGE_TEST_APP**              | Range testing data            |
    114 | **REMOTE_HARDWARE_APP**         | Remote hardware control       |
    115 | **REPLY_APP**                   | Reply messages                |
    116 | **ROUTING_APP**                 | Routing information           |
    117 | **SERIAL_APP**                  | Serial communication          |
    118 | **SIMULATOR_APP**               | Simulator messages            |
    119 | **STORE_FORWARD_APP**           | Store and forward messages    |
    120 | **TELEMETRY_APP**               | Device telemetry data         |
    121 | **TEXT_MESSAGE_APP**            | Plain text messages           |
    122 | **TEXT_MESSAGE_COMPRESSED_APP** | Compressed text messages      |
    123 | **TRACEROUTE_APP**              | Network route tracing         |
    124 | **WAYPOINT_APP**                | Waypoint information          |
    125 | **ZPS_APP**                     | Zone/Position System messages |
    126 
    127 
    128 ## Roadmap
    129 - [ ] Add support for custom node ID & names for the client
    130 - [ ] Add support for custom MQTT servers besides the official Meshtastic server
    131 - [ ] Create a PyPi package for easy import into other projects
    132 - [ ] Create an examples folder with use cases for the library, such as an IRC relay, cli chat, logging, etc.
    133 
    134 ___
    135 
    136 ###### Mirrors for this repository: [acid.vegas](https://git.acid.vegas/meshtastic_mqtt_json) • [SuperNETs](https://git.supernets.org/acidvegas/meshtastic_mqtt_json) • [GitHub](https://github.com/acidvegas/meshtastic_mqtt_json) • [GitLab](https://gitlab.com/acidvegas/meshtastic_mqtt_json) • [Codeberg](https://codeberg.org/acidvegas/meshtastic_mqtt_json)