Expand description
Document synchronization for Peat BLE mesh
This module provides centralized document state management for Peat-Lite nodes. It manages the local CRDT state (GCounter) and handles merging with received documents.
§Design Notes
This implementation uses a simple GCounter for resource-constrained devices (ESP32, smartwatches). For full Peat nodes using AutomergeIroh, this component can be replaced or extended - the observer pattern and BLE transport layer are independent of the document format.
§Usage
ⓘ
use peat_btle::document_sync::DocumentSync;
use peat_btle::NodeId;
let sync = DocumentSync::new(NodeId::new(0x12345678), "SOLDIER-1");
// Trigger an emergency
let doc_bytes = sync.send_emergency();
// ... broadcast doc_bytes over BLE
// Handle received document
if let Some(result) = sync.merge_document(&received_data) {
if result.is_emergency() {
println!("EMERGENCY from {:08X}", result.source_node.as_u32());
}
}Structs§
- Document
Check - Result from checking if a document contains an emergency
- Document
Sync - Document synchronization manager for Peat-Lite nodes