Skip to main content

This library may be useful for testing Meshtastic networks connected to an MQTT server.

Project description

This project is useful for testing Meshtastic networks connected to an MQTT server. Functions can be called via the mmqtt command or imported and used programmatically.

Installation

pip install mmqtt

Functions (see examples for further information):

from mmqtt import (
    send_nodeinfo,
    send_device_telemetry,
    send_position,
    send_environment_metrics,
    send_power_metrics,
    send_health_metrics,
    send_text_message,
)

send_nodeinfo(node_id, long_name, short_name)
send_device_telemetry()
send_position(latitude, longitude)
send_environment_metrics()
send_power_metrics()
send_health_metrics()
send_text_message("text")

Optional Arguments for all message types:

  • to=INT
  • hop_limit=INT
  • hop_start=INT
  • want_ack=BOOL
  • want_response=BOOL

Example:

send_text_message("Happy New Year" to=12345678, hop_limit=5)

Supported keyword arguments for nodeinfo:

  • id (required)
  • long_name (required)
  • short_name (required)
  • hw_model
  • is_licensed
  • role
  • public_key

Supported keyword arguments for device metrics:

  • battery_level
  • voltage
  • channel_utilization
  • air_util_tx
  • uptime_seconds

Supported keyword arguments for position metrics:

  • latitude (required)
  • longitude (required)
  • latitude_i
  • longitude_i
  • altitude
  • precision_bits
  • HDOP
  • PDOP
  • VDOP
  • altitude_geoidal_separation
  • altitude_hae
  • altitude_source
  • fix_quality
  • fix_type
  • gps_accuracy
  • ground_speed
  • ground_track
  • next_update
  • sats_in_view
  • sensor_id
  • seq_number
  • timestamp
  • timestamp_millis_adjust

Supported keyword arguments for environment metrics:

  • temperature
  • relative_humidity
  • barometric_pressure
  • gas_resistance
  • voltage
  • current
  • iaq
  • distance
  • ir_lux
  • lux
  • radiation
  • rainfall_1h
  • rainfall_24h
  • soil_moisture
  • soil_temperature
  • uv_lux
  • weight
  • white_lux
  • wind_direction
  • wind_gust
  • wind_lull
  • wind_speed

Supported keyword arguments for power metrics:

  • ch1_voltage
  • ch1_current
  • ch2_voltage
  • ch2_current
  • ch3_voltage
  • ch3_current

Supported keyword arguments for health metrics:

  • heart_bpm
  • spO2
  • temperature

Command Line Interface:

mmqtt --args

Available arguments:

  -h, --help             show this help message and exit
  --config CONFIG        Path to the config file
  --message MESSAGE      Message to send. You can use this multiple times.
  --message-file FILE    Path to a file containing messages, one per line
  --nodeinfo             Send NodeInfo from my config
  --telemetry            Send telemetry from my config
  --lat LAT              Latitude coordinate
  --lon LON              Longitude coordinate
  --alt ALT              Altitude
  --precision PRECISION  Position Precision
  --position             Send position from config unless overridden by --lat, --lon, or --alt
  --listen               Stay connected and listen for incoming MQTT messages

Examples:

To publish a message to the broker using settings defined in config-example.json:

mmqtt --message "I need an Alpinist"

To publish a message to the broker using settings defined in my-config.json:

mmqtt --config "my-config.json" --message "I need an Alpinist"

Example config.json:

{
  "mqtt": {
    "broker": "mqtt.meshtastic.org",
    "port": 1883,
    "user": "meshdev",
    "password": "large4cats",
    "root_topic": "msh/US/2/e/"
  },
  "channel": {
    "preset": "LongFast",
    "key": "AQ=="
  },
  "nodeinfo": {
    "id": "!deadbeef",
    "short_name": "q",
    "long_name": "mmqtt",
    "hw_model": 255
  },
  "position": {
    "lat": 45.43139,
    "lon": -122.37354,
    "alt": 9,
    "location_source": "LOC_MANUAL",
    "precision": 16
  },
  "telemetry": {
    "battery_level": 99,
    "voltage": 4.0,
    "chutil": 3,
    "airtxutil": 1,
    "uptime": 420
  },
  "message": {
    "text": "Happy New Year",
    "destination_id": "4294967295"
  },
  "mode": {
    "listen": "False"
  }
}

Build and install locally:

python3 -m venv .venv
source .venv/bin/activate
pip install poetry
poetry build
pip install dist/mmqtt*.whl

Install in development (editable) mode:

pip install -e .

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mmqtt-1.1.3.tar.gz (23.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mmqtt-1.1.3-py3-none-any.whl (26.5 kB view details)

Uploaded Python 3

File details

Details for the file mmqtt-1.1.3.tar.gz.

File metadata

  • Download URL: mmqtt-1.1.3.tar.gz
  • Upload date:
  • Size: 23.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for mmqtt-1.1.3.tar.gz
Algorithm Hash digest
SHA256 b035959a54716f2e56d4a1a698657e5c054d3d026ff82ace820ff5240fe8513e
MD5 fa17d12d21cdcfad6b92101ec83ea868
BLAKE2b-256 fc920ef4e19fce007c52dc0edc102d9a3e97f913f1751029381eef8411463ecd

See more details on using hashes here.

Provenance

The following attestation bundles were made for mmqtt-1.1.3.tar.gz:

Publisher: release.yaml on pdxlocations/mmqtt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mmqtt-1.1.3-py3-none-any.whl.

File metadata

  • Download URL: mmqtt-1.1.3-py3-none-any.whl
  • Upload date:
  • Size: 26.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for mmqtt-1.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 dd7698e63d76c51cf4dcec558f271b6e24b93101b5041f3ac80d2312cfbc70a2
MD5 fc95dab1eb20c252052d848081d1cb19
BLAKE2b-256 d72e68ec0984c2d68eb71ba84d5081a1178275d3700017f165c4ee9318544d58

See more details on using hashes here.

Provenance

The following attestation bundles were made for mmqtt-1.1.3-py3-none-any.whl:

Publisher: release.yaml on pdxlocations/mmqtt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page