Important: Before you run this example, make sure to program the SoftDevice.
This dynamic multiprotocol example application is based on the Color Dimmer Switch, a Zigbee Home Automation device. This device can turn on and off several compatible light bulbs, dim them, and change their color. With this example, the device supports dynamic switching between two protocols, BLE and Zigbee, at the same time (concurrently). Furthermore, this example makes use of Finding & Binding feature, which allows the device to discover its peers on the network.
This example uses at least three devices:
The light switch device operates through pressing buttons on the DK on the Zigbee network, and through the Nordic UART Service on the BLE network. Both networks are independent from each other. Three different Zigbee Endpoints are instantiated on the light switch (with numbers 1, 2, and 3), with the possibility to trigger Finding & Binding process on each of them.
To support both protocols at the same time, the Zigbee stack uses the 802.15.4 radio during the inactive time of the Bluetooth Low Energy radio (using Timeslot API). Depending on the Bluetooth Low Energy connection interval, the nRF52840 SoC can spend up to 99% of the radio time on the Zigbee protocol. This is the same mechanism as the one used in Dynamic multiprotocol examples in Thread.
For more information on multiprotocol operation, refer to the Multiprotocol support with BLE/Bluetooth support section.
You can find the source code in the following folder: <InstallFolder>\examples\multiprotocol\ble_zigbee\ble_zigbee_dynamic_light_switch_nus
To show the basic behaviour of the device, you need two other examples that contain a Zigbee coordinator and a Zigbee light bulb. With these two examples, you can control the light bulb (On/Off and Level Control clusters). You can find these examples in Zigbee Light Control example.
You can control the devices either with the buttons on the development kits or the NUS UART commands in the nRF Toolbox application. The NUS UART commands offer more options than the DK buttons.
- @b BSP_LED_0: Shows BLE connection state: - Blinking -- BLE advertising. - Continuously on -- Connected over BLE. - @b BSP_LED_1: Shows Finding & Binding process state: - On -- In progress. - Off -- Not in progress. - @b BSP_LED_2 -- Turns on when the device joins the Zigbee network. - @b BSP_LED_3: - Blinking -- Signalizes the Zigbee Endpoint that is currently selected (number of flashes equals the Endpoint number).
Command | Effect |
---|---|
n | Turns on the Zigbee light bulb. |
f | Turns off the Zigbee light bulb. |
t | Toggles the Zigbee light bulb on or off. |
i | Increases the brightness level of the Zigbee light bulb. |
d | Decreases the brightness level of the Zigbee light bulb. |
sn | Selects the next Endpoint. |
sp | Selects the previous Endpoint. |
& | Starts or stops the Finding & Binding procedure on the currently selected Endpoint. |
h[vH]s[vS] | Moves the Color Bulb to the desired value of Hue and Saturation, [vH] and [vS] respectively, indicated by decimal values (from 0 to 255).Example: h25s150 . |
[v] | [v] corresponds to a numeric value between 0 and 999. The command toggles the Zigbee light bulb after [v] seconds.Example: 33 . |
For this example, prepare:
To evaluate the example, first configure the boards:
You can toggle the LED on the light bulb board bound to the currently selected endpoint in the network by pressing BSP_BUTTON_0 and BSP_BUTTON_1 on the light switch board.
After configuration, you can also start interacting with the boards using the nRF Toolbox application:
n
f
t
i
d
sn
sp
&
h12s34
n
and f
commands: Press the corresponding buttons to turn the LED on the Zigbee light bulb node on and off, respectively.t
command: Press the corresponding button two times to toggle the LED on the Zigbee light bulb node on and off.ssn
and sp
commands: Move through the endpoints with the corresponding buttons.&
command: Press the corresponding button to initiate the Finding & Binding procedure.h12s34
to move to the predefined Hue and Saturation value.i
and d
commands: Press the corresponding buttons to adjust the brightness level.Testing the [v] command
To test the delayed toggle command ([v]
command in the BLE UART command assignments table), add another button with the numeric command or create a separate configuration (screen).
For example, you can add buttons to toggle the light bulb after 1 (1
command), 3 (3
command), and 9 (9
command) seconds.