docs/en/api-guides/esp-ble-mesh/ble-mesh-architecture.rst
:link_to_translation:zh_CN:[中文]
This document introduces ESP-BLE-MESH architecture overview, ESP-BLE-MESH architecture implementation as well as ESP-BLE-MESH auxiliary routines.
ESP-BLE-MESH Architecture Overview
ESP-BLE-MESH Architecture Implementation
ESP-BLE-MESH Auxiliary Routines
Currently ESP-BLE-MESH has implemented most functions of Mesh Profile and all the Client Models defined in Mesh Model specification. Those missing functions/models are under development and will be provided soon. ESP-BLE-MESH architecture has been granted the official Bluetooth certification <https://launchstudio.bluetooth.com/ListingDetails/76255>__.
.. figure:: ../../../_static/esp-ble-mesh-architecture.png :align: center
Figure 1.1 ESP-BLE-MESH Architecture Diagram
ESP-BLE-MESH architecture includes five key parts:
Mesh Protocol Stack
Mesh Networking is responsible for processing of messages of ESP-BLE-MESH nodes.Mesh Provisioning is responsible for provisioning flow of ESP-BLE-MESH devices.Mesh Models is responsible for the implementation of SIG-defined models.Network Management
Features
Mesh Bearer Layer
Advertising Bearer and GATT Bearer. The bearer layer is crucial to ESP-BLE-MESH protocol stack which is built on Bluetooth Low-Energy technology, because the protocol stack must make use of the bearer layer to transmit data via the BLE advertising channel and connection channel.Applications
Mesh Models.Applications interact with Mesh Networking and Mesh Provisioning in ESP-BLE-MESH protocol stack, as well as a series of Models provided by Mesh Models.1.1.1 Mesh Networking ^^^^^^^^^^^^^^^^^^^^^
Mesh Networking in the protocol stack architecture implements the following functions:
ble-mesh-feature-list.The implementation of Mesh Networking functions is based on hierarchy structure. Functions of each layer are shown in Table 1.1:
.. list-table:: Table 1.1 Mesh Networking Architecture Description :widths: 40 150 :header-rows: 1
1.1.2 Mesh Provisioning ^^^^^^^^^^^^^^^^^^^^^^^
Mesh Provisioning in the protocol stack architecture implements the following functions:
ble-mesh-feature-list.The implementation of Mesh Provisioning functions is based on hierarchy structure. Functions of each layer are shown in Table 1.2:
.. list-table:: Table 1.2 Mesh Provisioning Architecture Description :widths: 40 150 :header-rows: 1
1.1.3 Mesh Models ^^^^^^^^^^^^^^^^^
Mesh Models in the protocol stack architecture implements the following functions:
Functions of each layer are shown in Table 1.3:
.. list-table:: Table 1.3 Mesh Models Architecture Description :widths: 40 150 :header-rows: 1
Network Management implements the following functions:
Features includes the following options:
Bearers in the protocol stack architecture are responsible for passing of data between ESP-BLE-MESH protocol stack and Bluetooth Low Energy Core.
Bearers can be taken as a carrier layer based on Bluetooth Low Energy Core, which implements the function of receiving and transmitting data for the ESP-BLE-MESH protocol stack.
.. list-table:: Table 1.3 Mesh Bearers Description :widths: 40 150 :header-rows: 1
Proxy PDUs between two devices over a GATT connection.Bluetooth Low Energy advertising PDU using the Mesh Message AD Type.The Applications in the protocol stack architecture implement the corresponding functions by calling the API provided by the ESP-BLE-MESH protocol stack and processing the Event reported by the protocol stack. There are some common applications, such as gateway, lighting and etc.
Interaction between application layer (Applications) and API/Event
Application layer calls API
Application layer processes Event
The application layer is designed based on events, which take parameters to the application layer. Events are mainly divided into two categories.
The event is reported by the callback function registered by the application layer, and the callback function also contains the corresponding processing of the event.
Interaction between API / Event and ESP-BLE-MESH protocol stack
API used by user mainly calls functions provided by Mesh Networking, Mesh Provisioning and Mesh Models.
The interaction between API / Event and the protocol stack does not operate across the hierarchy of the protocol stack. For example, API does not call functions related to Network Layer.
The design and implementation of ESP-BLE-MESH architecture is based on layers and modules. In details, Section 2.1 (Mesh Networking Implementation), Section 2.2 (Mesh Provisioning Implementation) and Section 2.3 (Mesh Bearers Implementation) are based on layers, and Section 2.4 (Mesh Models Implementation) is on modules.
Layer-based Approach: With Layer-based approach, the architecture is designed according to the layers specified in the Mesh Profile Specification. Each layer has its unique files which include APIs of this layer and etc. The specific design is shown in Figure 2.1.
Module-based Approach: Every file implements an independent function that can be called by other programs.
.. figure:: ../../../_static/esp-ble-mesh-interface.png :align: center
Figure 2.1 ESP-BLE-MESH Architecture Implementation Diagram
The design of ESP-BLE-MESH architecture uses layer-based approach. The sequence of layers which data packets are processed through is fixed, i.e., the processing of packets will form a message flow. Thus, we could see flows of messages from the Protocol Stack Interface Diagram in Figure 2.1.
2.1.1 Mesh Networking Implementation ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The list of files and the functions implemented in each file in Mesh Networking are shown in Table 2.1:
.. list-table:: Table 2.1 Mesh Networking File Description :widths: 40 150 :header-rows: 1
access.c <bt/esp_ble_mesh/core/access.c>transport.c <bt/esp_ble_mesh/core/transport.c>net.c <bt/esp_ble_mesh/core/net.c>adv.c <bt/esp_ble_mesh/core/adv.c>2.1.2 Mesh Provisioning Implementation ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The implementation of Mesh Provisioning is divided into two chunks due to the Node/Provisioner coexistence.
Specific files that provide implementation of provisioning of Node are shown in Table 2.2:
.. list-table:: Table 2.2 Mesh Provisioning (Node) File Description :widths: 40 150 :header-rows: 1
prov_node.c <bt/esp_ble_mesh/core/prov_node.c>proxy_server.c <bt/esp_ble_mesh/core/proxy_server.c>beacon.c <bt/esp_ble_mesh/core/beacon.c>Specific files that implement functions of Provisioner are shown in Table 2.3:
.. list-table:: Table 2.3 Mesh Provisioning (Provisioner) File Description :widths: 40 150 :header-rows: 1
prov_pvnr.c <bt/esp_ble_mesh/core/prov_pvnr.c>proxy_client.c <bt/esp_ble_mesh/core/proxy_client.c>pvnr_mgmt.c <bt/esp_ble_mesh/core/pvnr_mgmt.c>2.1.3 Mesh Models Implementation ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Mesh Models are used to implement the specific functions of model in nodes. Server model is used to maintain node status. Client model is used to obtain and modify node state.
.. list-table:: Table 2.4 Mesh Models File Description :widths: 40 150 :header-rows: 1
cfg_cli.c <bt/esp_ble_mesh/core/cfg_cli.c>cfg_srv.c <bt/esp_ble_mesh/core/cfg_srv.c>health_cli.c <bt/esp_ble_mesh/core/health_cli.c>health_srv.c <bt/esp_ble_mesh/core/health_srv.c>client_common.c <bt/esp_ble_mesh/models/client/client_common.c>generic_client.c <bt/esp_ble_mesh/models/client/generic_client.c>lighting_client.c <bt/esp_ble_mesh/models/client/lighting_client.c>sensor_client.c <bt/esp_ble_mesh/models/client/sensor_client.c>time_scene_client.c <bt/esp_ble_mesh/models/client/time_scene_client.c>generic_server.c <bt/esp_ble_mesh/models/server/generic_server.c>lighting_server.c <bt/esp_ble_mesh/models/server/lighting_server.c>sensor_server.c <bt/esp_ble_mesh/models/server/sensor_server.c>time_scene_server.c <bt/esp_ble_mesh/models/server/time_scene_server.c>2.2 Mesh Bearers Implementation ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Portability is fully considered in the implementation of Mesh Bearers. When the ESP-BLE-MESH protocol stack is being ported to other platforms, users only need to modify :component_file:adapter.c <bt/esp_ble_mesh/core/bluedroid_host/adapter.c> (example of :component_file:NimBLE version <bt/esp_ble_mesh/core/nimble_host/adapter.c>).
.. list-table:: Table 2.5 Mesh Bearers File Description :widths: 40 150 :header-rows: 1
adapter.c <bt/esp_ble_mesh/core/bluedroid_host/adapter.c>.. note::
:component_file:adapter.c <bt/esp_ble_mesh/core/bluedroid_host/adapter.c> is the implementation of Advertising Bearer and GATT Bearer in Mesh Networking framework.
2.3 Mesh Applications Implementation ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
We have provided a series of application examples for customer development, and users can develop products based on :ref:esp-ble-mesh-examples.
Auxiliary routine refers to optional functions in the ESP-BLE-MESH protocol stack. The design of the auxiliary routine generally implement the truncation of code through :ref:CONFIG_BLE_MESH.
3.1 Features ^^^^^^^^^^^^
3.2 Network Management ^^^^^^^^^^^^^^^^^^^^^^
3.3 Auxiliary Routine Implementation ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
When adopting the design of independent module, the two main factors should be considered:
.. list-table:: Table 3.1 Module File Description :widths: 40 150 :header-rows: 1
lpn.c <bt/esp_ble_mesh/core/lpn.c>friend.c <bt/esp_ble_mesh/core/friend.c>net.c <bt/esp_ble_mesh/core/net.c>proxy_server.c <bt/esp_ble_mesh/core/proxy_server.c>proxy_client.c <bt/esp_ble_mesh/core/proxy_client.c>settings.c <bt/esp_ble_mesh/core/storage/settings.c>main.c <bt/esp_ble_mesh/core/main.c>