Bluetooth: Mesh sensor client¶
The Bluetooth Mesh sensor client sample demonstrates how to set up a basic Bluetooth Mesh sensor client model application that gets sensor data from one sensor server model. Four different sensor types are used to showcase different ways for the server to publish data. In addition, the samples demonstrate usage of both single-channel sensor types and sensor series types.
Note
This sample must be paired with Bluetooth: Mesh sensor server to show any functionality. A client has no sensor data and is dependent on a server to provide it.
Overview¶
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
.
The following Mesh sensor types are used in this sample:
bt_mesh_sensor_present_dev_op_temp
- Published by the server according to its publishing period.bt_mesh_sensor_rel_runtime_in_a_dev_op_temp_range
- Periodically requested by the client.bt_mesh_sensor_presence_detected
- Published when a button is pressed on the server board.bt_mesh_sensor_time_since_presence_detected
- Periodically requested by the client and published by the server according to its publishing period.
Provisioning¶
The provisioning is handled by the Bluetooth Mesh provisioning handler for Nordic DKs. Use nRF Mesh mobile app for provisioning and configuring of models supported by the sample.
Models¶
The following table shows the Mesh sensor client composition data for this sample:
Element 1
Config Server
Health Server
Sensor Client
The models are used for the following purposes:
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.Mesh sensor client gets sensor data from one or more Mesh sensor server(s).
The model handling is implemented in src/model_handler.c
.
A k_delayed_work
item is submitted recursively to periodically request sensor data.
Requirements¶
The sample supports the following development kits:
Hardware platforms |
PCA |
Board name |
Build target |
---|---|---|---|
PCA10040 |
|
||
PCA10056 |
|
The sample also requires a smartphone with Nordic Semiconductor’s nRF Mesh mobile app installed in one of the following versions:
Additionally, the sample requires the Bluetooth: Mesh sensor server sample application, programmed on a separate development kit and configured according to the Mesh sensor server sample’s testing guide.
User interface¶
- Buttons:
Can be used to input the OOB authentication value during provisioning. All buttons have the same functionality during the provisioning procedure.
- Terminal:
All sensor values gathered from the server are printed over UART. For more details, see Testing a sample application.
Building and running¶
This sample can be found under samples/bluetooth/mesh/sensor_client
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¶
Note
The Mesh sensor client sample cannot demonstrate any functionality on its own, and needs a device with the Bluetooth: Mesh sensor server sample running in the same mesh network. Before testing the Mesh sensor client, go through the Mesh sensor server’s testing guide with a different board.
After programming the sample to your board, you can test it by using a smartphone with Nordic Semiconductor’s nRF Mesh app installed. Testing consists of provisioning the device and configuring it for communication with the mesh models.
All sensor values gathered from the server are printed over UART. For more details, see Testing a sample application.
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 Sensor Client 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¶
Complete the following steps in the nRF Mesh app to configure models:
On the Network screen, tap the Mesh Sensor Client node. Basic information about the mesh node and its configuration is displayed.
In the Mesh node view, expand the element. It contains the list of models in the first and only element of the node.
Tap Sensor Client to see the model’s configuration.
Bind the model to application keys to make it open for communication:
Tap BIND KEY at the top of the screen.
Select Application Key 1 from the list.
Set the publishing parameters:
Tap SET PUBLICATION.
Tap Publish Address.
Select Groups from the drop-down menu.
Select an existing group or create a new one.
Note
The sensor server must subscribe to the same group.
Tap OK.
Set the Retransmit Count to zero (Disabled) to avoid duplicate logging in the UART terminal.
Tap the confirmation button at the bottom right corner of the app to save the parameters.
Set subscription parameters:
Tap SUBSCRIBE.
Select an existing group or create a new one.
Note
The sensor server must publish to the same group.
Tap OK.
Double-tap the back arrow button at the top left corner of the app to get back to the main application screen.
The sensor client model is now configured and able to receive data from the server.
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