This demo project consists of two examples: the dimming server and the dimming client. In addition, it requires the provisioner example that is provided as part of the light_switch
examples.
SERVER_NODE_COUNT
(in light_switch_example_common.h
) to the number of boards available and rebuild the provisioner example.See the compatiblity section for information about the supported boards.
Note: This example uses the PWM peripheral for dimming. Therefore, it cannot be run on nRF51 devices.
To build the examples, follow the instructions in Building the Mesh Stack. Refer to the How to run examples section in Examples README for the commands required to program a device using nrfjprog
.
The provisioner prints details about the provisioning and the configuration process in the RTT log. While the provisioner is scanning and provisioning a device, LED 1 on the provisioner board is turned ON. During configuration, LED 2 on the provisioner board is turned ON.
The provisioner configures the two client model instances on the client board to communicate with the Odd and Even server groups.
Connect the RTT viewer to the dimming client to control the dimming level. Three message types are demonstrated: Set, Delta Set, and Move Set. The RTT input is used to emulate the button numbers 0
to 6
, so to send level messages, you send numbers from 0
to 6
via the RTT viewer.
The client example is configured as follows:
1
/3
/5
increase the internal target level value parameters in large steps.0
/2
/4
decrease the internal target level value parameters in large steps.0
and 1
cause the client to send a Generic Level Set message.2
and 3
cause the client to send a Generic Level Delta Set message.4
and 5
cause the client to send a Generic Level Move Set message.6
cause the client to switch between Odd or Even group nodes.Note: If you use the buttons on the DK instead of RTT input, you can only send Set and Delta Set messages. You cannot send Move message or switch between Odd or Even groups.
When provisioning and configuration of the client node and at least one of the server nodes is completed, you can send numbers using the RTT viewer and see the dimming action on LED 1 of the server boards.
You can also connect the RTT viewer to one of the servers and send 0
or 1
to locally increase or decrease the brightness of their LED 1 in steps. Observe the corresponding status printed in the RTT log of the client board.
Note: You cannot use buttons on the server boards since dimming server does not use
simple_hal
module.
If any of the devices are powered off and back on, they remember their configuration in flash and rejoin the network. More information about the flash manager can be found in the flash manager documentation.
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.
Instead of using a provisioner board, you can also use the nRF Mesh app:
nRF Mesh
app for your mobile phone (iOS or Android) and provision the nodes.The demonstration consists of two example applications that use the Generic Level Client/Server model.
The dimming client has a provisionee role in the network. The client accepts RTT inputs from 0
to 6
to control the state of LED 1 on the servers. It instantiates two instances of the Generic Level Client model. 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. 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 zero results in a 50% duty cycle on the PWM output when the target level is reached.
The Generic Level Client/Server is used for manipulating the Level state. Note that when the server has a publish address set (as in this example), the server publishes information about any state changes to its publish address.
More information about the Generic Level model can be found in the Generic Level model documentation and the Generic Level server behaviour documentation.