Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * window_covering.c
- *
- * Created on: Jun 1, 2019
- * Author: TrungTQ9
- */
- #include <jendefs.h>
- #include <string.h>
- #include "zps_apl.h"
- #include "zcl_heap.h"
- #include "zcl.h"
- #include "zcl_options.h"
- #include "Basic.h"
- #include "Identify.h"
- #include "Groups.h"
- #include "WindowCovering.h"
- #include "window_covering.h"
- #ifdef CLD_OTA
- #include "OTA.h"
- #endif
- /****************************************************************************/
- /*** Macro Definitions ***/
- /****************************************************************************/
- /****************************************************************************/
- /*** Type Definitions ***/
- /****************************************************************************/
- /****************************************************************************/
- /*** Local Function Prototypes ***/
- /****************************************************************************/
- /****************************************************************************/
- /*** Exported Variables ***/
- /****************************************************************************/
- /****************************************************************************/
- /*** Local Variables ***/
- /****************************************************************************/
- /****************************************************************************/
- /*** Exported Functions ***/
- /****************************************************************************/
- PUBLIC teZCL_Status eHA_RegisterWindowCoveringEndPoint(
- uint8 u8EndPointIdentifier,
- tfpZCL_ZCLCallBackFunction cbCallBack,
- tsHA_WindowCoveringDevice *psDeviceInfo
- ) {
- /* Fill in end point details */
- psDeviceInfo->sEndPoint.u8EndPointNumber = u8EndPointIdentifier;
- psDeviceInfo->sEndPoint.u16ManufacturerCode = ZCL_MANUFACTURER_CODE;
- psDeviceInfo->sEndPoint.u16ProfileEnum = HA_PROFILE_ID;
- psDeviceInfo->sEndPoint.bIsManufacturerSpecificProfile = FALSE;
- psDeviceInfo->sEndPoint.u16NumberOfClusters = sizeof(tsHA_WindowCoveringDeviceClusterInstances) / sizeof(tsZCL_ClusterInstance);
- psDeviceInfo->sEndPoint.psClusterInstance = (tsZCL_ClusterInstance*)&psDeviceInfo->sClusterInstance;
- psDeviceInfo->sEndPoint.pCallBackFunctions = cbCallBack;
- /* Mandatory server clusters */
- #if (defined CLD_BASIC) && (defined BASIC_SERVER)
- /* Create an instance of a Basic cluster as a server */
- if (eCLD_BasicCreateBasic(
- &psDeviceInfo->sClusterInstance.sBasicServer,
- TRUE,
- &sCLD_Basic,
- &psDeviceInfo->sBasicServerCluster,
- &au8BasicClusterAttributeControlBits[0]) != E_ZCL_SUCCESS) {
- return E_ZCL_FAIL;
- }
- #endif
- #if (defined CLD_IDENTIFY) && (defined IDENTIFY_SERVER)
- /* Create an instance of an Identify cluster as a server */
- if (eCLD_IdentifyCreateIdentify(
- &psDeviceInfo->sClusterInstance.sIdentifyServer,
- TRUE,
- &sCLD_Identify,
- &psDeviceInfo->sIdentifyServerCluster,
- &au8IdentifyAttributeControlBits[0],
- &psDeviceInfo->sIdentifyServerCustomDataStructure) != E_ZCL_SUCCESS) {
- return E_ZCL_FAIL;
- }
- #endif
- #if (defined CLD_WINDOWCOVERING) && (defined WINDOWCOVERING_SERVER)
- if (eCLD_WindowCoveringCreateWindowCovering(
- &psDeviceInfo->sClusterInstance.sWindowCoveringServer,
- TRUE,
- &sCLD_WindowCovering,
- &psDeviceInfo->sWindowCoveringServerCluster,
- &au8WindowCoveringAttributeControlBits[0],
- &psDeviceInfo->sWindowCoveringCustomDataStructure) != E_ZCL_SUCCESS) {
- return E_ZCL_FAIL;
- }
- #endif
- #if (defined CLD_SCENES) && (defined SCENES_SERVER)
- /* Create an instance of a Scenes cluster as a server */
- if (eCLD_ScenesCreateScenes(
- &psDeviceInfo->sClusterInstance.sScenesServer,
- TRUE,
- &sCLD_Scenes,
- &psDeviceInfo->sScenesServerCluster,
- &au8ScenesAttributeControlBits[0],
- &psDeviceInfo->sScenesServerCustomDataStructure,
- &psDeviceInfo->sEndPoint) != E_ZCL_SUCCESS) {
- return E_ZCL_FAIL;
- }
- #endif
- #if (defined CLD_GROUPS) && (defined GROUPS_SERVER)
- /* Create an instance of a Groups cluster as a server */
- if (eCLD_GroupsCreateGroups(&psDeviceInfo->sClusterInstance.sGroupsServer,
- TRUE,
- &sCLD_Groups,
- &psDeviceInfo->sGroupsServerCluster,
- &au8GroupsAttributeControlBits[0],
- &psDeviceInfo->sGroupsServerCustomDataStructure,
- &psDeviceInfo->sEndPoint) != E_ZCL_SUCCESS) {
- return E_ZCL_FAIL;
- }
- #endif
- #ifdef CLD_OTA
- #ifdef OTA_CLIENT
- if (eOTA_Create(
- &psDeviceInfo->sClusterInstance.sOTAClient,
- FALSE, /* client */
- &sCLD_OTA,
- &psDeviceInfo->sCLD_OTA, /* cluster definition */
- u8EndPointIdentifier,
- NULL,
- &psDeviceInfo->sCLD_OTA_CustomDataStruct
- ) != E_ZCL_SUCCESS) {
- // Need to convert from cluster specific to ZCL return type so we lose the extra information of the return code
- return E_ZCL_FAIL;
- }
- #endif
- #ifdef OTA_SERVER
- if (eOTA_Create(
- &psDeviceInfo->sClusterInstance.sOTAServer,
- TRUE, /* Server */
- &sCLD_OTA,
- &psDeviceInfo->sCLD_ServerOTA, /* cluster definition */
- u8EndPointIdentifier,
- NULL,
- &psDeviceInfo->sCLD_OTA_ServerCustomDataStruct
- ) != E_ZCL_SUCCESS) {
- // Need to convert from cluster specific to ZCL return type so we lose the extra information of the return code
- return E_ZCL_FAIL;
- }
- #endif
- #endif
- return eZCL_Register(&psDeviceInfo->sEndPoint);
- }
- /****************************************************************************/
- /*** Local Functions ***/
- /****************************************************************************/
- /****************************************************************************/
- /*** END OF FILE ***/
- /****************************************************************************/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement