Quick Start
Basic Setup
Protocol Lifecycle
Complete Flow Example
Event Sequence Timeline
What Happens Under the Hood
On protocol.start()
- Protocol core starts in Rust
- BLE Manager initializes:
- Starts scanning for devices advertising the Offline Protocol service UUID
- Starts advertising this device with mesh metadata (degree, free slots, battery, uptime)
- Process timer starts - polls for outgoing fragments every 100ms
On Peer Discovery
- BLE scan detects advertisement from another device
- MeshController.shouldInitiateOutbound() evaluates the candidate:
- Checks connection budget (default max: 4)
- Calculates peer score (RSSI, availability, battery, uptime, stability, load)
- Determines if this is a cluster bridge opportunity
- If accepted: BLE connection established,
neighbor_discoveredfires - If at capacity: May evict a lower-scoring peer to make room
On protocol.sendMessage()
- Message created with unique ID, TTL, timestamp, priority
- message_sent event fires immediately
- Message queued for transmission
- DORS selects transport (BLE, WiFi Direct, or Internet)
- Message sent to connected peers
- ACK tracking begins (default 5s timeout)
- On ACK received:
message_deliveredevent fires - On timeout/max retries:
message_failedevent fires
On Incoming Message
- BLE fragment received from peer
- Deduplication check - skip if message ID already seen
- If addressed to this device:
message_receivedevent fires - ACK sent back to sender
- Hop count incremented for metrics
On protocol.stop()
- BLE Manager stops scanning and advertising
- All peer connections closed
- neighbor_lost events fire for each disconnected peer
- Protocol core stops
Diagnostic Events
The SDK emits diagnostic events for debugging:Next Steps
Explore the API reference