- Created CHANGELOG.md to document major enhancements and bug fixes. - Added metrics collection for message statistics and connection health. - Implemented a health monitoring system to track component statuses. - Introduced a REST API for monitoring bridge health and metrics. - Enhanced README.md and documentation to reflect new features and configuration options. - Fixed various bugs in test files and added new validation and sanitization features for messages. - Ensured backward compatibility and provided migration notes for existing users.
10 KiB
Usage Guide
Last Updated: December 31, 2025
This guide explains how to run and interact with the Akita Meshtastic Meshcore Bridge (AMMB).
Prerequisites
Ensure you have completed the steps in the Installation section of the main README, including:
- Cloning the repository
- Setting up a Python virtual environment (recommended)
- Installing dependencies (
pip install -r requirements.txt) - Creating and configuring your
config.inifile
Running the Bridge
-
Navigate to the project root directory in your terminal or command prompt (the directory containing
run_bridge.py). -
Activate your virtual environment (if you created one):
- Linux/macOS:
source venv/bin/activate - Windows:
.\venv\Scripts\activate
- Linux/macOS:
-
Run the bridge script:
python run_bridge.py
Expected Output
Upon successful startup, you should see log messages similar to this in your console:
2025-12-31 10:00:00 - MainThread - INFO - config_handler - Configuration loaded successfully from config.ini
2025-12-31 10:00:00 - MainThread - INFO - utils - Logging level set to INFO
2025-12-31 10:00:00 - MainThread - INFO - bridge - Initializing network handlers...
2025-12-31 10:00:00 - MainThread - INFO - meshtastic_handler - Attempting connection to Meshtastic on /dev/ttyUSB0...
2025-12-31 10:00:01 - MainThread - INFO - meshtastic_handler - Connected to Meshtastic device. Node ID: !deadbeef
2025-12-31 10:00:01 - MainThread - INFO - meshtastic_handler - Meshtastic receive callback registered.
2025-12-31 10:00:01 - MainThread - INFO - meshcore_handler - Attempting connection to Serial device on /dev/ttyS0 at 9600 baud...
2025-12-31 10:00:01 - MainThread - INFO - meshcore_handler - Connected to Serial device on /dev/ttyS0
2025-12-31 10:00:01 - MainThread - INFO - bridge - Starting handler background tasks/threads...
2025-12-31 10:00:01 - MainThread - INFO - bridge - Bridge background tasks started. Running... (Press Ctrl+C to stop)
Notes:
- The bridge will attempt to connect to both the Meshtastic and external devices based on your
config.ini - If a connection fails initially (e.g., device not plugged in), it will log a warning or error and periodically retry in the background
- Once running, it will log messages received and sent on both networks (depending on your
LOG_LEVEL)
Monitoring
Console Logs
Keep an eye on the terminal where you ran python run_bridge.py. This is the primary way to see what the bridge is doing, including:
- Received messages
- Sent messages
- Connection attempts
- Errors and warnings
- Metrics and statistics
Log Level
If you need more detailed information for troubleshooting:
- Stop the bridge (
Ctrl+C) - Edit
config.ini - Set
LOG_LEVEL = DEBUG - Restart the bridge
- Remember to set it back to
INFOorWARNINGfor normal operation to avoid excessive output
REST API Monitoring
If the REST API is enabled (API_ENABLED = True in config.ini), you can monitor the bridge programmatically:
Health Status:
curl http://localhost:8080/api/health
Metrics:
curl http://localhost:8080/api/metrics
Combined Status:
curl http://localhost:8080/api/status
Bridge Information:
curl http://localhost:8080/api/info
Reset Metrics:
curl -X POST http://localhost:8080/api/control \
-H "Content-Type: application/json" \
-d '{"action": "reset_metrics"}'
The API returns JSON data that can be parsed by monitoring tools, scripts, or dashboards.
Stopping the Bridge
Press Ctrl+C in the terminal where the bridge is running. The bridge will:
- Detect the shutdown signal
- Stop all handler threads
- Close all connections
- Stop the API server (if enabled)
- Stop health monitoring
- Log shutdown messages
The shutdown sequence is designed to be graceful, ensuring all resources are properly cleaned up.
Message Format
Meshtastic to External
Messages from Meshtastic are translated to the following format:
{
"type": "meshtastic_message",
"sender_meshtastic_id": "!deadbeef",
"portnum": "TEXT_MESSAGE_APP",
"payload": "Hello from Meshtastic",
"timestamp_rx": 1704067200.0,
"rx_rssi": -85,
"rx_snr": 5.2
}
For position messages:
{
"type": "meshtastic_position",
"sender_meshtastic_id": "!deadbeef",
"portnum": "POSITION_APP",
"payload": {
"latitude": 37.7749,
"longitude": -122.4194,
"altitude": 100,
"timestamp_gps": 1704067200
},
"timestamp_rx": 1704067200.0
}
External to Meshtastic
Messages from external systems should be in the following format:
For Serial (JSON protocol):
{
"destination_meshtastic_id": "^all",
"payload": "Hello from external system",
"channel_index": 0,
"want_ack": false
}
For MQTT:
{
"destination_meshtastic_id": "^all",
"payload": "Hello from MQTT",
"channel_index": 0,
"want_ack": false
}
Destination Options:
^allor^broadcast: Broadcast to all nodes!aabbccdd: Send to specific node ID (hexadecimal)
Troubleshooting Common Issues
Connection Issues
Error: Error connecting to Meshtastic device: [Errno 2] No such file or directory: '/dev/ttyUSB0'
- Cause: The specified
MESHTASTIC_SERIAL_PORTinconfig.iniis incorrect, or the device is not connected/detected by the OS. - Solution:
- Verify the port name using
meshtastic --port listor OS tools - Ensure the device is plugged in and drivers are installed
- Check permissions (Linux users might need to be in the
dialoutgroup:sudo usermod -a -G dialout $USER)
- Verify the port name using
Error: Error connecting to Serial device: [Errno 2] No such file or directory: '/dev/ttyS0'
- Cause: The specified
SERIAL_PORTinconfig.iniis incorrect, or the device is not connected/detected. - Solution:
- Verify the port name using OS tools
- Ensure the device is plugged in and drivers are installed
- Check permissions
Error: serial.SerialException: Could not configure port: (5, 'Input/output error')
- Cause: The user running the script doesn't have permission to access the serial port.
- Solution (Linux): Add your user to the
dialoutgroup:sudo usermod -a -G dialout $USER. You may need to log out and log back in for the change to take effect.
Message Issues
No messages received from external device / Gibberish received
- Cause 1: Incorrect
SERIAL_BAUD_RATEinconfig.ini. It must match the device's setting exactly. - Cause 2: Incorrect
SERIAL_PROTOCOLselected, or the device is not sending data in the expected format. - Cause 3: Wiring issue between the computer and the device.
- Solution:
- Verify baud rate matches device setting
- Verify the protocol setting matches the actual data format
- Check physical connections
- Use a serial terminal program to test communication directly
Messages dropped (Queue is full warnings)
- Cause: Messages are arriving faster than they can be sent out on the other network, or the destination network/device is unresponsive.
- Solution:
- Investigate potential bottlenecks on the destination network
- Consider increasing
MESSAGE_QUEUE_SIZEinconfig.iniif temporary bursts are expected - Check if rate limiting is too restrictive
- Note: This won't solve underlying rate issues, only provides temporary buffering
JSONDecodeError / UnicodeDecodeError
- Cause: The bridge received data that was not valid JSON (when using
json_newlineprotocol) or not valid UTF-8 text. - Solution:
- Ensure the device is sending correctly formatted, UTF-8 encoded JSON strings, terminated by a newline
- Check the log messages for clues about the invalid data
- Verify the protocol setting matches the actual data format
Rate limit exceeded warnings
- Cause: Too many messages are being sent in a short time period.
- Solution:
- This is a protective feature to prevent message flooding
- Review your message sending rate
- The default limit is 60 messages per minute per source
- Rate limit violations are tracked in metrics
Validation Errors
Invalid message rejected warnings
- Cause: A message failed validation (invalid format, missing fields, etc.)
- Solution:
- Check the error message in the logs for specific validation failures
- Ensure messages match the expected format (see Message Format section)
- Verify node IDs are in the correct format (
!aabbccddor^all)
API Issues
API server not starting
- Cause: Port may be in use, or configuration error.
- Solution:
- Check if another process is using the API port
- Verify
API_ENABLED = Trueinconfig.ini - Check
API_HOSTandAPI_PORTsettings - Review error messages in logs
Cannot connect to API
- Cause: Firewall blocking, wrong host/port, or API not enabled.
- Solution:
- Verify API is enabled in configuration
- Check firewall settings
- Verify host and port settings
- Try connecting from localhost first
MQTT Issues
MQTT connection failed
- Cause: Broker unreachable, wrong credentials, or network issues.
- Solution:
- Verify broker address and port
- Check username and password (if required)
- Test broker connectivity with another MQTT client
- Check firewall settings
MQTT TLS errors
- Cause: Certificate issues or TLS configuration problems.
- Solution:
- Verify certificate file path (if using custom CA)
- Check TLS settings in configuration
- Review TLS error messages in logs
- Consider using
MQTT_TLS_INSECURE = Truefor testing only (not recommended for production)
Performance Tips
- Queue Size: Increase
MESSAGE_QUEUE_SIZEif you experience frequent message drops during bursts - Log Level: Use
INFOorWARNINGin production to reduce logging overhead - API: Disable API if not needed to reduce resource usage
- Rate Limiting: Adjust rate limits based on your actual message volume
- Serial Baud Rate: Use higher baud rates (115200) if your device supports it for better throughput
Getting Help
If you encounter issues not covered in this guide:
- Check the logs with
LOG_LEVEL = DEBUGfor detailed information - Review the API metrics and health status
- Consult the architecture documentation (
docs/architecture.md) - Check the configuration documentation (
docs/configuration.md) - Review the development guide (
docs/development.md)