Expand description
HIVE Document wire format for BLE mesh sync
This module provides the unified document format used across all platforms (iOS, Android, ESP32) for mesh synchronization. The format is designed for efficient BLE transmission while supporting CRDT semantics.
§Wire Format
Header (8 bytes):
version: 4 bytes (LE) - document version number
node_id: 4 bytes (LE) - source node identifier
GCounter (4 + N*12 bytes):
num_entries: 4 bytes (LE)
entries[N]:
node_id: 4 bytes (LE)
count: 8 bytes (LE)
Extended Section (optional, when peripheral data present):
marker: 1 byte (0xAB)
reserved: 1 byte
peripheral_len: 2 bytes (LE)
peripheral: variable (34-43 bytes)Structs§
- Hive
Document - A HIVE document for mesh synchronization
- Merge
Result - Result from merging a received document
Constants§
- CHAT_
MARKER - Marker byte indicating chat CRDT section
- DELTA_
DOCUMENT_ MARKER - Marker byte indicating delta document for bandwidth-efficient sync
- EMERGENCY_
MARKER - Marker byte indicating emergency event section
- ENCRYPTED_
MARKER - Marker byte indicating encrypted document (mesh-wide)
- EXTENDED_
MARKER - Marker byte indicating extended section with peripheral data
- KEY_
EXCHANGE_ MARKER - Marker byte indicating key exchange message for per-peer E2EE
- MAX_
DOCUMENT_ SIZE - Hard limit before fragmentation would be required
- MAX_
MESH_ SIZE - Maximum recommended mesh size for reliable single-packet sync
- MIN_
DOCUMENT_ SIZE - Minimum document size (header only, no counter entries)
- PEER_
E2EE_ MARKER - Marker byte indicating per-peer E2EE message
- RELAY_
ENVELOPE_ MARKER - Marker byte indicating relay envelope for multi-hop transmission
- TARGET_
DOCUMENT_ SIZE - Target document size for single-packet transmission