This example demonstrates the interaction between a mesh dimmable light and a dimmer. The mesh dimmer controls the brightness of the mesh dimmable light. The example consists of two minor examples:
Both these minor examples use the Generic Level Client/Server model.
For provisioning purposes, the example requires either the provisioner example that is provided in the Provisioner example or the nRF Mesh mobile app.
Table of contents
The dimming client has a provisionee role in the network. The client accepts RTT inputs from 1
to 7
to control the state of LED 1 on the servers. It instantiates two instances of the Generic Level Client model. It can either be provisioned and configured by the provisioner device or by a GATT-based provisioner. The provisioner configures this client model instances to communicate with the servers.
The dimming server has a provisionee role in the network. It instantiates one instance of the Generic Level Server model to control the state of LED 1. It uses the APP_PWM library of the nRF5 SDK to control the brightness of the LED. It can either be provisioned and configured by the provisioner device or by a GATT-based provisioner. The provisioner configures this server model instance to communicate with the client model on the client board and to publish a message when the value of the Level state changes.
The examples are based on the Generic Level model, which works with signed 16-bit level values. Therefore, the dimming server maps this range on the allowed range of PWM tick values. As a consequence, sending a level model message that sets the target level to 0x0000 results in a 50% duty cycle on the PWM output when the target level is reached.
The Generic Level Client model is used for manipulating the Level state associated with peer Generic Level Server model. Note that when the server has a publish address set (as in this example), the server publishes information about the state changes to its publish address once the final state is reached.
More information about the Generic Level model can be found in the Generic Level model documentation and the Generic Level server behaviour documentation.
You need at least two supported development kits for this example:
Additionally, you need one of the following:
See Compatibility for information about the supported development kits.
If you decide to use the static provisioner example, you need the provisioner example: <InstallFolder>/examples/provisioner
See the provisioner details page for more information about the provisioner example.
You can find the source code of this example in the following folder: <InstallFolder>/examples/dimming
RTT inputs | DK Buttons | Effect |
---|---|---|
1 | Button 1 | The internal target level variable value is decreased in large steps and Generic Level Set message is sent. |
2 | Button 2 | The internal target level variable value is increased in large steps and Generic Level Set message is sent. |
3 | Button 3 | The internal target delta level variable value is decreased in large steps and Generic Level Delta Set message is sent. |
4 | Button 4 | The internal target delta level variable value is increased in large steps and Generic Level Delta Set message is sent. |
5 | - | The internal target move level variable value is decreased in large steps and Generic Level Move Set message is sent. |
6 | - | The internal target move level variable value is increased in large steps and Generic Level Move Set message is sent. |
7 | - | The client switches between Odd or Even group nodes. |
simple_hal
module.RTT inputs | DK Buttons | Effect |
---|---|---|
1 | - | The brightness of the LED 1 decresses in large steps. |
2 | - | The brightness of the LED 1 increases in large steps. |
4 | - | Clear all the states to reset the node. |
To test the dimming example, build the examples by following the instructions in Building the mesh stack.
MAX_PROVISIONEE_NUMBER
(in example_network_config.h
) to the number of boards available and rebuild the provisioner example.After building is complete, use one of the following methods, depending on the preferred provisioning approach:
If the provisioner encounters an error during the provisioning or configuration process for one of the nodes, you can reset the provisioner to restart the process for that node.
See the information on the main Examples page 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:
nRF5x Mesh Dimmable Light
.nRF5x Mesh Dimmer
.The following model instances must be configured in the app for this example:
nRF5x Mesh Dimmable Light
server board: Generic Level Server.nRF5x Mesh Dimmer
client board: Generic Level Client.When provisioning and configuration of the client node and at least one of the server nodes are complete, you can send command numbers using the RTT viewer and see the dimming action on the LED 1 on each of the server boards.
To evaluate this interaction, connect the RTT viewer to the dimming client.
There are three message types available for this demonstration:
Dimming client interaction
The RTT input is used to emulate the button numbers 1
to 7
to send level messages. You can send numbers from 1
to 7
via the RTT viewer and observe the changes in the brightness of the LED 1 on the corresponding server boards.
See the LED and button assignments for the list of available commands.
Dimming-server interaction
See the LED and button assignments for the list of available commands.
If you send the commands to the server board, observe the corresponding status printed in the RTT log of the client board.
If any of the devices are powered off and back on, they remember their configuration in flash and rejoin the network. For more information about the flash manager, see Flash manager.