Bluetooth Mesh
About Bluetooth Mesh
On July 17, 2017, the Bluetooth SIG organization released the Bluetooth Mesh standard. Bluetooth Mesh differs from the traditional Bluetooth Low Energy (BLE) protocol's one-to-one and one-to-many communication methods by enabling many-to-many communication. This allows for intercommunication among all nodes within the mesh network. The Bluetooth Mesh protocol is built on top of the physical and link layers of BLE, meaning it can communicate with Bluetooth devices version BLE 4.0 and higher. However, it's important to note that this does not imply support for all the latest BLE features, such as the LE Coded PHY and 2M PHY, which are not supported in the current Bluetooth Mesh specification.

BLE physical layer and link layer
Physical Layer
BLE operates in the 2.4GHz ISM band of 2402MHz-2480MHz. BLE defines 40 channels, each with a width of 2MHz. There are 3 broadcast channels, 37, 38, and 39 marked in green in the figure. They are used for device discovery, broadcasting, and other functions. The frequency bands of these three channels just avoid the most commonly used channels 1, 6, and 11 of WiFi, which also operates in the 2.4GHz band, to reduce interference with normal communication. The other 37 channels are used for two-way data transmission after BLE establishes a connection, called data channels. After turning on the adaptive frequency hopping function of Bluetooth, the device will automatically detect interference to select the appropriate working channel. These two channel types correspond to the two main communication modes of BLE, Advertising and Connection. Bluetooth Mesh only uses the Advertising method for communication between nodes within the network.

Link Layer
Advertising means that the Bluetooth broadcasting device sends messages at specific time intervals in three broadcasting channels, and the Bluetooth scanning device scans the three broadcasting channels in sequence with a specific time length of scanning window and interval to receive the information sent by the broadcasting device. The three different colored bar graphs in the figure represent the three broadcasting channels 37, 38, and 39. The broadcasting device sends messages in three channels continuously with an interval of 20ms. The scanning device has a scanning window time of 30ms and a scanning interval of 40ms, scanning one channel at a time. When the Bluetooth Mesh device communicates within the network, it scans the broadcasting channel with a duty cycle as close to 100% as possible. That is to say, the scanning window time is equal to the scanning interval to ensure that the information will not be lost. When sending specific information, the Bluetooth Mesh device does not wait for a broadcast interval like ordinary BLE broadcasting, but delays a short random time and sends it out immediately.

BLE System Architecture
The Bluetooth mesh protocol stack is a hierarchical structure.

- The lowest layer is the BLE layer . As mentioned at the beginning, Bluetooth mesh is built on the BLE physical layer and link layer, using two data transmission methods: Advertising and Connection.
- Bearer layer : The bearer layer defines how to use the underlying LE stack to transmit PDUs. Currently, two types of bearers are defined, Advertising Bearer and GATT Bearer.
- Network layer : The network layer defines various message address types and network message formats. Relay and proxy behaviors are implemented by the network layer.
- Lower transport layer : The lower transport layer handles segmentation and reassembly of PDUs when necessary.
- Upper transport : Responsible for encryption, decryption, and authentication of application data transmitted to and from the access layer. It is also responsible for processing special messages called transport control messages. These include heartbeats and messages related to "friendship" relationships.
- Access layer (access) : Responsible for the format of application data, defining and controlling the encryption and decryption processes performed at the upper transport layer, and verifying that data received from it is intended for the correct network and application before forwarding it up the stack.
- Foundation models : The foundation model layer is responsible for implementing models related to the configuration and management of MESH networks.
- Models : The model layer is concerned with the implementation of models, and therefore also with the implementation of behaviors, messages, states, etc.
Node Features
Bluetooth Mesh nodes all have the function of sending and receiving messages, and nodes can also choose some features, such as relay, proxy, friend, and low power.

- Relay feature : Nodes that have this feature enabled can receive and forward messages to other devices in the mesh network through Advertising Bearer. It only forwards messages that are not in the message cache and whose TTL value is greater than 1. Before forwarding, the TTL value will be reduced by 1. The Bearer here refers to the bearer layer in the Bluetooth Mesh protocol, which mainly abstracts BLE data for use by the upper layer. Currently, two types of bearers are defined: broadcast bearer and GATT bearer, corresponding to the Advertising and Connection modes of BLE respectively.
- Proxy feature : In order to be compatible with billions of BLE devices on the market that do not support Bluetooth Mesh, such as mobile phones and tablets, nodes that enable this feature can communicate with BLE devices on the data channel using BLE GATT Bearer, and the proxy node will forward messages from mobile phones and tablets to other devices in the mesh network through Advertising.
- Friendship feature : It contains two sub-features, friend and low power feature. For power-sensitive devices such as button battery powered devices, low power feature is enabled, and they are in sleep state most of the time, waking up once at a longer time interval. However, the messages delivered to them during sleep are likely to be missed, so the device with friend feature enabled can help the low power device combined with it cache messages. After waking up from sleep, the low power device queries its friend device for messages and makes corresponding processing.
Network topology
The figure shows the Bluetooth Mesh network topology. Nodes with different features enabled are called low-power nodes, friend nodes, and relay nodes.

The connection between nodes indicates a direct connection within the coverage of the wireless signal. Communication between nodes outside the coverage of the wireless signal needs to go through the relay node. As shown in the figure, Q, R, and S forward messages to the destination node. There are 3 friend nodes in the figure, of which nodes P and O have 3 and 2 low-power node combinations respectively, and friend node N has no low-power node combination. Node T is a BLE device, communicating with the proxy relay node S through the GATT Bearer method. Node S must forward all message transmissions with node T. For example, BLE node T wants to send a message to the low-power node L. First, node T sends a message to node S on the data channel through GATT Bearer, and then node S forwards the message on the broadcast channel through Advertising Bearer. Nodes H, R, O, and N are all within their wireless signal coverage and receive the message. Node O, as a friend of low-power node L, will store the received message. After node L wakes up from sleep, it will query friend node O to obtain the message sent to it and do corresponding processing.