Bluetooth: Mesh light¶
The Bluetooth mesh light sample demonstrates how to set up a mesh server model application, and control LEDs with Bluetooth mesh using the Generic OnOff models.
Note
This sample is self-contained, and can be tested on its own. However, it is required when testing the Bluetooth: Mesh light switch sample.
Requirements¶
The sample supports the following development kits:
Hardware platforms |
PCA |
Board name |
Build target |
---|---|---|---|
PCA10095 |
|
||
PCA10056 |
|
||
PCA10040 |
|
||
PCA10100 |
|
||
PCA10100 |
|
The sample also requires a smartphone with Nordic Semiconductor’s nRF Mesh mobile app installed in one of the following versions:
Overview¶
The mesh light sample is a Generic OnOff Server with a provisionee role in a mesh network. There can be one or more servers in the network, for example light bulbs.
The sample instantiates four instances of the Generic OnOff Server model for controlling LEDs.
Provisioning is performed using the nRF Mesh mobile app. This mobile application is also used to configure key bindings, and publication and subscription settings of the Bluetooth mesh model instances in the sample. After provisioning and configuring the mesh models supported by the sample in the nRF Mesh mobile app, you can control the LEDs on the development kit from the app.
Provisioning¶
The provisioning is handled by the Bluetooth mesh provisioning handler for Nordic DKs. It supports four types of out-of-band (OOB) authentication methods, and uses the Hardware Information driver to generate a deterministic UUID to uniquely represent the device.
Models¶
The following table shows the mesh light composition data for this sample:
Element 1 |
Element 2 |
Element 3 |
Element 4 |
---|---|---|---|
Config Server |
Gen. OnOff Server |
Gen. OnOff Server |
Gen. OnOff Server |
Health Server |
|||
Gen. OnOff Server |
The models are used for the following purposes:
Generic OnOff Server instances in elements 1 to 4 each control LEDs 1 to 4, respectively.
Config Server allows configurator devices to configure the node remotely.
Health Server provides
attention
callbacks that are used during provisioning to call your attention to the device. These callbacks trigger blinking of the LEDs.
The model handling is implemented in src/model_handler.c
, which uses the DK Button and LEDs library to control each LED on the development kit according to the matching received messages of Generic OnOff Server.
User interface¶
- Buttons:
Can be used to input the OOB authentication value during provisioning. All buttons have the same functionality during this procedure.
- LEDs:
Show the OOB authentication value during provisioning if the “Push button” OOB method is used. Show the OnOff state of the Generic OnOff Server of the corresponding element.
Configuration¶
See Configuring your application for information about how to permanently or temporarily change the configuration.
Source file setup¶
This sample is split into the following source files:
A
main.c
file to handle initialization.One additional file for handling mesh models,
model_handler.c
.
Building and running¶
This sample can be found under samples/bluetooth/mesh/light
in the nRF Connect SDK folder structure.
See Building and programming a sample application for information about how to build and program the application.
Testing¶
After programming the sample to your development kit, you can test it by using a smartphone with nRF Mesh mobile app installed. Testing consists of provisioning the device and configuring it for communication with the mesh models.
Provisioning the device¶
The provisioning assigns an address range to the device, and adds it to the mesh network. Complete the following steps in the nRF Mesh app:
Tap Add node to start scanning for unprovisioned mesh devices.
Select the Mesh Light device to connect to it.
Tap Identify, and then Provision, to provision the device.
When prompted, select an OOB method and follow the instructions in the app.
Once the provisioning is complete, the app returns to the Network screen.
Configuring models¶
See Configuring mesh models using the nRF Mesh mobile app for details on how to configure the mesh models with the nRF Mesh mobile app.
Configure the Generic OnOff Server model on each element on the Mesh Light node:
Bind the model to Application Key 1.
Once the model is bound to the application key, you can control the first LED on the device.
In the model view, tap ON (one of the Generic On Off Controls) to light up the first LED on the development kit.
Make sure to complete the configuration on each of the elements on the node to enable controlling each of the remaining three LEDs.
Dependencies¶
This sample uses the following nRF Connect SDK libraries:
In addition, it uses the following Zephyr libraries:
include/drivers/hwinfo.h
-
include/kernel.h
-
include/bluetooth/bluetooth.h
-
include/bluetooth/mesh.h