Bluetooth mesh basics (basic concepts)

1. Background

Previously, most BLE devices performed one-to-one data communication. This is a point-to-point network topology type, called "piconet" (piconet) in the Bluetooth core specification.
Suppose a smartphone establishes a point-to-point connection with a heart rate monitor so that data can be transferred between them. One of the advantages of Bluetooth is that it allows the device to establish multiple connections, so this smartphone can then communicate with another exercise tracker. The device establishes a connection. At this point, the mobile phone can communicate with two other devices, but the two devices cannot communicate directly with each other.
Contrary to the above, mesh has a many-to-many network topology type. Each device can communicate with other devices on the network. The communication between devices is transmitted in the form of messages. One device can relay the message sent by one device to another device, so that the end-to-end communication range can be extended, which is far beyond that of a single device Bluetooth The range covered by the radio.
insert image description here

2. Devices and Nodes

A single device in a mesh network is called a node, and devices outside the network are called "unprovisioned devices". The process of connecting an "unprovisioned device" to the network to become a network node is called "provisioning". For example, a newly purchased Bluetooth light with mesh function needs simple configuration to add it to the original Bluetooth mesh network at home, so that it can be controlled through the light switch and dimmer at home. This process is called "open configuration".
The "provisioner device" (provisioner device, usually a smartphone or tablet) is informed of the new key in the process of "provisioner device" (provisioner device, usually a smartphone or tablet) during this process. The device joins the network. One of the keys is called the network key, namely NetKey, which is to improve the security of the mesh, which will be explained later.

3. Elements

Some nodes consist of multiple independent parts, each of which can be controlled independently. In a Bluetooth mesh, these individual parts are called elements. As shown in Figure 1, a light node in the network has 5 elements, one element for each LED light bulb. Each node has at least one element, called the primary element (Primary Element). Each element in a node has a uniquely determined address, called a unicast address, so that each element can be addressed independently.
Figure 1. Five elements make up a light node

4. Message

When a node needs to get the state of other nodes, or needs to control other nodes in some way, it sends a message (message). It also sends messages if a node needs to report status to other nodes. In a mesh network, all communications are delivered in the form of messages. Multiple message types are defined in the protocol specification, and each message type has its own unique opcode.
In terms of response or not, messages can be divided into two types: Response required and Response not required. A message requiring an acknowledgment requires the receiving node to return a response message after receiving the message. This response message serves two purposes:

  1. Inform the sender of the message that the message has been received.
  2. Returns some data that the receiver of the message needs to tell the sender.
    A message that requires an acknowledgment may be sent multiple times if it does not get a response, so this message must be idempotent. Idempotency means that no matter how many times the message arrives at the receiving node, the effect of reaching the receiving node once is the same. Otherwise, if the message arrives at the receiving node multiple times due to some accidents, the state of the receiving node may become uncertain.
    A message that does not require an acknowledgment does not require the recipient to send a response message.
    A message of a particular type can operate on one or more state values. Messages can also be divided into three categories: GET, SET, and STATUS, corresponding to the three operations supported by the Bluetooth mesh network.
    The GET message can be used to request a status value from one or more nodes, and then the corresponding node will return STATUS information to inform the requested status value.
    The SET message can change the value of the established state. Some SET messages require a response and require a STATUS message to be returned, and some messages do not need a response.
    The STATUS message can be used to respond to the GET message, and can also be used to respond to the SET message or sent regularly through a timer in an element.
    We can identify a specific state by the message opcode (opcode). On the other hand, we can also use the 16-bit attribute ID in the general attribute related message to directly refer to the attribute.

5. Address

Messages must be sent from one address to another. Three types of addresses (excluding unassigned addresses) are defined in the Bluetooth mesh protocol. The
unicast address is used to uniquely determine a single element. During the "Activation Configuration" process, a unicast address will be assigned to the device.
A group address is a type of multicast address that can represent one or more elements. Group addresses are either dynamically assigned or predefined by the Bluetooth SIG (SIG fixed group addresses). The Bluetooth SIG has defined four fixed group addresses, namely All-proxies, All-friends, All-relays and All-nodes. We can configure the application to create dynamic group addresses that reflect some physical assignment of a building, such as defining a group address for each room in the building.
A virtual address can be assigned to one or more elements, spanning one or more nodes. A virtual address is in the form of a 128-bit UUID to which any element can be associated, more like a label.
The virtual address can be pre-configured before leaving the factory, and then used in some specific scenarios, such as making addressing of a projector made by a certain manufacturer more convenient.

6. Status and properties

Elements may be in various conditions, called states in Bluetooth mesh. An element can have multiple states, each state being a specific set of values. State is associated with a specific behavior and cannot be reused elsewhere.
For example, Bluetooth mesh defines a general switch state to describe the possible state of a light. Assign a value of 1 to turn on the light, and assign a value of 0 to turn off the light.
Properties are similar to states in that they contain values ​​associated with an element, but otherwise differ significantly.
Friends who are familiar with BLE should understand characteristics (characteristic), they are a data type that is not associated with a specific behavior, so that they can be easily reused (chong). Using the properties mentioned above, properties can be associated with specific meanings. One thing to pay special attention to is that the property here is completely different from the property in the BLE protocol stack. In order to prevent confusion, we can also translate the former into "property".

7. Model

Models bring together the previously mentioned concepts and define the functionality of elements. There are three types of models defined in the current Bluetooth mesh specification.
The first is the server model, which defines a series of states, state transitions, state bindings, and messages that elements in the model can send and receive. It also defines behaviors corresponding to messages, states, and state transitions.
The second is that the client model (client model) does not define any state, it only defines several kinds of messages. These messages can be used to operate on the state in the corresponding server model, such as GET, SET, and STATUS.
The third is the control model (Control model) contains a server model and a client model. Server models can be used to communicate with other clients, and client models can be used to communicate with other server models.
New models can be created by extending a model. However, there is a model that cannot be extended. This model is called the root model.
Models cannot be changed, that is, behavior cannot be added or removed from the model. The only way to implement a new model is to extend an already existing model.

8. Features

All nodes can send and receive mesh messages, but some nodes can also be individually endowed with additional features to have specific functions. There are four features to choose from: Relay, Proxy, Friend and Low Power. Each node can support 0 or more of the above four features, and the configured features can be canceled at any time.

Guess you like

Origin blog.csdn.net/panpan_jiang1/article/details/126533066