[Reprint] Talking about Bluetooth Mesh Networking Technology

This article is reprinted from Eren: https://www.erenship.com/posts/63c7.htmlBluetooth
SIG official website: https://www.bluetooth.com/zh-cn/Bluetooth
SIG official account: BluetoothSIGBluetooth
SIG Bluetooth Mesh related references to this blog: Bluetooth mesh — Summary of Decrypted Bluetooth Mesh Series Articles

This article is mainly based on the relevant blog posts of the Bluetooth Technology Alliance (SIG) and its official WeChat public account on Bluetooth Mesh networking, aiming to have a preliminary understanding of Bluetooth Mesh networking technology.

foreword

Bluetooth Mesh was born out of a private protocol advocated by CSR - CSR Mesh, which was born in 2014.

The Bluetooth Special Interest Group (SIG) officially announced on July 19 last year that Bluetooth technology began to fully support Mesh mesh networks. Bluetooth Mesh networking is a networking technology that is supported by all Bluetooth 4.0 and above chips that support Bluetooth Low Energy. The new Mesh function provides many-to-many transmission between devices, and especially improves the communication ability to build a large-scale network coverage. It is suitable for building automation, wireless sensor networks, etc., where tens of thousands of devices need to be transmitted in a reliable and safe environment. IoT solutions. Today, the scope of application of Bluetooth has gradually expanded to all edge scenarios of the Internet of Things: the application of "Bluetooth Enhanced Rate Technology (BR / EDR)" has developed from wireless headsets to mouse keyboards; "Bluetooth Low Energy Technology" has been applied to watches, bracelets , to explore the wearable market; while "Bluetooth Mesh networking technology" is aimed at the entire (edge ​​domain) Internet of Things market, including consumer and industrial fields [1] .

Bluetooth Low Energy (BLE)

To discuss Bluetooth Mesh networking technology, Bluetooth Low Energy (BLE) must be explained first, because Bluetooth Mesh networks use and rely on Bluetooth Low Energy. Bluetooth low energy technology is a wireless communication protocol stack used by Bluetooth Mesh [2] .

First of all, Bluetooth is a radio technology for short-range communication. Its characteristics are:

  • Decentralized network structure;
  • point-to-point or multipoint communication;
  • Fast frequency hopping and short packet technology;
  • Work in the 2.4GHz ISM band (Industrial Scientific Medical Band);
  • Time-division full-duplex transmission.

Bluetooth low energy generally refers to Bluetooth 4.0 or higher modules. Bluetooth low energy technology is a low-cost, short-range, interoperable wireless technology communication technology that operates in the license-free 2.4GHz ISM radio frequency band. Compared with traditional Bluetooth (Classic Bluetooth, BT), Bluetooth Low Energy has lower power consumption, longer transmission distance, and can realize AOA indoor positioning. Today's electronic devices are basically equipped with Bluetooth modules above BLE 4.0. For example, our wireless headsets, smart bracelets, and various red, yellow, blue, and green bicycles all use low-power Bluetooth modules for communication.

BLE low-power Bluetooth and traditional Bluetooth have the following five major differences [5] :

  1. The sending and receiving tasks of Bluetooth Low Energy will be completed as quickly as possible. After completion, Bluetooth BLE will suspend wireless transmission (but still accept), and wait for the next connection to be activated again; traditional Bluetooth is to keep connecting;
  2. There are only 3 broadcast channels for low-power Bluetooth (divided to ensure that the network does not interfere with each other); traditional Bluetooth has 32;
  3. It only takes 3ms for Bluetooth low energy to "complete" a connection (that is, scan for other devices, establish a link, send data, authenticate and end appropriately); traditional Bluetooth needs hundreds of milliseconds to complete the same connection cycle;
  4. Bluetooth low energy uses very short data packets, and is mostly used in products with relatively high real-time requirements but relatively low data rates, such as remote control such as keyboards, remote control mice, and data transmission of sensor devices, such as heartbeat belts and blood pressure monitors , temperature sensor, etc.; traditional Bluetooth uses a longer data packet length, which can be used for transmission of relatively large data volume, such as voice, music, high data volume transmission, etc.;
  5. Bluetooth low power consumption has no power level, the general transmission power is +4dBm, and the transmission distance is generally 70m in an open distance; traditional Bluetooth has 3 power levels, Class1, Class2, and Class3, which support transmission distances of 100m, 10m, and 1m respectively .

The Bluetooth low energy architecture consists of two chips: a single-mode chip and a dual-mode chip. The Bluetooth single-mode chip can communicate with other single-mode chips and dual-mode chips. At this time, the latter needs to use the Bluetooth low energy technology part of its own architecture to send and receive data. The dual-mode chip is also capable of communicating with standard Bluetooth technology and other dual-mode chips using the legacy Bluetooth architecture.

Bluetooth Mesh networking

Bluetooth Mesh technology is not a wireless communication technology, but a network (networking) technology used to build a "many-to-many communication connection" network.

To put it simply, Bluetooth Mesh networking is to connect many Bluetooth devices to each other to form a network. Individual Bluetooth devices are called nodes in the network (some key nodes are called gateways). Each node can communicate with each other.

Bluetooth Mesh allows us to establish a "many-to-many" (m:m) relationship between wireless devices . Additionally, the device is capable of relaying data to other devices that are not within direct radio coverage of the original device. In this way, mesh networks can span very large physical areas and contain a large number of devices.

The new mesh capability enables many-to-many (m:m) device communications and is optimized for creating large-scale device networks. It is ideally suited for building automation, sensor networks, and other IoT solutions where tens, hundreds, or thousands of devices need to reliably and securely communicate with one another[2].

New mesh capabilities enable many-to-many (m:m) device communication and are optimized for creating large-scale device networks. It is ideal for building automation, sensor networks and other IoT solutions where dozens, hundreds or thousands of devices need to communicate with each other reliably and securely.

Mesh topology can provide the best way to meet the increasingly popular communication needs, so Bluetooth Mesh network emerges as the times require, typical applications include building automation and sensor networks. These communication needs include:

  • Wide coverage
  • "Direct Interoperability"
  • Ability to monitor and control a large number of devices
  • Optimized, low-power
  • Effective use of radio resources and scalability
  • Compatible with current market smartphones, tablets and PC products
  • Industry-standard compliance with government-grade security

characteristic

  • Message-Centric Communication

    Bluetooth mesh network uses publish/subscribe (publish/subscribe) message system .

    Devices can send messages to specific addresses with names and meanings that correspond to high-level concepts that users can understand, such as "Garden Lights." This is called "publishing".

    Devices are configured to receive messages sent by other devices to specific addresses. This is called "subscribing".

    When a device publishes a message to a particular address, all other devices subscribed to that address will receive a copy of that address, process it, and respond in some way.

    Imagine a set of outdoor lights installed in a garden, each of which has been configured so that it subscribes to the "Garden Lights" message. Now, imagine a Bluetooth Mesh light switch sending an "on" message to the "garden light" address. That's right, all the lights in the garden will receive the "ON" message and respond by turning on the lights.Snipaste_2020-09-13_13-11-08

  • Messages and Device Status

    "State" (state) is a key concept in Bluetooth mesh networking . Each device in a Bluetooth mesh network has an independent set of status values ​​that represent some state of the device. In the garden lights example, each light has a state value indicating whether the device is currently on or off. A Bluetooth Mesh light switch controls a light bulb by publishing a class of messages that by definition means responding to an "on" or "off" state value to change the state value. Changing the state value modifies the physical condition of the device itself, such as turning the device on or off.

    Messages, states, and device behavior related to these and other concepts are defined in specifications called "modules". Models are implemented by Bluetooth Mesh devices.

  • relay

    Thanks to mesh networking, devices can be installed over very large areas while maintaining communication with each other. Imagine the sprawling footprint of a shopping mall, airport or office building. Because of walls and other physical obstructions, a device in a building may not be able to establish a direct wireless connection with a device installed on the far side of the same building, or with a device in an adjacent building. Bluetooth mesh networking, on the other hand, solves this problem by designating certain devices on the network as "relay devices."

    Relay devices are capable of forwarding messages received from other devices. When forwarding messages, they are able to communicate with devices that are outside the wireless range of the original message-publishing device. Messages can be relayed multiple times, and each relay is a "hop". Up to 127 hops can be performed, which is enough for message transmission in a wide physical area.

    Snipaste_2020-09-13_12-54-27

  • Managed Flooding

    Bluetooth mesh networks use a method known as "network flooding (flooding)" to publish and relay messages. This means that messages are not routed through a process or along a specific path formed by a series of specific devices. Instead, all devices within transmission range receive the message, and the relay device can forward the message to all other devices within its transmission range.

    The advantage of network flooding is that no specific device is required to act exclusively as a centralized router. Failure of a centralized router can render the entire network inoperable. Not having a specific route may also have a catastrophic effect on the network, but this situation can also be avoided by using the method of network flooding in the Mesh network.

    The way the network floods also means that messages can typically take multiple paths to reach their destination. This makes for a fairly reliable network.

    • Optimizing Mesh Networks

      The Bluetooth Mesh network has also taken a series of measures to support the use of network flooding, while optimizing the energy consumption of each device and even the entire network.

      All data packets contain a field called TTL, which can be used to limit the number of hops a message can be relayed. The information contained in the heartbeat messages sent intermittently by devices allows the network to understand its topology and the number of hops to each other device. This enables the device to set the TTL to an optimal value, thereby avoiding unnecessary relay operations.

      Each device contains a message cache to determine whether it has already relayed the message. If so, the message is discarded immediately, avoiding unnecessary processing by upper stacks.

    Very power-constrained devices, such as sensors powered by small batteries for many years, may be designated as "low-power nodes." Low-power nodes are capable of cooperating with one or more devices designated as "friends". Friends are not power-constrained, they can act as a low-power node, store messages addressed to this low-power node, and only deliver messages when the low-power node needs them. The relationship between low-power nodes and "friends" is of course called "friendship".

basic terms

  • Node

    These devices in a Bluetooth Mesh network are called nodes. Every node can send and receive messages. Information can be relayed between nodes, allowing messages to travel farther than radio waves normally travel.

  • Elements

    Some nodes, such as sensors, have the potential to drain their batteries, while others, such as lighting, manufacturing machinery, and security cameras, draw their power from the main grid. Some nodes will have more processing power than others. These nodes can undertake more complex tasks and play different roles in the Mesh network, showing the following four node characteristics (Features) :

    Low-Power Features

    Power-constrained nodes may take advantage of low-power features to reduce radio on-time and save power consumption. At the same time, low-power nodes (LPN) can work together with friend nodes.

Friend feature

Nodes with unlimited power are good candidates for friend nodes. Friend nodes can store messages and security updates sent to low-power nodes (LPN); and then transmit the stored information to low-power nodes when needed by low-power nodes.

Relay Features

Relay nodes can receive and forward messages, and realize a larger-scale network by relaying messages between nodes. Whether a node is capable of this feature depends on its power and computing power.

Proxy Features

The proxy node can realize the sending and receiving of Mesh messages between GATT and Bluetooth Mesh nodes. Nodes in this role require fixed power and computing resources.

Snipaste_2020-09-13_13-46-07

Some nodes are more complex than others and consist of multiple independent parts called Elements. Each node has at least one element, called the primary element (Primary Element), and may also contain other elements.

Snipaste_2020-09-13_13-28-21

Elements consist of entities that define node functionality and element conditions. For example, a light bulb has an element inside it, and has two functions:

node = bulb

an element = main element

Node function:

​ - On/Off

​ - Brightness

Element Condition/Status:

​ - "on" or "off"

​ - 0 – 10 (brightness level)

Each element in a node has a unique address, called a unicast address, so that each element is addressable.

  • Model (Model) and state (State)

    Regardless of whether the nodes are located in the network of manufacturing plants, hotels, office buildings, or business parks, the basic functions of the nodes are defined and implemented by the Model. Models are inside elements, and elements must have at least one model. The model can define and implement the function and behavior of the node, while the state (State) can define the condition of the element .

    Snipaste_2020-09-13_13-31-29

    Taking the light bulb as an example, the function of this model is to switch and adjust the brightness. The relevant states are "on" / "off" and 0-10 respectively:

    model (node ​​function)

    ​1. On/Off

    ​ Status -> "On" or "Off"

    ​2. Brightness (0-10)

    ​ Status -> 0-10

  • Bluetooth Mesh supports composite states, which are states that consist of two or more values. An example of this is color-changing lights, where hues can be changed independently of color saturation or brightness.

    The term "bound state" is defined from the situation where a change in one state causes a change in another state. Level state and on/off state are usually tied to each other. If the level changes from 0 to 1, the state of the "on/off" also changes from "off" to "on".

    Each model has a unique identifier. The Bluetooth SIG uses a 16-bit model, while the vendor uses 32 bits (including a 16-bit company identifier assigned by the Bluetooth SIG and a 16-bit model identifier assigned by the vendor). This ensures that each model's address is unique and definitely addressed.

    A Bluetooth mesh network communicates through a client-server architecture using messages. The function of the server is to expose the state of the element. One of the simplest states is a binary switch, where the state is "on" or "off". A simple server model is the Generic On/Off Server Model, which includes a state that represents whether the switch is on or off.

    Clients can access the state to request, change or use the server's state. An example of a simple client model is the Generic On/Off Client Model (binary switch). The generic on/off client model controls the generic on/off server model by sending messages. For example, a client can use this mechanism to turn a light on or off.

    protocol stack

    Bluetooth mesh networking introduces a whole new protocol stack . This protocol stack is built on top of Bluetooth Low Energy technology. The figure below depicts the layers of the protocol stack .

    Snipaste_2020-09-13_13-48-12

    • Bearer layer: The bearer layer defines how to transmit PDUs using the underlying low-power stack. Currently, two bearer layers are defined: Advertising Bearer and GATT Bearer.
    • Network layer : The network layer defines various message address types and network message formats. Relay and proxy behavior is implemented through the network layer.
    • Lower transport layer: The lower transport layer handles segmentation and reassembly of PDUs when required.
    • Upper transport layer (upper transport layer) : responsible for encrypting, decrypting and authenticating the application data in and out of the access layer. It is also responsible for a special class of messages called "transport control messages", including heartbeats and messages related to "friendship".
    • Access layer: responsible for the format of the application data, defining and controlling the encryption and decryption process performed in the upper transport layer, and verifying that the received data is suitable for the correct network and before forwarding the data to the protocol stack application.
    • Foundation models: The foundation model layer is responsible for implementing models related to Mesh network configuration and management.
    • Models: The model layer is concerned with the implementation of models, etc., and implementations such as behavior, messages, state, etc.

    Nodes (such as lighting fixtures, temperature control equipment, manufacturing equipment, and electric doors) are devices in a Bluetooth Mesh network that can send, receive, or relay messages. Message (message) is used to transmit data between nodes, address (address) is used to define message source (source) address and destination (destination) address.

    Address

    There are four types of addresses, three of which are used for message delivery: unicast, virtual, and group addresses. The fourth type is called an unassigned address. Addresses are 16 bits long and encoded as defined below.

    640

    Unassigned Address

    An unconfigured element or an element that has not been assigned an address has an unassigned address. Since these elements do not have unique addresses, they are not used for message delivery.

    Unicast Address

    During "provisioning" (provisioning), the provisioner assigns each element in the node a unicast address for the lifetime of the network node. The unicast address may appear in the source address field or the destination address field of the message. Messages sent to a unicast address can only be processed by one element.

    Virtual Address

    A virtual address is a set of elements associated with a particular UUID label ; these addresses may be published or subscribed to. A UUID tag is a 128-bit value associated with multiple elements from one or more nodes.

    For the virtual address, bits 15 and 14 are set to 1 and 0 respectively; bits 13 – 0 are set to the hash value (providing 16384 hash values). The hash (hash) comes from the Label UUID. Using a subscribing element to check a full 128-bit UUID is very inefficient, especially if the UUID spans multiple message segments. Hash values ​​provide a more efficient way of determining which messages are sent to which elements.

    Group Address

    The group address is another multicast address in the Bluetooth Mesh network . It usually represents multiple elements in one or more nodes and contains two types:

    • Dynamically Assigned Address (Dynamically Assigned) -> 0xC000-0xFEFF
    • Fixed Address (Fixed Address) - assigned by the Bluetooth SIG, divided into five segments.

    Message

    Bluetooth mesh networking communicates through messages. Messages can be divided into control messages and access messages.

    Control Message: Messages related to Bluetooth Mesh network operations, such as heartbeat and friend request messages.

    Access Message: This type of message allows the client model to retrieve or set state values ​​in the server model, or is used by the server to report state values.

    A model implements and defines the functionality of a node. Elements are the only addressable entities within a node (one or more models can be contained in a node), and state changes of elements are defined by state . For each state, there is a set of messages supported by the server model. Examples include a client model that requests a state value or a request to change state, and a server model that sends messages about state or state changes.

    Access messages are divided into two categories: acknowledged (acknowledged) and unacknowledged (unacknowledged) . Acknowledged messages are sent to and acknowledged by each receiving element. The response is usually a status message. There is no response to unacknowledged messages. For example, the status message of the Bluetooth Mesh network is an unacknowledged message.

    Security

    The security guarantee of all Bluetooth Mesh network messages comes from the encryption and verification of messages by the network key (NetKey) and application key (AppKey). NetKey is used for network layer communication. Assuming a Bluetooth mesh network has no subnets, all communications within the mesh network use the same network key.

    AppKey is used for application data. Some nodes in the network have specific applications, and access to some potentially sensitive data is restricted according to the needs of the applications. These nodes have a specific AppKey and are associated with a specific application. Areas that would use different AppKeys typically include security (building access, computer room access, and CEO office access), lighting (manufacturing plants, exterior building lighting, and walkways), and HVAC systems.

    Relay nodes (such as light bulbs or wall switches) typically have a valid NetKey and are capable of relaying sensitive messages within the network. However, these nodes cannot access specific AppKeys in various restricted areas, such as building controls or HVAC systems, nor can they decrypt the application's data.

    Start configuration (Provisioning)

    The whole process of starting the configuration includes about 5 steps [1] , which are:

    • Beaconing: Send a Beacon signal to tell you that I want to configure the network, here is the newly defined AD broadcast packet type, Mesh AD;
    • Invitation: After hearing the Beacon, the provisioner sends an invitation, using the PDU (Protocol Data Unit) for inviting the network;
    • Exchanging Public Keys: exchanging public keys;
    • Authentication: an interactive random number authentication process;
    • Distribution of the Provisioning Data: After the authentication is completed, the Session Key is derived from the public key and the private key of the two devices. The subsequent information exchange process of the provisioning network will be encrypted with this Session key. After the network provisioning is successful, it will be based on the final One step contains the exchanged NetKey to encrypt the subsequent data exchange

    information exchange

    The Bluetooth Mesh network uses a publish/subscribe (publish/subscribe) model for message transmission. Nodes that generate messages publish messages. Nodes that need to receive messages subscribe to the addresses they need. Messages can be published to unicast, group or virtual addresses.

    Messages can be sent as replies to other messages or as unsolicited messages. When the model sends a reply message, it uses the source address where the message originated as the destination address. When sending an unsolicited message, the model will use the model's publish address as the destination address. Each model in the node has a publish address.

    When receiving messages, each instance of a model within a node (there may be multiple models in a node) can subscribe to receive messages from one or more groups or virtual addresses.

    Models that subscribe to messages use the model's subscription list to define valid addresses for receiving messages. When a model receives a message, the model checks its subscription list. When the address on the subscription list is set to the element unicast address of the model or the fixed group address belonging to the node, it is considered a match. The figure below shows the valid source and destination addresses for incoming messages.

    640 (1)

    When the Bluetooth Mesh entity publishes the status of various nodes, the system in the entire Bluetooth Mesh network can subscribe to the data regardless of its distance from the node sending the data. This enables devices at one end of the network to communicate with other managers in the facility through low-power wireless messages, regardless of distance.

    Advanced

    postscript

    Although the protocol of Bluetooth Mesh networking technology has been proposed, I personally feel that the relevant SDK development kit is still immature. However, future application scenarios are still imaginable.

    As envisioned by the Bluetooth Interest Alliance:

    We expect Bluetooth mesh networking to be widely adopted across industries and applications, starting with applications such as building automation, commercial lighting, and sensor networks . Especially exciting is the application of Bluetooth mesh networking in commercial lighting . Just imagine, with the right firmware, a lighting system can do more than wireless light control, but also become a platform for various Bluetooth services in the building, such as material tracking and location services!

    reference

Guess you like

Origin blog.csdn.net/CJohn1994/article/details/127583954