nRF5 SDK for Mesh v5.0.0
Light switch example
You can test this example on the following devices: nRF52840, nRF52833, and nRF52832.
This example is only partially compatible with the nRF52840 dongle device.
This example is not compatible with the nRF52810 and nRF52820 devices.

This example demonstrates the Bluetooth mesh ecosystem that contains devices acting in the Node role (also referred to as provisionee role). It also demonstrates how to use Bluetooth mesh models by using the Generic OnOff model in an application.

Table of contents

The example is composed of the following minor examples:

You can use the provisioner example to evaluate the light switch example. The provisioner example provides a simple static provisioner implementation that sets up the demonstration network. The example provisions all the nodes in one Bluetooth mesh network. Additionally, it also configures key bindings and publication and subscription settings of the Bluetooth mesh model instances on these nodes to enable them to talk to each other.

Note
For provisioning purposes, you can also use the nRF Mesh mobile app.

The Generic OnOff Client/Server is used for manipulating the on/off state. Note that when the server has a publish address set (as in this example), the server will publish any operation of its state change to its publish address. More information about the Generic OnOff model can be found in the Generic OnOff model documentation and Generic OnOff server behavior documentation.

For a more detailed overview of the example structure and an introduction to various SDK APIs, see the following pages:

The following figure gives the overall view of the Bluetooth mesh network that will be set up by the static provisioner. Numbers in parentheses indicate the addresses that are assigned to these nodes by the provisioner.

mesh-nw-demo_r02.svg
Bluetooth mesh network demonstration

Both the light switch server and light switch client examples have provisionee role. They support provisioning over Advertising bearer (PB-ADV) and GATT bearer (PB-GATT) and also support Bluetooth mesh Proxy Service (Server). Read more about the Proxy feature in GATT provisioning and Proxy.

Note
The Proxy Client role is not supported.

Hardware requirements

You need at least two compatible development kits for this example:

Additionally, you need one of the following for provisioning:

See Compatibility for information about the compatible development kits.


Software requirements

Depending on the provisioning method:


Setup

You can find the source code of this example and its minor examples in the following folder: <InstallFolder>/examples/light_switch

LED and button assignments

The buttons (1 to 4) are used to initiate certain actions, and the LEDs (1 to 4) are used to reflect the status of actions as follows:

Scene model integration

Scene Setup Server model instance is used by default by the Light switch server example. You can exclude it by setting SCENE_SETUP_SERVER_INSTANCES_MAX to 0 (from the default value of 1) in examples/light_switch/server/include/nrf_mesh_config_app.h.

If you decide to exclude the Scene Setup Server model instance from Light switch server example, exclude it also from the Provisioner example if you want to evaluate using the static provisioner.


Testing the example

To test the light switch example, build the examples by following the instructions in Building the Bluetooth mesh stack.

After building is complete, use one of the following methods, depending on the preferred provisioning approach:

Once the provisioning is complete, you can start interacting with the boards.

Evaluating using the static provisioner

See provisioner example testing section for detailed steps required to provision and configure the boards using the static provisioner.

Evaluating using the nRF Mesh mobile app

See Evaluating examples using the nRF Mesh mobile application for detailed steps required to provision and configure the boards using the nRF Mesh mobile app.

When using the nRF Mesh app with this example, the following naming convention is used in the app:

The following model instances must be configured in the app for this example:

At the end of the configuration process, the client example will be configured as follows:

Note
You can also configure the publish address of the second Generic On Off client model instance. To do this, repeat step 3 from binding nodes and all steps from setting publication. If you set the model instance's address to the Unicast Address of any server node, the client example will be configured as follows:
  • The Button 3 on the client board turns ON LED 1 on the corresponding server board.
  • The Button 4 on the client board turns OFF LED 1 on the corresponding server board.

Interacting with the boards

Once the provisioning and the configuration of the client node and at least one of the server nodes are complete, you can press buttons on the client to see the LEDs getting toggled on the associated servers. See LED and button assignments section.

If an RTT terminal is available and connected to the client, sending the ASCII numbers 14 will have the same effect as pressing the buttons.

If you are using RTT log, you can also press Button 1 on the servers to locally toggle the state of their LED 1, and the status reflecting this state will be sent to the client board. You can see the status printed in the RTT log of the client board.

If any of the devices is powered off and back on, it will remember its flash configuration and rejoin the network. For more information about the flash manager, see Flash manager.


Documentation feedback | Developer Zone | Subscribe | Updated