Skip to main content

Module peat_mesh

Module peat_mesh 

Source
Expand description

PeatMesh - Unified mesh management facade

This module provides the main entry point for Peat BLE mesh operations. It composes peer management, document sync, and observer notifications into a single interface that platform implementations can use.

§Usage

use peat_btle::peat_mesh::{PeatMesh, PeatMeshConfig};
use peat_btle::observer::{PeatEvent, PeatObserver};
use peat_btle::NodeId;
use std::sync::Arc;

// Create mesh configuration
let config = PeatMeshConfig::new(NodeId::new(0x12345678), "ALPHA-1", "DEMO");

// Create mesh instance
let mesh = PeatMesh::new(config);

// Add observer for events
struct MyObserver;
impl PeatObserver for MyObserver {
    fn on_event(&self, event: PeatEvent) {
        println!("Event: {:?}", event);
    }
}
mesh.add_observer(Arc::new(MyObserver));

// Platform BLE callbacks
mesh.on_ble_discovered("device-uuid", Some("PEAT_DEMO-AABBCCDD"), -65, Some("DEMO"), now_ms);
mesh.on_ble_connected("device-uuid", now_ms);
mesh.on_ble_data_received("device-uuid", &data, now_ms);

// Periodic maintenance
if let Some(sync_data) = mesh.tick(now_ms) {
    // Broadcast sync_data to connected peers
}

Structs§

DataReceivedResult
Result from receiving BLE data
DecodedTranslatorFrame
ADR-059 Amendment 3 — payload returned in DataReceivedResult::decoded_translator_frame when a 0xB6 translator frame decodes successfully on the receive dispatch. Hosts (peat-atak-plugin and equivalents) forward populated entries through their existing publish-with-origin FFI surface (e.g. peat-ffi’s publishDocumentWithOriginJni(collection, doc_json, "ble")). Defined unconditionally — no #[cfg(feature = "mesh-translator")] — so the UniFFI binding shape is stable across feature combos. Population only happens when mesh-translator is on.
PeatMesh
Main facade for Peat BLE mesh operations
PeatMeshConfig
Configuration for PeatMesh
RelayDecision
Decision from processing a relay envelope