What Is Bluetooth Mesh?
What Is Bluetooth Mesh?
Nodes
A node is a device that has joined a Bluetooth mesh network. Devices that
are not part of the network are called unprovisioned devices. Once an
unprovisioned device gets provisioned, it joins the network and becomes a
node.
Elements
A node may contain multiple parts which can be controlled independently. For
example, a light fixture may contain multiple light bulbs which can be turned
on/off independently. These different parts of a single node are referred to as
elements.
States
Elements can be in various conditions, represented by state values. For
example, on and off are states of a lightbulb within a light fixture. A change
from one state to another is called a state transition. This can be
instantaneous, or it can occur over time, after what’s called a transition
period. When a state change occurs, it is likely to cause a change in the
behavior of an element.
Some states may be bound to each other, meaning that a change in one
state triggers a change in the other. There may be two or more states bound
to each other. Let’s take for example a light dimmer: it will likely have a level
state as well as an on/off state. If the level state value changes to zero, it will
trigger the on/off state to transition to off. If the level value changes from zero
to a non-zero value, then that triggers the on/off state to transition to on.
Properties
Properties add some context to a state value. For example, defining that a
temperature value is an outdoor or indoor temperature. There are two types
of properties:
Manufacturer property: provides read-only access
Admin property: provides read-write access
Messages
In Bluetooth mesh, all communications within the network are
message-oriented, and nodes send messages to control or relay information
to each other. Messages are the mechanism by which operations on nodes
are invoked. If a node needs to report its status, it also sends it via a
message. A given message type represents an operation on a state or
collection of multiple state values.
There are three types of messages in Bluetooth mesh, each of which is
defined by a unique opcode (operation code):
● A GET message: a message to request the state from one or more
nodes.
● A SET message: a message to change the value of a given state.
● A STATUS message: A status message is used in different scenarios:
○ In response to a GET message, containing the state value.
○ In response to an acknowledged SET message.
○ Sent independently of any message to report the element’s status.
One example is a message that’s triggered by a timer running on
the element sending this message.
Some messages require an acknowledgment message to be sent by the
receiver of the original message. An acknowledgment message serves two
purposes:
● Confirmation of receipt of the message.
● Return of data related to the message received.
In the case where a response to the message is not received by the sender,
or an unexpected response is received, the sender may resend the message.
Multiple acknowledged messages received by a node do not affect the
behavior (it’s as if the message was received once).
Addresses
Messages in a Bluetooth mesh network must be sent to and from an address.
There are three types of addresses:
● Unicast Address: an address that uniquely identifies a single node
assigned during the provisioning process (which we’ll cover in an
upcoming post).
● Group Address: an address used to identify a group of nodes. A group
address usually reflects a physical grouping of nodes such as all nodes
within a specific room. A group address could either be:
○ Defined by the Bluetooth SIG, also referred to as a SIG-Fixed
Group Address. These include All-proxies, All-friends, All-relays,
and All-nodes group addresses.
○ Dynamic Group Address, which is defined by the user via a
configuration application.
● Virtual Address: an address that may be assigned to one or more
elements, spanning one or more nodes. This acts as a label and takes
the form of a 128-bit UUID with which any element can be associated.
Virtual addresses are likely to be preconfigured at the time of
manufacturing.
Publish/Subscribe
The way messages are exchanged in a Bluetooth mesh network is via the
publish-subscribe pattern
Publishing is the act of sending a message. Subscribing is a configuration
used to allow select messages to be sent to specific addresses for
processing. Typically, messages are addressed to group or virtual
addresses.
Here’s an example of a mesh network in a home that’s comprised of 6 light
switches and 9 light bulbs. The network utilizes the publish-subscribe method
to allow nodes to send messages to each other.
Nodes may subscribe to multiple addresses. An example of this is light #3 in
the above figure, which is subscribed to both the kitchen and the dining room
group addresses. Also, multiple nodes may publish to the same address, such
as switches #5 and #6 in this example. These two switches control the same
group of lights, located in the garden.
The benefit of using group or virtual addresses is that adding or removing
nodes does not require reconfiguration of nodes
Managed Flooding
Many mesh networks use routing mechanisms to relay messages across the
network. The other extreme is to flood the network with the messages being
relayed without consideration of the optimal routes these messages need to
take to reach their perspective destinations. Bluetooth mesh uses a technique
that’s a compromise of both of these techniques. This technique is referred to
as managed flooding.
Managed flooding relies on broadcasting messages to all nodes within range
of the sender node, with a few added optimizations:
● Messages have a TTL assigned
TTL stands for time-to-live, which limits the number of hops a message
can take across multiple nodes within the mesh network. A value of zero
indicates that a message has not been relayed and should not be
relayed. This means that a node can send a message to other nodes
which are in its direct radio range and indicate that the receiving node(s)
should not relay the message.
If a message is sent with a TTL ≥ 2, then each time it is relayed, the TTL
value gets decremented. A TTL value of 1 means that the message may
have been relayed at least once, but that it should not be relayed again.
● Messages are cached
Message caching is required by all nodes and requires that messages
received that already exist in the cache get immediately discarded.
● Heartbeat messages are sent periodically
Heartbeat messages are used to indicate to other nodes that the
sender is alive and active within the network.
● Friendship
Friendship refers to the relationship between two nodes. These two
node types are:
○ A low-power node, or LPN, conserves power and is not able to
receive mesh messages all the time. This node spends most of its
time with the radio turned off.
○ A live-powered node called the friend node, which can serve as a
proxy for the LPN. The friend node caches messages for the LPN
to save power, so that the LPN can stay asleep most of the time
and only wake up occasionally. When the LPN wakes up, it polls
the friend node to read the cached messages and sends any
messages it needs to send to the mesh network.
There are several other types of nodes in a mesh network which we’ll be
covering in a later post.
Models
One important term defined in Bluetooth mesh is the concept of a model. A
model defines some or all functionality of a given element.
There are three categories of models:
● Server model: is a collection of states, state transitions, state bindings,
and messages which an element containing the model may send or
receive.
● Client model: does not define any states; rather, it defines only
messages such as the GET, SET and STATUS messages sent to a
server model.
● Control model: contains both a server and client model allowing
communication with other server and client models.
Models can be extended to include additional functionality instead of
modifying the original model. A model that is not extended is called a root
model.
Scenes
Another concept we want to cover is the concept of scenes in a Bluetooth
mesh network. A scene is a stored collection of states and is identified by a
16-bit number which is unique within the mesh network.
Scenes allow triggering one action to set multiple states of different nodes.
They can be triggered on-demand or at a specified time. For example, a
scene may be configured to set the temperature of a room to 72 degrees, the
living room lights to a certain brightness level, and the window blinds to close.
3. Types of Nodes
All types of nodes can send and receive mesh messages. However, optional
features give particular nodes special capabilities. Here are the different types
of nodes with optional features enabled:
● Relay nodes
● Proxy nodes
● Friend nodes
● Low power nodes
A node may support none, some, or all of these optional features, which may
be enabled or disabled at any time. For example, a single node may have the
features of a relay node, proxy node, and friend node, all at the same time.
Relay Nodes
A relay node is one that supports the relay feature. This means it can
retransmit messages that are broadcast by other nodes. This enables
extending the reach of these messages and allows them to traverse the entire
network beyond the reach of the original transmitting node.
Proxy Nodes
To allow communication with a mesh network from a non-mesh-supported
BLE device, a special type of node called a proxy node can be utilized. A
proxy node acts as an intermediary and utilizes GATT operations to allow
other nodes outside of the mesh network to interface and interact with the
network.
The protocol used in this case is called the proxy protocol, which is intended
to be used with a connection-enabled device (using GATT).
The protocol is built on top of GATT and allows a device to read and write
proxy protocol PDUs from GATT characteristics exposed by the proxy node.
The proxy node performs the translation between proxy protocol PDUs and
mesh PDUs.
For example, this allows a smartphone that does not implement the Bluetooth
mesh protocol to interact with a mesh network via a proxy device through
GATT operations.