Bluetooth Mesh Implementation: From Provisioning to Production
Step-by-step guide to deploying a Bluetooth Mesh network
Bluetooth Mesh Implementation: From Provisioning to Production
Bluetooth Mesh extends BLE from point-to-point to a many-to-many topology, enabling large-scale networked deployments — building automation, industrial lighting, sensor networks. Mesh uses a managed flooding approach where messages propagate through relay nodes, eliminating the need for a central hub and providing self-healing redundancy.
Architecture Overview
[Provisioner (phone/gateway)]
│
│ Provisioning (OOB or ECDH)
│
┌────▼────────────────────┐
│ Mesh Network │
│ [Relay] ─ [Relay] │
│ │ │ │
│ [Node] [Low Power] │
│ ─[Friend] │
└─────────────────────────┘
Every node in the mesh has a 16-bit Unicast Address. Groups use multicast addresses (0xC000–0xFEFF). The Publish-Subscribe model decouples publishers from subscribers: a light switch publishes to group 0xC001; all lights subscribed to 0xC001 respond.
Mesh Stack Layers
| Layer | Function |
|---|---|
| Model | Application behavior: Generic OnOff, Light Lightness, Vendor Model |
| Access | Message format, opcode routing |
| Upper Transport | E2E encryption (AppKey), segmentation |
| Lower Transport | Network-level segmentation, reassembly |
| Network | Network encryption (NetKey), managed flooding, TTL |
| Bearer | ATT">GATT Bearer (for GATT Proxy) or Advertising Bearer |
Provisioning Workflow
Provisioning is the process of adding an unprovisioned device to the mesh network. The Provisioner distributes the Network Key (NetKey) and assigns a Unicast Address.
Provisioner Unprovisioned Device
│ │
│─── Beacon Invite ────────>│
│<── Capabilities ─────────│ (OOB auth methods, algorithms)
│─── Start ────────────────>│ (select auth: OOB/No OOB/Static)
│<── Public Key ───────────│ (ECDH key exchange)
│─── Public Key ────────────>│
│ [ECDH shared secret] │
│─── Confirmation ─────────>│
│<── Confirmation ─────────│
│─── Random ───────────────>│
│<── Random ───────────────│
│─── Provisioning Data ────>│ (NetKey, IV Index, Unicast Address)
│<── Complete ─────────────│
OOB (Out-of-Band) authentication adds a second factor: the user enters a PIN displayed on the device, confirming physical access. Static OOB uses a pre-shared key programmed at manufacture.
Relay Optimization
Naive relay flooding wastes radio bandwidth and reduces battery life. Production networks tune:
| Parameter | Default | Optimized |
|---|---|---|
| TTL (Time To Live) | 7 | Network diameter + 2 (e.g., 5) |
| Relay retransmit count | 2 | 1 for dense networks |
| Relay retransmit interval | 10 ms | 20–50 ms to reduce collision |
| Advertising interval | 20–100 ms | 40 ms for mesh bearer |
| Network Transmit count | 3 | 1 in high-density deployments |
Nodes that do not need to relay (sensors, actuators near a relay) should disable the Relay feature to save energy. Only nodes with reliable power (mains-powered lights, outlets) should act as relays.
Low Power Nodes and Friend Nodes
Battery-powered sensors cannot stay awake to receive relay traffic. The Friend/Low-Power Node (LPN) protocol solves this:
- The Low Power Node establishes a friendship with a Friend Node (mains-powered)
- Friend caches messages destined for the LPN while it sleeps
- LPN wakes at its poll interval (configurable: 100 ms to 60 min) and polls the Friend
- Friend delivers cached messages in one exchange
A single Friend Node can maintain up to 8–16 friendships (hardware-dependent). Friendship dramatically extends LPN battery life — from days to years for infrequent sensors.
Group Addressing and Scenes
Light switch → publishes to 0xC001 (All Lights group)
Sensor → publishes to 0xC002 (All HVAC group)
Gateway → subscribes to 0xC001, 0xC002 (monitoring)
Scenes (Generic Scenes Model) let a single message recall a pre-programmed state across all subscribed nodes — a conference room "Meeting Mode" scene dims all lights and adjusts thermostats in one publish.
Zephyr RTOS Mesh Stack
#include <bluetooth/mesh.h>
static struct bt_mesh_cfg_cli cfg_cli = {};
static struct bt_mesh_health_srv health_srv = {};
BT_MESH_MODEL_LIST(root_models,
BT_MESH_MODEL_CFG_SRV,
BT_MESH_MODEL_CFG_CLI(&cfg_cli),
BT_MESH_MODEL_HEALTH_SRV(&health_srv, &health_pub),
);
static const struct bt_mesh_comp comp = {
.cid = BT_COMP_ID_LF,
.elem = elements,
.elem_count = ARRAY_SIZE(elements),
};
bt_mesh_init(&prov, &comp);
Production Checklist
- [ ] Assign unique Provisioner credentials per installation
- [ ] Set TTL appropriate to network diameter — avoid flooding entire building
- [ ] Enable Friend feature on all mains-powered nodes (relay + friend = cheap)
- [ ] Test provisioning flow with 50+ nodes before deployment
- [ ] Implement Heartbeat monitoring for network health visibility
- [ ] Use Configuration Client to remotely tune relay/network transmit params post-deploy
See BLE Mesh glossary and the Beacon Configurator for provisioning parameter reference.
자주 묻는 질문
Yes, our guides range from beginner introductions to advanced topics. Each guide indicates its difficulty level and prerequisites so you can find the right starting point.