Expand description
MeshCore - Rust library for communicating with MeshCore companion radio nodes
This library provides an async interface for communicating with MeshCore devices over serial, TCP, or BLE connections.
§Serial Example
use meshcore_rs::MeshCore;
#[tokio::main]
async fn main() -> Result<(), meshcore_rs::Error> {
// Connect via serial
let meshcore = MeshCore::serial("/dev/ttyUSB0", 115200).await?;
// Get device info
let info = meshcore.commands().lock().await.send_appstart().await?;
println!("Connected to: {}", info.name);
// Get contacts
let contacts = meshcore.commands().lock().await.get_contacts(0).await?;
println!("Found {} contacts", contacts.len());
meshcore.disconnect().await?;
Ok(())
}§BLE Example
Requires the ble feature.
use meshcore_rs::MeshCore;
use std::time::Duration;
#[tokio::main]
async fn main() -> Result<(), meshcore_rs::Error> {
// First discover available MeshCore devices
let devices = MeshCore::ble_discover(Duration::from_secs(5)).await?;
println!("Found devices: {:?}", devices);
// Connect to a specific device by name
let meshcore = MeshCore::ble_connect("MyDevice").await?;
// Get device info
let info = meshcore.commands().lock().await.send_appstart().await?;
println!("Connected to: {}", info.name);
// Get contacts
let contacts = meshcore.commands().lock().await.get_contacts(0).await?;
println!("Found {} contacts", contacts.len());
meshcore.disconnect().await?;
Ok(())
}Re-exports§
pub use error::Error;pub use events::ChannelMessage;pub use events::ContactMessage;pub use events::EventDispatcher;pub use events::EventPayload;pub use events::EventType;pub use events::MeshCoreEvent;pub use events::MsgSentInfo;pub use events::Subscription;pub use packets::AnonReqType;pub use packets::BinaryReqType;pub use packets::ControlType;pub use packets::PacketType;
Modules§
- commands
- Command handlers for MeshCore operations
- error
- Error types for the MeshCore library
- events
- Event system for MeshCore communication
- packets
- Packet types and protocol constants for MeshCore communication
- parsing
- Binary parsing utilities for MeshCore protocol
- reader
- Message reader for parsing incoming MeshCore packets
Structs§
- Mesh
Core - MeshCore client for communicating with MeshCore devices
Constants§
- CHANNEL_
INFO_ LEN - Total length of channel info payload (idx + name + secret)
- CHANNEL_
NAME_ LEN - Length of channel name field in bytes
- CHANNEL_
SECRET_ LEN - Length of channel secret field in bytes
Type Aliases§
- Result
- Result type alias using the library’s Error type