MeshCore-rs
Rust library for communicating with MeshCore companion radio nodes.
This is a Rust port of the meshcore_py Python library.
Features
- Async/await - Built on Tokio for async I/O
- Serial connection - Connect via USB serial port
- TCP connection - Connect via TCP socket
- BLE connection - Connect via Bluetooth Low Energy (optional feature)
- Event-driven - Subscribe to events with filters
- Full protocol support - Contacts, messaging, binary protocol, signing, etc.
Installation
Add to your Cargo.toml:
[]
= "0.1"
Optional Features
[]
= { = "0.1", = ["ble"] }
serial- Serial port support (enabled by default)tcp- TCP socket support (enabled by default)ble- Bluetooth Low Energy support (requires btleplug)
Quick Start
use MeshCore;
async
Event Subscriptions
use ;
use HashMap;
// Subscribe to incoming messages
let sub = meshcore.subscribe.await;
// Auto-fetch messages when device signals messages waiting
meshcore.start_auto_message_fetching.await;
// Later, unsubscribe
sub.unsubscribe.await;
API Overview
Device Commands
send_appstart()- Initialize connection, get device infoget_bat()- Get battery voltage (millivolts) and storage infoget_time()/set_time()- Get/set device timeset_name()- Set device nameset_coords()- Set device coordinatesset_tx_power()- Set transmission powersend_advert()- Send advertisementget_channel()/set_channel()- Get/set channel configexport_private_key()/import_private_key()- Key management
Contact Commands
get_contacts()- Get contact listadd_contact()- Add a contactremove_contact()- Remove a contactexport_contact()- Export contact as URIimport_contact()- Import contact from card data
Messaging Commands
get_msg()- Get next message from queuesend_msg()- Send a direct messagesend_chan_msg()- Send a channel messagesend_login()/send_logout()- Login/logout to remote node
Binary Protocol Commands
req_status()- Request device statusreq_telemetry()- Request telemetry datareq_acl()- Request ACL entriesreq_neighbours()- Request neighbour list
Signing Commands
sign_start()/sign_data()/sign_finish()- Low-level signingsign()- High-level sign helper
Protocol Details
The library implements the MeshCore serial/TCP protocol:
- Frame format:
[0x3c][len_low][len_high][payload] - Little-endian byte ordering
- Coordinates stored as microdegrees (divide by 1,000,000 for decimal degrees)
License
MIT License - see LICENSE for details.
Related Projects
- MeshCore - Firmware for MeshCore devices
- meshcore_py - Python library (original)
- meshcore-cli - Command-line interface