meshMonitor

CLI API Documentation

The Mesh Monitor provides a command-line interface for monitoring and displaying network status information. The CLI is built around the cli.py module and offers both one-shot and continuous monitoring modes.

Overview

The CLI allows you to:

Usage

Basic Command Structure

python -m src.meshviewer.cli [OPTIONS]

Command Line Options

Option Type Default Description
--mode choice continuous Display mode: oneshot or continuous
--interval int 30 Refresh interval for continuous mode (seconds)
--tcp-host str 192.168.0.114 TCP host for connection
--tcp-port int 4403 TCP port for connection
--serial-port str None Serial port for connection (optional)

Modes

One-shot Mode (--mode oneshot)

Displays a single snapshot of the network status and exits.

python -m src.meshviewer.cli --mode oneshot

Output includes:

Continuous Mode (--mode continuous)

Continuously monitors the network with periodic updates.

python -m src.meshviewer.cli --mode continuous --interval 60

Features:

Connection Methods

TCP Connection (Default)

The CLI attempts TCP connection by default:

python -m src.meshviewer.cli --tcp-host 192.168.1.100 --tcp-port 4403

Serial Connection

For direct serial connection to a Meshtastic device:

python -m src.meshviewer.cli --serial-port /dev/ttyUSB0

Fallback Behavior

When a serial port is specified but connection fails, the CLI automatically falls back to TCP connection.

Output Format

Node Information Display

Each node is displayed in the following format:

[node_id]  [long_name:25] - [hw_model:21] : [battery_info] : [last_heard] - [uptime]

Example:

!12345678  John's Node              - Heltec V3              :  85%, 3.7V  : last heard T-00:05:23 Ago - up 12.5 hrs
!87654321  Remote Station           - T-Beam V1.1            : Chg, 4.1V   : last heard T-00:01:45 Ago - up 8.2 hrs

Battery Status Format

Time Formats

Examples

Quick Status Check

python -m src.meshviewer.cli --mode oneshot

Continuous Monitoring with Custom Interval

python -m src.meshviewer.cli --mode continuous --interval 60

Connect to Different TCP Host

python -m src.meshviewer.cli --tcp-host 10.0.0.100 --tcp-port 4403

Serial Connection with Fallback

python -m src.meshviewer.cli --serial-port /dev/ttyUSB0 --tcp-host 192.168.1.50

Error Handling

The CLI includes robust error handling:

Integration

The CLI is designed to work seamlessly with the broader meshViewer ecosystem:

Troubleshooting

Common Issues

  1. Connection refused: Check TCP host/port or serial port permissions
  2. No data displayed: Ensure the Meshtastic device is connected and active
  3. Permission denied: For serial connections, ensure user has access to the device

Debug Mode

For troubleshooting, you can enable debug output by modifying the CLI code to include the debug=True parameter in the text_oneshot() function call.

Dependencies

The CLI requires:

All dependencies are included in the standard meshMonitor installation.