BLE MESH TUTORIAL : Nodes Elements Models in ble mesh

🔷 Bluetooth Mesh — Part 1

BLE MESH TUTORIAL : Nodes Elements Models in ble mesh

📖 Topic
Elements & Models
⏱ Read Time
~10 minutes
🎯 Level
Beginner–Intermediate

Key Terms in This Post

Node Element Model State Message State Binding Unicast Address Primary Element Generic Power Level Sensor Server

Why Does This Matter?

When you buy a Bluetooth Mesh smart bulb or smart power strip, it behaves in a very specific, structured way — you can control it with any compatible app or device. That is possible because the Bluetooth Mesh specification defines a strict internal structure: Nodes → Elements → Models → States. Once you understand this hierarchy, the entire Mesh profile makes sense.

🏠 What is a Node?

A node is any device that has been added (provisioned) into a Bluetooth Mesh network. Before provisioning, a device is called an unprovisioned device. Once it joins, it becomes a node.

Examples: Smart power strip, smart bulb, temperature sensor, light switch.

📡 NODE
Dual-Socket Smart Power Strip
Element 1
Socket 1
Addr: 0x0001
Element 2
Socket 2
Addr: 0x0002
One physical device → Two elements (one per socket)

💡 Key insight: A single device can have multiple elements. Each element gets its own unicast address so it can be controlled independently.

🔌 What is an Element?

An element is a logical part of a node that can be independently addressed. Think of it as a sub-device inside a device.

Why do we need elements? Because in our power strip, the two sockets are independent. You need to turn on Socket 1 without affecting Socket 2. So each socket is modelled as a separate element with its own address.

📌 Rule: The element with the lowest unicast address is called the Primary Element. It is special — it handles the Configuration Server model, which is used for network management. All other elements are secondary elements.

📦 What is a Model?

A model defines the functionality of an element. Every model has two things:

📊
States
Data stored in the model.
Example: Power Level = 75%
✉️
Messages
Commands to read/change states.
Example: Generic Power Level Set

Models are standardised by the Bluetooth SIG. That is why a dimmer from Brand A can control a bulb from Brand B — both implement the same model.

Models in our power strip example:

Model Name States it Holds Purpose
Configuration Server Config states Network management (primary element only)
Health Server Health / fault states Reports device faults
Generic Power Level Server Generic Power Actual
Generic Level
Controls socket power output
Sensor Server Sensor states Reports energy consumption

🖼️ Element-Model Structure: Dual Socket Power Strip

Here is how the full dual-socket device looks with both elements side by side:

🔵 Primary Element — Socket 1
Unicast Address: 0x0001
🟢 Secondary Element — Socket 2
Unicast Address: 0x0002
Configuration Server Model
← Primary element only
(Not present)
Health Server Model Health Server Model
Generic Power Level Server
States: Power Actual, Level, Last, Default, OnOff
Generic Power Level Server
States: Power Actual, Level, Last, Default, OnOff
Sensor Server Model
Reports energy consumption
Sensor Server Model
Reports energy consumption

Both sockets have identical models. Only the primary element (Socket 1) also carries the Configuration Server.

🔗 State Binding — The Clever Trick

Here is a very powerful feature. Imagine a dimmer switch. The dimmer does not know anything about power strips. It only knows how to set a generic level (0% to 100%). Yet it can control our smart power strip! How? Through state binding.

🎛 Dimmer
Generic Level Client
Generic Level Set
Generic Level State
changes to new value
State Binding ↓
Generic Power Actual
auto-updates → controls socket

The Generic Level state is bound to the Generic Power Actual state. When the dimmer changes the Generic Level, the binding automatically changes the Generic Power Actual — and the socket adjusts its power output. No extra logic needed!

💡 Real world analogy: Think of state binding like a linked spreadsheet. When you change cell A1, cell B1 (which is linked to A1) automatically updates too.

💻 BlueZ in Action — Reading Element & Model Info

The BlueZ stack ships with mesh-cfgclient, a command-line tool to interact with Bluetooth Mesh nodes. After provisioning a node, you can read its composition data — which tells you all its elements and models.

Step 1: Launch mesh-cfgclient and connect to the daemon

# Make sure bluetooth-meshd is running
sudo systemctl start bluetooth-meshd

# Launch the mesh configuration client
mesh-cfgclient

Step 2: Read the node composition (elements + models)

# Target the node by its unicast address (0x0001 = first node)
[mesh-cfgclient]# target 0x0001

# Request composition page 0 — this lists all elements and their models
[mesh-cfgclient]# get-composition 0

# --- Expected output ---
# Received Composition:
#   CID: 0x05F1  PID: 0x0001  VID: 0x0001  CRPL: 10
#   Features: Relay Proxy Friend LPN
#
#   Element 0  (addr: 0x0001)   <--- Primary Element
#     SIG Model: 0x0000  (Configuration Server)
#     SIG Model: 0x0002  (Health Server)
#     SIG Model: 0x1306  (Generic Power Level Server)
#     SIG Model: 0x1100  (Sensor Server)
#
#   Element 1  (addr: 0x0002)   <--- Secondary Element
#     SIG Model: 0x0002  (Health Server)
#     SIG Model: 0x1306  (Generic Power Level Server)
#     SIG Model: 0x1100  (Sensor Server)

What are those hex model IDs?

Model ID Name
0x0000 Configuration Server
0x0002 Health Server
0x1306 Generic Power Level Server
0x1100 Sensor Server

📝 Quick Summary

Concept What It Is Analogy
Node A provisioned device in the mesh A building in a city
Element Independently addressable unit inside a node A flat/apartment inside the building
Model Defines behaviour (states + messages) A role a resident has (tenant, manager)
State Data stored in a model Current electricity usage reading
State Binding Link between two states so one auto-updates Linked spreadsheet cells

Continue Learning Bluetooth Mesh

Next up: How nodes talk to each other using the Publish-Subscribe model

▶ Part 2: Publish-Subscribe & Messaging 🏠 Back to Mesh Series

Leave a Reply

Your email address will not be published. Required fields are marked *