The Bluetooth Mesh is a profile specification developed and published by the Bluetooth SIG. This document explains the basic concepts of the Bluetooth Mesh and gives an overview of the operation and capabilities of the profile, as well as explaining the life cycle of a mesh device. For more specific information about Nordic Semiconductor's implementation of the Bluetooth Mesh, see the mesh architecture documentation.
蓝牙MESH的基本概念
蓝牙MESH是一个由蓝牙团体开发和发布的概要文件规范,该文档解释了蓝牙MESH的基本概念,并概述了概要" profile"的操作和功能,并解释了一个mesh设备的生命周期。要了解更多关于北欧半导体实现蓝牙网格的信息,请参阅MESH架构文档。
Relation to Bluetooth low energy
The Bluetooth Mesh is based on the Bluetooth low energy part of the Bluetooth 4.0 Specification and shares the lowest layers with this protocol. On-air, the Bluetooth Mesh physical representation is compatible with existing Bluetooth low energy devices, as mesh messages are contained inside the payload of Bluetooth low energy advertisement packets. However, Bluetooth Mesh specifies a completely new host layer, and although some concepts are shared, Bluetooth Mesh is incompatible with the Bluetooth low energy host layer.
与低功耗蓝牙的关系
蓝牙MESH是基于蓝牙4.0规范的蓝牙低能量部分,并与该协议共享最低层。在空中,蓝牙MESH物理层表示与现有的低功耗蓝牙设备兼容,因为MESH信息包含在蓝牙低能量广播包的有效负载中。然而,蓝牙MESH指定了一个全新的主机层,尽管一些概念是共享的,但蓝牙MESH与低功耗主机层是不兼容的。
蓝牙MESH和低功耗蓝牙技术之间的关系
Application areas
Bluetooth Mesh primarily targets simple control and monitoring applications, like light control or sensor data gathering. The packet format is optimized for small control packets, issuing single commands or reports, and is not intended for data streaming or other high-bandwidth applications.
Using Bluetooth Mesh causes higher power consumption than traditional Bluetooth low energy applications. This is mainly due to the need for keeping the radio running constantly. Therefore, unlike Bluetooth low energy advertisers, active mesh devices cannot be run off coin-cell batteries for extended periods of time.
Bluetooth Mesh supports up to 32767 devices in a network, with a maximum network diameter of 126 hops.
应用领域
蓝牙MESH主要针对简单的控制和监视应用,比如光控或传感器数据采集。包格式针对小的控制包进行了优化,发出单一的命令或报告,并且不适合用于数据流或其他高带宽的应用程序。使用蓝牙MESH比传统的低功耗蓝牙技术更能消耗电能。这主要是由于需要保持无线电的持续运行。因此,不像BLE的广播客户,活跃的网状设备不能在长时间内关闭电池。在一个MESH中,蓝牙MESH最多支持32767个设备,最大的MESH直径为126跳。
Network topology and relaying
Bluetooth Mesh is a broadcast-based network protocol, where every device in the network sends and receives all messages to and from all devices within radio range. There is no concept of connections in a mesh network. Any device in the network may relay messages from any other device, which makes it possible for a mesh device to send a message to a device outside of radio range by having one or more other devices relay the message towards the destination. This property also allows devices to move around and drop in and out of the network at any time.
网络拓扑和中继
蓝牙MESH是一个基于广播的网络协议,在这个网络协议中,网络中的每一个设备都发送和接收来自无线电范围内所有设备的所有消息。在网状网络中没有连接的概念。网络中的任何设备都可以从其他设备中传输消息,这使得一个网络设备可以通过让一个或多个其他设备将消息传递到目的地,从而将消息发送到无线电范围之外的设备上。这一特性还允许设备在任何时候移动和退出网络。
Mesh transport
Bluetooth Mesh utilizes the Bluetooth low energy advertiser and scanner roles, communicating through Bluetooth low energy advertisement packets. The advertisement packets are picked up by nearby mesh devices and handled like other Bluetooth low energy advertisement packets. The mesh packets are represented with a unique AD type and added to the advertisement packet payload.
Bluetooth low energy devices send advertisement packets at regular advertisement intervals, and mesh packets are no exception. However, unlike traditional advertisers, mesh devices will change their advertisement payload on every transmission, broadcasting new mesh packets as they are queued up in the stack. Every Bluetooth Mesh advertisement is transmitted only once for every device, and if there is no traffic in the mesh, the devices stay silent.
MESH传输
蓝牙MESH利用BLE的广播和扫描仪角色,通过BLE的广播包进行通信。广播包被附近的MESH设备接收,并像其他BLE的低能量广播包一样处理。MESH数据包以唯一的广播类型表示,并添加到广播层的有效负载中。
BLE在定期的广播间隔发送广播包,而MESH数据包也不例外。然而,与传统的广播者不同的是,MESH设备将会在每次传输中改变广播层的有效负载,在堆栈中按照队列的方式排列新的MESH包。每个蓝牙MESH广播包只在每台设备上传输一次,如果在MESH中没有流量,设备就会保持沉默。
Relays
Bluetooth Mesh expands the range of the network by relaying messages. Any mesh device may be configured to act as a relay, and no dedicated relay devices are needed to build a network. Every device acting as a relay will decrement the Time To Live (TTL) value in received messages and forward them if the TTL is two or higher. This undirected relaying is referred to as messageflooding and ensures a high probability of message delivery, without requiring any information on the network topology. The Mesh Profile Specification does not provide any routing mechanisms, and all messages are forwarded by all relays until the TTL value reaches zero. To avoid messages being forwarded by the same relays over and over, all mesh devices maintain a message cache. This cache is used for filtering out packets that the device has already handled.
The flooding based approach to message relaying can cause a lot of redundant traffic on air, which may impact the throughput and reliability of the network. Therefore, it is highly recommended to limit the number of relays in a network to restrict this effect. The rate of relay-enabled devices in the network is a trade-off between message route-redundancy and reliability. It should be tuned according to network density, traffic volumes, network layout, and requirements for reliability and responsiveness.
中继器
蓝牙mesh通过转播消息来扩展网络的范围。任何网络设备都可以配置为一个中继器,并且不需要专门的中继设备来建立一个网络。作为中继的每一个设备都将减少接收消息的时间(TTL)值,如果TTL是2或更高,则转发它们。这种无定向的中继被称为消息泛滥,并确保消息传递的高概率,而不需要任何关于网络拓扑的信息。网格配置文件规范不提供任何路由机制,所有的消息都由所有的中继转发,直到TTL值达到0。为了避免被相同的中继转发的消息,所有的网格设备都维护一个消息缓存。这个缓存用于过滤设备已经处理过的数据包。基于洪水的消息传递方法可能会导致大量的空中冗余流量,这可能会影响网络的吞吐量和可靠性。因此,强烈建议限制网络中继电器的数量来限制这种效果。在网络中,启用了中继的设备的速率是消息的冗余和可靠性之间的一种权衡。它应该根据网络密度、流量、网络布局和可靠性和响应性需求进行调整。
GATT proxy
To enable support for legacy Bluetooth low energy devices that do not support receiving mesh packets, Bluetooth Mesh defines a separate protocol for tunneling mesh messages over the Bluetooth low energy GATT protocol. For this purpose, the Mesh Profile Specification defines a GATT bearer and the corresponding GATT Proxy Protocol. This protocol allows legacy Bluetooth low energy devices to participate in the mesh network by establishing a GATT connection to a mesh device that has the proxy feature enabled.
The legacy device gets assigned an address and the necessary keys to become a full-fledged member of the network. The device receives the security credentials through the regular provisioning procedure or through some out-of-band mechanism.
GATT 代理
为了支持不支持接收网格数据包的传统蓝牙低功耗设备,蓝牙MESH定义了一个单独的协议,用于通过蓝牙低功耗的GATT协议来实现隧道网消息。为此,MESH配置文件规范定义了一个GATT的持有者和相应的GATT代理协议。该协议允许传统的蓝牙低功耗设备通过建立一个GATT连接到一个具有代理特性的网格设备来参与MESH。
遗留设备被分配一个地址和必要的密钥,成为网络的正式成员。该设备通过常规的配置过程或通过一些带外的机制接收安全凭据。
Power consumption
To enable broadcast-based communication, the devices must continuously keep their radio in listening mode, causing significantly higher power consumption than in a typical Bluetooth low energy device. To enable low power devices to take part in the mesh network, Bluetooth Mesh contains a low power friendship feature. This protocol lets low power devices establish a relationship with a regular mesh device, which will then cache and forward messages to the low power device at regular intervals. This saves the low power device from having to stay on to listen for incoming messages.
电力消耗
为了支持基于广播的通信,设备必须连续不断地将无线电保持在收听模式中,这比典型的低功耗蓝牙低功耗设备的功耗要高得多。为了使低功耗设备能够参与到MESH网络中,蓝牙MESH包含了一个低功耗的友好功能。该协议允许低功耗设备与常规的mesh设备建立一种关系,然后定期将消息缓存和转发给低功耗设备。
这样就可以节省低功率设备,让它不必再继续听传入的消息了。
Addressing
The Bluetooth Mesh addressing scheme is different from the Bluetooth low energy addressing scheme. It features three types of addresses:
- Unicast addresses: unique for every device
- Group addresses: allow forming a group of devices and addressing them all at once
- Virtual addresses: untracked UUID-based addresses with a large address space
When a device is added to a network, it is assigned a range of unicast addresses that represents it. A device's unicast addresses cannot be changed and are always sequential. The unicast address space supports having 32767 unicast addresses in a single mesh network. Unicast addresses can be used by any application to directly send a message to a device.
Group addresses are allocated and assigned as part of the network configuration procedure. A group address may represent any number of devices, and a device may be part of any number of groups. There can at most be 16127 general purpose group addresses in a mesh network.
The virtual addresses can be considered a special form of group addresses, and can be used to represent any number of devices. Each virtual address is a 128-bit UUID generated from a text label. The virtual addresses do not have to be tracked by a network configuration device, and in this way, users can generate virtual addresses prior to deployment or addresses can be generated ad-hoc between devices in the network.
寻址
蓝牙MESH寻址方案与低功耗蓝牙寻址方案不同。它有三种类型的地址:
- 单一地址:每个设备的唯一
- 组地址:允许形成一组设备,并一次性处理它们
- 虚拟地址:未跟踪的基于uuid的地址,地址空间很大
当一个设备被添加到一个网络时,它被分配一个代表它的单一地址的地址。设备的单位地址不能更改,而且总是顺序的。单一的地址空间支持在单一的网格网络中拥有32767个单位地址。任何应用程序都可以使用单播地址直接向设备发送消息。组地址分配和分配作为网络配置过程的一部分。组地址可以表示任意数量的设备,并且设备可能是任意数量的组的一部分。在一个网状网络中最多可以有16127个通用目标组地址。虚拟地址可以看作是组地址的一种特殊形式,可以用来表示任意数量的设备。每个虚拟地址都是由一个文本标签生成的128位UUID。虚拟地址不需要通过网络配置设备来跟踪,这样,用户可以在部署之前生成虚拟地址,也可以在网络中的设备之间生成特定的地址。
Provisioning
Before a device can participate in normal mesh operation, it must be provisioned. During provisioning, a device gets added to the network and is assigned unicast addresses, a network key, and a device key. The provisioning is done by a Provisioner, which is a trusted device with access to the full list of devices in the network and their addresses. After the new device has been provisioned, the provisioner is expected to use the new device's device key to establish a secure channel to configure it.
供应
在一个设备能够参与正常的网格操作之前,必须先提供它。在供应过程中,一个设备被添加到网络中,并被分配到一个单一的地址、一个网络密钥和一个设备密钥。供应是由一个供应者完成的,这是一个受信任的设备,可以访问网络中的所有设备和它们的地址。在配置了新设备之后,预计将使用新设备的设备密钥来建立一个安全通道来配置它。
Models and Elements
To standardize communication between devices from different vendors, the Mesh Profile Specification defines an access layer, which routes mesh messages between the various models in a device. A model represents a specific behavior or service and defines a set of states and messages that act on these states. The Mesh Profile Specification and the Mesh Model Specification each define a set of models to cover typical usage scenarios like device configuration, sensor readings, and light control. In addition to these, vendors are free to define their own models with accompanying messages and states.
The models in a device belong in elements. Every device has one or more elements, each acting as a virtual entity in the mesh with its own unique unicast address. Each incoming message is handled by a model instance in an element. To make it possible to uniquely resolve how messages are handled, only one model instance per element can implement a handler for a specific message opcode. If a device has multiple instances of the same model, each instance must be assigned to a separate element. Similarly, if two models implement handlers for the same message, these models must be in separate elements.
To represent complex behavior with minimal message and state duplication, models can be made up of other models, potentially spanning multiple elements. These models are referred to as extended models. Models that are purely self-contained are referred to as root models.
Models talk to each other through a publish and subscribe system. Every model may subscribe to a set of group and virtual addresses, and the model will only handle messages that are published to one of its subscription addresses or the containing element's unicast address. Any model may maintain a publish address that it publishes messages to. This publish address can be of any type.
模型和元素
模型和元素为了规范来自不同供应商的设备之间的通信,网格配置文件规范定义了一个访问层,它在设备的不同模型之间路由网格消息。模型表示特定的行为或服务,并定义一组状态和消息,这些状态和消息在这些状态下执行。网格配置文件规范和网格模型规范分别定义了一组模型来覆盖典型的使用场景,比如设备配置、传感器读数和光控制。除了这些,供应商还可以自由地定义自己的模型,并提供相应的消息和状态。
设备中的模型属于元素。每个设备都有一个或多个元素,每个元素都在网格中作为一个虚拟实体,并具有自己唯一的单一地址。每个传入消息都由一个元素中的模型实例处理。为了能够唯一地解决如何处理消息的方式,每个元素只有一个模型实例可以为特定的消息操作码实现一个处理程序。如果一个设备具有相同模型的多个实例,那么每个实例必须被分配给一个单独的元素。类似地,如果两个模型为相同的消息实现处理程序,那么这些模型必须在单独的元素中。
为了用最少的消息和状态重复来表示复杂的行为,模型可以由其他模型组成,可能跨越多个元素。这些模型被称为扩展模型。纯自包含的模型称为根模型。
模型通过发布和订阅系统相互通信。每个模型都可以订阅一组组和虚拟地址,并且模型只处理发布到其订阅地址或包含元素的单播地址的消息。任何模型都可以维护发布消息的发布地址。这个发布地址可以是任何类型的。