Expand description
Multi-hop relay support for Peat BLE mesh
This module provides message deduplication and hop tracking for multi-hop relay scenarios. Without deduplication, messages would bounce infinitely between mesh nodes.
§Wire Format
Relay envelope wraps documents for multi-hop transmission:
[1 byte: marker (0xB1)]
[1 byte: flags]
- bit 0: requires_ack
- bit 1: is_broadcast
- bits 2-7: reserved
[16 bytes: message_id (UUID)]
[1 byte: hop_count (current)]
[1 byte: max_hops (TTL)]
[4 bytes: origin_node_id]
[4 bytes: payload_len]
[N bytes: payload (encrypted document)]§Deduplication
The SeenMessageCache tracks message IDs with TTL expiration to prevent
infinite relay loops while allowing legitimate re-transmissions after
the TTL expires.
Structs§
- Message
Id - A 128-bit message identifier for deduplication
- Relay
Envelope - A relay envelope wrapping a document for multi-hop transmission
- Relay
Flags - Relay envelope flags
- Seen
Message Cache - Cache of seen message IDs for deduplication
Constants§
- DEFAULT_
MAX_ HOPS - Default max hops for relay messages
- DEFAULT_
SEEN_ TTL_ MS - Default TTL for seen messages (5 minutes in ms)
- MAX_
CACHE_ SIZE - Maximum cache size before cleanup is forced
- RELAY_
ENVELOPE_ MARKER - Marker byte indicating relay envelope