The Zigbee light control example with touchlink commissioning is a variation of the Basic Zigbee Light Control example. In this example, the touchlink commissioning procedure is used to create and extend the Zigbee network.
It provides an example implementation of the following devices:
The light switch, working as a touchlink initiator, will generate random network credentials and request network creation on the first connected router (light bulb). Afterwards, it will only provide the network key and request the new device to try the rejoin procedure to join the network established by the first router. On every new device, the switch will read a simple descriptor of the router's endpoint, check if it implements Level Control and On Off clusters, and finally add it into the control group. During normal operation, pressing physical buttons will send messages to the group address, and every commissioned light bulb will respond to that command.
All devices indicate the Zigbee stack state using LEDs, as defined in Thread BSP LED reference. Additionally, BSP_LED_3 on the light bulb imitates dimmable light and BSP_LED_3 on the light switch node informs whether the touchlink commissioning process is in progress. The behavior of BSP_LED_2 on the light switch is also slightly modified, it will toggle on every successfully commissioned light bulb, so connecting the second bulb should turn it off.
Buttons are used only on the light switch node. Pressing BSP_BUTTON_1 after successful commissioning (BSP_LED_2 state) should turn off BSP_LED_3 on the light bulb node. Pressing BSP_BUTTON_0 will turn it back on. Using a long press adjusts the brightness level of the light bulb. BSP_BUTTON_1 decreases the brightness and BSP_BUTTON_0 increases the brightness.
In order to secure the communication between devices, the special network key exchange mechanism was introduced (see Zigbee Cluster Library Specification, section 13.3.4.10.5.2). This exchange uses a touchlink master key, that "is provided to a company as a result of a successful certification of a product" (Base Device Behavior Specification, section 6.3.4). As a result, examples provided with this SDK are not going to work with stock products without modifications (they use developer or certification key by default). In order to do that, the master key has to be specified during the initialization:
You can find the source code and the makefiles in the following folders:
<InstallFolder>\examples\zigbee\experimental\touchlink\target
<InstallFolder>\examples\zigbee\experimental\touchlink\initiator