Configuring Bluetooth Mesh in nRF Connect SDK
The Bluetooth® mesh support is controlled by
CONFIG_BT_MESH, which depends on the following configuration options:
CONFIG_BT- Enables the Bluetooth subsystem.
CONFIG_BT_OBSERVER- Enables the Bluetooth Observer role.
CONFIG_BT_PERIPHERAL- Enables the Bluetooth Peripheral role.
Optional features in the Bluetooth Mesh stack must be explicitly enabled:
CONFIG_BT_MESH_RELAY- Enables message relaying.
CONFIG_BT_MESH_FRIEND- Enables the Friend role.
CONFIG_BT_MESH_LOW_POWER- Enables the Low Power role.
CONFIG_BT_MESH_PROVISIONER- Enables the Provisioner role.
CONFIG_BT_MESH_GATT_PROXY- Enables the GATT Proxy Server role.
CONFIG_BT_MESH_PB_GATT- Enables the GATT provisioning bearer.
CONFIG_BT_MESH_CDB- Enables the Configuration Database subsystem.
The nRF Connect SDK Bluetooth Mesh model implementations are optional features, and each model has individual Kconfig options that must be explicitly enabled. See Bluetooth Mesh models for details.
The following configuration options are used to configure the behavior and performance of a Bluetooth Mesh network. For more information about configuration options affecting the memory footprint of Bluetooth Mesh, see memory footprint optimization guide for Bluetooth Mesh.
CONFIG_BT_MESH_PROXY_USE_DEVICE_NAME- Includes the GAP device name in a scan response when the GATT Proxy feature is enabled.
CONFIG_BT_MESH_DK_PROV- Enables the Bluetooth Mesh provisioning handler for the nRF5x development kits.
CONFIG_BT_MESH_ADV_BUF_COUNT- Defines the number of advertising buffers for local messages. Increase to improve the performance, at the cost of increased RAM usage.
CONFIG_BT_MESH_ADV_EXT_GATT_SEPARATE- Enables the use of a separate extended advertising set for GATT Server Advertising.
CONFIG_BT_MESH_ADV_EXT_FRIEND_SEPARATE- Enables the use of a separate extended advertising set for Friend advertising.
CONFIG_BT_MESH_RELAY_ADV_SETS- Defines a maximum number of simultaneous relay messages.
CONFIG_BT_MESH_ADV_EXT_RELAY_USING_MAIN_ADV_SET- Sets the main advertising set to relay messages.
This section lists additional configuration options that can be used to configure behavior and performance of Bluetooth Mesh. The provided values are meant as suggestions only, and should be individually adjusted for each application.
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE- Sets the system workqueue stack size. Use the option to increase the system workqueue stack size if the default system workqueue stack size is low.
CONFIG_MAIN_STACK_SIZE- Sets the initialization and main thread stack size. Use the option to increase the stack size of the default initialization and main thread if necessary.
CONFIG_HWINFO- Enables the hardware information driver. The hardware information driver must be enabled to perform provisioning of the device. See the UUID section of Bluetooth Mesh provisioning handler for Nordic DKs.
CONFIG_PM_PARTITION_SIZE_SETTINGS_STORAGE- Sets the size of the partition used for settings storage. Use the option to increase the size if necessary.
CONFIG_SOC_FLASH_NRF_PARTIAL_ERASE- Enables partial erase on supported hardware platforms. Partial erase allows the flash page erase operation to be split into several small chunks preventing longer CPU stalls. This improves responsiveness of a mesh node during the defragmentation of storage areas used by the settings subsystem.
CONFIG_NCS_SAMPLES_DEFAULTS- Enables the Zephyr system logger with minimal logging implementation. This is enabled by default for all samples in nRF Connect SDK. For more information, see Zephyr system logger.
CONFIG_LOG_MODE_DEFERRED- Enables deferred logging. Setting this configuration option is recommended to avoid slowing down the processing of mesh messages. It improves the LPN power consumption when the friendship is established.
CONFIG_LOG_BUFFER_SIZE- Sets the number of bytes dedicated for the logger internal buffer. Increase the number to avoid missing logs in case of a complex protocol or functionality issue.
CONFIG_LOG_PROCESS_THREAD_SLEEP_MS- Sets the sleep period for the internal log processing thread. Decrease the value to flush logs more quickly.
GATT Proxy performance
These options are only compatible with devices supporting Bluetooth Low Energy (LE) v4.2 or higher.
The following configuration options allow fitting the full relayed mesh advertiser frame into a single Link Layer payload:
The following option allows sending up to several data frames during the single connection interval:
The following configuration options are used to configure the Bluetooth Low Energy behavior and performance:
CONFIG_BT_COMPANY_ID- Sets the Bluetooth Company Identifier for this device.
CONFIG_BT_DEVICE_NAME- Defines the Bluetooth device name.
CONFIG_BT_L2CAP_TX_BUF_COUNT- Sets the number of buffers available for outgoing L2CAP packets.
CONFIG_BT_RX_STACK_SIZE- Sets the size of the receiving thread stack.
CONFIG_BT_EXT_ADV_MAX_ADV_SET- Sets the maximum number of simultaneous advertising sets.
CONFIG_BT_BUF_ACL_RX_SIZE- Sets the data size needed for HCI ACL RX buffers.
Disabled and unused Bluetooth features
The following feature options are by default disabled in the samples, but it needs to be considered if any of them are required by the application and thus should be enabled:
Emergency data storage (EMDS)
The following configuration options should be considered in case of large networks with high demands on storing the replay protection list (RPL) data. This will require additional hardware. For more information, see Emergency data storage.
CONFIG_EMDS- Enables the emergency data storage.
CONFIG_BT_MESH_RPL_STORAGE_MODE_EMDS- Enables the persistent storage of RPL in EMDS.
CONFIG_PM_PARTITION_SIZE_EMDS_STORAGE=0x4000 - Defines the partition size for the Partition Manager.
CONFIG_EMDS_SECTOR_COUNT=4 - Defines the sector count of the emergency data storage area.
Low Power node (LPN)
The Low Power node (LPN) is a power optimization feature specific to Bluetooth Mesh.
The following configuration options are relevant when using the LPN feature:
Serial communication consumes considerable power, and disabling it should be considered.
While enabled, secure beacons will be advertised periodically. This consumes power, and is not required for a Low Power node.
Each LPN poll event consumes power. Extending the interval between the poll events will improve the power consumption.
While the GATT Proxy feature is enabled, the Network ID is periodically advertised. Disabling it will conserve the energy.
Reducing the Node ID advertisement timeout decreases the period where the device consumes power for advertising.
Zephyr’s Mesh implementation has been designed to use the settings subsystem to store internal states and options in the persistent storage. The settings subsystem can be used with different backends. Bluetooth Mesh is configured with the non-volatile storage (NVS) as the settings backend.
Using the settings subsystem based on NVS can in some cases result in a significant store time increase. In a worst case scenario, the store time can be up to several minutes. This can for example happen when storing a large size replay protection list. It is recommended to configure the settings subsystem’s internal caches to improve the performance.
The Settings NVS name cache reduces the number of search loops of internal parameter identifiers, keeping them in memory.
The size of the Settings NVS name cache is recommended to be set to the maximum number of devices the configured device communicates with. For example, if a device communicates with 255 other devices, it is worth setting the cache to minimum 255.
NVS lookup cache reduces the number of search loops within NVS’ application table.