Launch Week Day 5: Introducing Reachability for PHP.Learn More
Socket
Book a DemoSign in
Socket

meshtastic-mqtt-json

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

meshtastic-mqtt-json

A lightweight Python library for parsing Meshtastic MQTT messages

pipPyPI
Version
2.0.0
Maintainers
1

Meshtastic MQTT Parser

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.

Overview

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.

Features

  • Connects to any Meshtastic MQTT broker
  • Decrypts encrypted messages
  • Parses all standard Meshtastic message types
  • Outputs clean JSON format
  • Message type filtering support
  • Simple command-line interface

Installation

Install from PyPI:

pip install meshtastic-mqtt-json

usage

meshtastic_mqtt_json [options]
from meshtastic_mqtt_json import MeshtasticMQTT

# Create client instance
client = MeshtasticMQTT()

# Register callbacks for specific message types
def on_text_message(json_data):
    print(f'Received text message: {json_data["decoded"]["payload"]}')

def on_position(json_data):
    print(f'Received position update: {json_data["decoded"]["payload"]}')

client.register_callback('TEXT_MESSAGE_APP', on_text_message)
client.register_callback('POSITION_APP', on_position)

# Connect to MQTT broker
client.connect(
    broker='mqtt.meshtastic.org',
    port=1883,
    root='msh/US/2/e/',
    channel='LongFast',
    username='meshdev',
    password='large4cats',
    key='AQ=='
)

Callback System

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.

# Register a callback
client.register_callback('MESSAGE_TYPE', callback_function)

# Unregister a callback
client.unregister_callback('MESSAGE_TYPE')

The callback function should accept a single parameter that will receive the JSON data:

def my_callback(json_data):
    # json_data contains the parsed message
    print(json_data)

If no callback is registered for a message type, the message will be printed to the console by default.

Command Line Options

OptionDescriptionDefault
--brokerMQTT broker addressmqtt.meshtastic.org
--portMQTT broker port1883
--rootRoot topicmsh/US/2/e/
--channelChannel nameLongFast
--usernameMQTT usernamemeshdev
--passwordMQTT passwordlarge4cats
--keyEncryption keyAQ==
--filterFilter specific message types

Filter Example

python meshtastic_mqtt_json.py --filter "NODEINFO,POSITION,TEXT_MESSAGE"

Supported Message Types

The library supports parsing of the following Meshtastic message types:

Message TypeDescription
ADMIN_APPAdministrative messages
ATAK_FORWARDERATAK forwarding messages
ATAK_PLUGINATAK plugin messages
AUDIO_APPAudio messages
DETECTION_SENSOR_APPSensor detection data
IP_TUNNEL_APPIP tunneling messages
NEIGHBORINFO_APPNeighbor information
NODEINFO_APPNode information and details
PAXCOUNTER_APPPeople counter data
POSITION_APPGPS position updates
PRIVATE_APPPrivate messages
RANGE_TEST_APPRange testing data
REMOTE_HARDWARE_APPRemote hardware control
REPLY_APPReply messages
ROUTING_APPRouting information
SERIAL_APPSerial communication
SIMULATOR_APPSimulator messages
STORE_FORWARD_APPStore and forward messages
TELEMETRY_APPDevice telemetry data
TEXT_MESSAGE_APPPlain text messages
TEXT_MESSAGE_COMPRESSED_APPCompressed text messages
TRACEROUTE_APPNetwork route tracing
WAYPOINT_APPWaypoint information
ZPS_APPZone/Position System messages

Roadmap

  • Add support for custom node ID & names for the client
  • Add support for custom MQTT servers besides the official Meshtastic server
  • Create a PyPi package for easy import into other projects
  • Create an examples folder with use cases for the library, such as an IRC relay, cli chat, logging, etc.
Mirrors for this repository: acid.vegasSuperNETsGitHubGitLabCodeberg

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts