Light Control from the Remote

The control of the Light from the Remote happens in a client-server model. This is as per the Zigbee Cluster Library (ZCL) specification. The light holds the relevant data (attributes) and is the server. The Remote is the client and manipulates the attributes on the light through commands.

Example:Change in brightness level of the Light from the AVR477 Remote Control.

The Move to Level command is part of the Level Control Cluster. This command is sent from the remote to the light with the parameters: level and transition time. When the light receives this command, it should move to the new level over the specified transition time.

The above example is the over-the-air command exchange from the remote to the light. The light needs to convert the received level into a PWM value that will be provided to the LED driver to cause the LED to change brightness accordingly.The API flow to perform this is shown in Figure 1 .
Figure 1. API Usage Example

When the wireless command to move to level reaches the ATSAMR21 MCU, it is propagated to the application from the lower layers in the stack to the application. The moveToLevelInd() function (in lightLevelControlCluster.c) is an indication function to inform the application that a new moveToLevel command has been received.

This command is processed by the application and provided to the LED Driver via function APP_PWMMoveToLevel()(in lightPwm.c). This function scales the level value to the PWM duty cycle value and starts a timer to periodically move level. This is done so that the new level is achieved at the end of the provided transition time.