.. _bluetooth_mesh_sensor_client: Bluetooth: Mesh sensor observer ############################### .. contents:: :local: :depth: 2 The Bluetooth® mesh sensor observer sample demonstrates how to set up a basic Bluetooth mesh :ref:`bt_mesh_sensor_cli_readme` model application that gets sensor data from one :ref:`bt_mesh_sensor_srv_readme` 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 :ref:`single-channel sensor types and sensor series types `, as well as how to add and write to a sensor setting. .. note:: This sample must be paired with :ref:`bluetooth_mesh_sensor_server` to show any functionality. The observer has no sensor data, and is dependent on a mesh sensor to provide it. Requirements ************ The sample supports the following development kits: .. table-from-sample-yaml:: The sample also requires a smartphone with Nordic Semiconductor's nRF Mesh mobile app installed in one of the following versions: * `nRF Mesh mobile app for Android`_ * `nRF Mesh mobile app for iOS`_ Additionally, the sample requires the :ref:`bluetooth_mesh_sensor_server` sample application, programmed on a separate development kit and configured according to mesh sensor sample's :ref:`testing guide `. Overview ******** The following Bluetooth mesh sensor types are used in this sample: * :c:var:`bt_mesh_sensor_present_dev_op_temp` - Published by the server according to its publishing period. * :c:var:`bt_mesh_sensor_dev_op_temp_range_spec` - Used as a setting for the :c:var:`bt_mesh_sensor_present_dev_op_temp` sensor type to set the range of reported temperatures. * :c:var:`bt_mesh_sensor_rel_runtime_in_a_dev_op_temp_range` - Periodically requested by the client. * :c:var:`bt_mesh_sensor_presence_detected` - Published when a button is pressed on the server. * :c:var:`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 :ref:`bt_mesh_dk_prov`. 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. Use `nRF Mesh mobile app`_ for provisioning and configuring of models supported by the sample. Models ====== The following table shows the mesh sensor observer 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. * Sensor Client gets sensor data from one or more :ref:`Sensor Server(s) `. The model handling is implemented in :file:`src/model_handler.c`. A :c:struct:`k_work_delayable` item is submitted recursively to periodically request sensor data. User interface ************** Buttons: Can be used to input the OOB authentication value during provisioning. All buttons have the same functionality during the provisioning procedure. Once the provisioning procedure has completed, the buttons will have the following functionality: Button 1: Sends a get message for a setting. Button 2: Sends a set message for a setting, switching between the ranges specified in the :c:var:`temp_ranges` variable. Button 3: Sends a get message for a descriptor, requesting information about the :c:var:`bt_mesh_sensor_present_dev_op_temp` sensor. Terminal: All sensor values gathered from the server are printed over UART. For more details, see :ref:`gs_testing`. Configuration ************* |config| Source file setup ================= This sample is split into the following source files: * A :file:`main.c` file to handle initialization. * One additional file for handling Bluetooth mesh models, :file:`model_handler.c`. FEM support =========== .. include:: /includes/sample_fem_support.txt Building and running ******************** .. |sample path| replace:: :file:`samples/bluetooth/mesh/sensor_client` .. include:: /includes/build_and_run.txt .. _bluetooth_mesh_sensor_client_testing: Testing ======= .. note:: The mesh sensor observer sample cannot demonstrate any functionality on its own, and needs a device with the :ref:`bluetooth_mesh_sensor_server` sample running in the same mesh network. Before testing the mesh sensor observer, go through the mesh sensor's :ref:`testing guide ` with a different development kit. 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. All sensor values gathered from the server are printed over UART. For more details, see :ref:`gs_testing`. Provisioning the device ----------------------- .. |device name| replace:: :guilabel:`Mesh Sensor Observer` .. include:: /includes/mesh_device_provisioning.txt Configuring models ------------------ See :ref:`ug_bt_mesh_model_config_app` for details on how to configure the mesh models with the nRF Mesh mobile app. Configure the Sensor Client model on the **Mesh Sensor Observer** node: * Bind the model to **Application Key 1**. * Set the publication parameters: * Destination/publish address: Select an existing group or create a new one, but make sure that the Sensor Server subscribes to the same group. * Retransmit count: Set the count to zero (**Disabled**), to avoid duplicate logging in the UART terminal. * Set the subscription parameters: Select an existing group or create a new one, but make sure that the Sensor Server publishes to the same group. The Sensor Client model is now configured and able to receive data from the Sensor Server. Dependencies ************ This sample uses the following |NCS| libraries: * :ref:`bt_mesh_sensor_cli_readme` * :ref:`bt_mesh_dk_prov` * :ref:`dk_buttons_and_leds_readme` In addition, it uses the following Zephyr libraries: * ``include/drivers/hwinfo.h`` * :ref:`zephyr:kernel_api`: * ``include/kernel.h`` * :ref:`zephyr:bluetooth_api`: * ``include/bluetooth/bluetooth.h`` * :ref:`zephyr:bluetooth_mesh`: * ``include/bluetooth/mesh.h``