This section outlines the steps to be taken when creating a new ZCL application. At least four modules should be
created for the new application:
- zcl_<appname>.h which should contain the definitions needed for the application
- zcl_<appname>_data.c which should contain the data definitions and declarations needed for the application
- zcl_<appname>.c which should contain all the functions and callback functions needed for the application
- OSAL_<AppName>.c where all the tasks needed for the application should be added to the task list
Each module is explained in detail in the following subsections.
——————————————
2.5.1 zcl_<appname>.h
This header file should contain all the definitions needed for the new application. The application’s endpoint should be defined in this module.
——————————————
2.5.2 zcl_<appname>_data.c
This module should contain the declaration of:
1. All the cluster attributes that are supported by the application
2. The attribute table containing one entry of zclAttrRec_t type for each supported attribute
3. The input and output cluster ID tables , where these tables are filled with the application-specific input and output cluster IDs respectively. These tables are used with the simple descriptor table
4. The application’s simple descriptor table of SimpleDescriptionFormat_t type defined in AF.h header file
——————————————
2.5.3 zcl_<appname>.c
This module should contain the following items:
1. The declaration of the application’s endpoint table of endPointDesc_t type defined in AF.h header file
2. Create all the command callback functions to handle any incoming command from the ZCL clusters. These callback functions are used with the command callback tables
3. The declaration of the application’s command callback tables for the ZCL functional domains. The type of this table for the General functional domain is zclGeneral_AppCallbacks_t , which is defined in zcl_general.h header file
4. Create void zcl<AppName>_Init( byte task_id ) function for the application task. This function’s responsibility is listed below
5. Create uint16 zcl<AppName>_event_loop( uint8 task_id, uint16 events ) function to receive and process messages and key events put on the application task’s queue
The application’s initialization function zcl<AppName>_Init() should register:
1. The command callback tables with the corresponding functional domains. The function zclGeneral_RegisterCmdCallbacks() defined in zcl_general.c module should be used to register the General cluster command callbacks
2. The application's attribute list with ZCL Foundation using zcl_registerAttrList() API which is defined in zcl.c module
3. The application’s endpoint with the AF layer using afRegister() API defined in AF.c module
4. The application’s task with the hardware to process all “press-key” events using RegisterForKeys() API defined in OnBoard.c module (if the application handles any key event)
5. The application’s simple descriptor with the HA profile using zclHA_Init() API defined in zcl_ha.c module
——————————————
2.5.4 OSAL_<AppName>.c
This module should contain void osalAddTasks( void ) function, where all the tasks needed for the application and the application task itself are added to the task list. The task addition is done using osalTaskAdd() API defined in OSAL_Tasks.c module. Here’s the minimum list of tasks and their addition order needed for a simple ZCL application:
1. HAL
2. MAC
3. Network
4. APS
5. ZD Application
6. ZCL
7. ZCL Application
Note : The ZCL task should be added first before any ZCL application task.