基于 Python 的脚本用于将 meshore 调试和数据包捕获数据发送到 MQTT 进行分析。需要将 meshcore 重传器连接到 Raspberry Pi、服务器或其他设备。
基于 Python 的脚本用于将 meshore 调试和数据包捕获数据发送到 MQTT 进行分析。需要将 meshcore 重传器连接到 Raspberry Pi、服务器或其他设备。
A Python-based script to send MeshCore debug and packet capture data to MQTT for analysis. Requires a MeshCore repeater to be connected to a Raspberry Pi, server, or similar device running Python.
The goal is to have multiple repeaters logging data to the same MQTT server so you can easily troubleshoot packets through the mesh. You will need to build a custom image with packet logging and/or debug for your repeater to view the data.
The parser supports the current MeshCore packet log variants from main,
including repeater packet logs without hash= and dispatcher/serial logs that
include time= and hash=.
One way of tracking a message through the mesh is filtering the MQTT data on the
hash field when the source log format includes it. Dispatcher/serial packet
logs include hash=..., while current repeater packet logs may not.
curl -fsSL https://raw.githubusercontent.com/Cisien/meshcoretomqtt/main/install.sh | sudo bashThe installer will:
mctomqtt system user/opt/mctomqtt/ with config at /etc/mctomqtt/~/.meshcoretomqtt installationsInstall from a fork or custom branch:
curl -fsSL https://raw.githubusercontent.com/yourusername/meshcoretomqtt/yourbranch/install.sh | \
sudo bash -s -- --repo yourusername/meshcoretomqtt --branch yourbranchgit clone https://github.com/Cisien/meshcoretomqtt
cd meshcoretomqtt
sudo LOCAL_INSTALL=$(pwd) ./install.shconfiguration.nix:
{ config, pkgs, meshcoretomqtt, ... }:flake.nix
inputs = {
meshcoretomqtt.url = "github:Cisien/meshcoretomqtt"
};in your system config
…Setup a Raspberry Pi (Zero / 2 / 3 or 4 recommended) or similar Linux/macOS device
Build/flash a MeshCore repeater with appropriate build flags:
Recommended minimum:
-D MESH_PACKET_LOGGING=1Optional debug data:
-D MESH_DEBUG=1Plug the repeater into the device via USB (RAK or Heltec tested)
Configure the repeater with a unique name as per MeshCore guides
tomllib stdlib module)The installer handles these dependencies automatically!
If a pre-compiled wheel for ed25519-orlp is not available for
your platform, a C toolchain (gcc/make) and Python development
headers are required for installation. The installer will attempt
to detect and optionally install these for you.
Run the local test suite with:
python3 -m pytest tests/Test tiers:
MCTOMQTT_SKIP_NETWORK=1.MCTOMQTT_SKIP_SYSTEM=1.MCTOMQTT_TEST_E2E=1.Pull requests automatically run the GitHub Actions test workflow on Ubuntu. That job executes python -m pytest tests/ -m "not e2e", which includes the normal unit suite plus any network/system tests that work in the runner, while still excluding opt-in e2e coverage that requires real services or devices.
…Configuration uses TOML files with a layered override system:
/etc/mctomqtt/config.toml — Default values (overwritten on updates, do not edit)/etc/mctomqtt/config.d/10-*.toml — Broker presets selected during install/etc/mctomqtt/config.d/99-user.toml — Your custom configuration (never overwritten)Files in config.d/ are loaded alphabetically and deep-merged over the defaults.
The installer writes presets with a 10- prefix and user overrides to
99-user.toml so local settings load last.
To bypass the default config loading entirely, use --config:
mctomqtt.py --config /path/to/config.toml
mctomqtt.py --config /path/to/base.toml --config /path/to/overrides.tomlWhen --config is used, /etc/mctomqtt/ is not read. Multiple --config flags are supported; files are loaded in order with later files overlaying earlier ones.
sudo nano /etc/mctomqtt/config.d/99-user.tomlThe installer can copy broker presets from the repo presets/ directory or
import a preset from a TOML URL/local path. Selected presets are installed as
/etc/mctomqtt/config.d/10-.toml; user-specific overrides remain in
99-user.toml.
[general]
iata = "SEA"
[serial]
ports = ["/dev/ttyACM0"]
[[broker]]
name = "my-mqtt"
enabled = true
server = "mqtt.example.com"
port = 1883
[broker.auth]
method = "password"
username = "my_username"
password = "my_password"[general]
iata = "SEA"
[serial]
ports = ["/dev/ttyACM0"]
# Local MQTT with Username/Password
[[broker]]
name = "local-mqtt"
enabled = true
server = "mqtt.local"
port = 1883
[broker.auth]
method = "password"
username = "localuser"
password = "localpass"
# LetsMesh.net Packet Analyzer (US)
[[broker]]
name = "letsmesh-us"
enabled = true
server = "mqtt-us-v1.letsmesh.net"
port = 443
transport = "websockets"
[broker.tls]
enabled = true
[broker.auth]
method = "token"
audience = "mqtt-us-v1.letsmesh.net"Topics support template variables:
{IATA} — Your 3-letter location code{PUBLIC_KEY} — Device public key (auto-detected)Global topics (in config.toml defaults):
[topics]
status = "meshcore/{IATA}/{PUBLIC_KEY}/status"
packets = "meshcore/{IATA}/{PUBLIC_KEY}/packets"
debug = "meshcore/{IATA}/{PUBLIC_KEY}/debug"Per-broker topic overrides (optional):
[[broker]]
name = "custom-broker"
enabled = true
server = "mqtt.example.com"
[broker.topics]
status = "custom/{IATA}/{PUBLIC_KEY}/status"
iata = "LAX"[[broker]]
name = "my-broker"
enabled = true
server = "mqtt.example.com"
[broker.auth]
method = "password"
username = "your_username"
password = "your_password"Requires firmware supporting the get prv.key command (v1.8.0 or later).
[[broker]]
name = "letsmesh-us"
enabled = true
server = "mqtt-us-v1.letsmesh.net"
port = 443
transport = "websockets"
[broker.tls]
enabled = true
[broker.auth]
method = "token"
audience = "mqtt-us-v1.letsmesh.net"The script will:
v1_{PUBLIC_KEY} username formatNote: The private key is read directly from the device and used for signing only. It's never transmitted or saved to disk.
[general]
# Logging level: DEBUG, INFO, WARNING, ERROR, CRITICAL
log_level = "INFO"
# Wait for system clock sync before setting repeater time (default: true)
# Set to false on systems without timedatectl or NTP
sync_time = trueRemote serial allows you to execute serial commands on your node remotely via the LetsMesh.net MeshCore Packet Analyzer web interface. Commands are cryptographically signed by an authorized companion device connected via Bluetooth.
Security Model:
Configuration:
[remote_serial]
enabled = true
allowed_companions = [
"03CEBEA3DA9C279CF8EB9449F0CC5BA3690621EE66A3B91067CDBA881EC883A5"
]
nonce_ttl = 120
command_timeout = 10How it works:
serial/commands topicserial/responses topicNote: Ensure your system clock is synchronized (NTP) for JWT expiry verification.
The installer offers three deployment options:
Automatically starts on boot and runs as a dedicated system user.
Linux (systemd):
sudo systemctl start mctomqtt # Start service
sudo systemctl stop mctomqtt # Stop service
sudo systemctl status mctomqtt # Check status
sudo systemctl restart mctomqtt # Restart service
sudo journalctl -u mctomqtt -f # View logsmacOS (launchd):
sudo launchctl load /Library/LaunchDaemons/com.meshcore.mctomqtt.plist
sudo launchctl unload /Library/LaunchDaemons/com.meshcore.mctomqtt.plist
sudo launchctl list | grep mctomqtt
tail -f /var/log/mctomqtt.log# Build the image
docker build -t mctomqtt:latest /path/to/meshcoretomqtt
# Run the container
docker run -d \
--name mctomqtt \
--restart unless-stopped \
-v /path/to/mctomqtt-config:/etc/mctomqtt:ro \
--device=/dev/ttyACM0 \
mctomqtt:latestcd /opt/mctomqtt
sudo -u mctomqtt ./venv/bin/python3 mctomqtt.py --config /etc/mctomqtt/config.tomlWith debug output:
sudo -u mctomqtt ./venv/bin/python3 mctomqtt.py --config /etc/mctomqtt/config.toml --debugUse the standalone update script for the simplest update experience:
curl -fsSL https://raw.githubusercontent.com/Cisien/meshcoretomqtt/main/scripts/update.sh | sudo bashOr re-run the installer — it will detect your existing installation and offer to update:
curl -fsSL https://raw.githubusercontent.com/Cisien/meshcoretomqtt/main/install.sh | sudo bashFor non-interactive updates:
curl -fsSL https://raw.githubusercontent.com/Cisien/meshcoretomqtt/main/install.sh | sudo bash -s -- --updateThe updater will:
/etc/mctomqtt/config.toml with latest defaults/etc/mctomqtt/config.d/99-user.toml configurationIf you have a legacy ~/.meshcoretomqtt installation, migrate to the new layout:
curl -fsSL https://raw.githubusercontent.com/Cisien/meshcoretomqtt/main/scripts/migrate.sh | sudo bashThe migrator will:
.env/.env.local configuration to TOML formatcurl -fsSL https://raw.githubusercontent.com/Cisien/meshcoretomqtt/main/uninstall.sh | sudo bashThe uninstaller will:
99-user.toml configuration/opt/mctomqtt/ and /etc/mctomqtt/mctomqtt system userThis tool collects and forwards all packets transmitted over the MeshCore network. Privacy on MeshCore is provided by protecting secret channel keys. All packets will be forwarded as raw data without additional processing or decryption. The primary use of this script is to send data to LetsMesh.net. Learn at https://letsmesh.net/
meshco暂无开放 Issues,或尚未同步最近议题。