Module document

Module document 

Source
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§

HiveDocument
A HIVE document for mesh synchronization
MergeResult
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