Advertisement
tranthudo

window_covering.c

Jul 2nd, 2019
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 7.05 KB | None | 0 0
  1. /*
  2.  * window_covering.c
  3.  *
  4.  *  Created on: Jun 1, 2019
  5.  *      Author: TrungTQ9
  6.  */
  7.  
  8. #include <jendefs.h>
  9. #include <string.h>
  10.  
  11. #include "zps_apl.h"
  12. #include "zcl_heap.h"
  13. #include "zcl.h"
  14. #include "zcl_options.h"
  15. #include "Basic.h"
  16. #include "Identify.h"
  17. #include "Groups.h"
  18. #include "WindowCovering.h"
  19. #include "window_covering.h"
  20.  
  21. #ifdef CLD_OTA
  22. #include "OTA.h"
  23. #endif
  24.  
  25. /****************************************************************************/
  26. /***        Macro Definitions                                             ***/
  27. /****************************************************************************/
  28.  
  29. /****************************************************************************/
  30. /***        Type Definitions                                              ***/
  31. /****************************************************************************/
  32.  
  33. /****************************************************************************/
  34. /***        Local Function Prototypes                                     ***/
  35. /****************************************************************************/
  36.  
  37. /****************************************************************************/
  38. /***        Exported Variables                                            ***/
  39. /****************************************************************************/
  40.  
  41. /****************************************************************************/
  42. /***        Local Variables                                               ***/
  43. /****************************************************************************/
  44.  
  45. /****************************************************************************/
  46. /***        Exported Functions                                            ***/
  47. /****************************************************************************/
  48.  
  49. PUBLIC teZCL_Status eHA_RegisterWindowCoveringEndPoint(
  50.     uint8                           u8EndPointIdentifier,
  51.     tfpZCL_ZCLCallBackFunction      cbCallBack,
  52.     tsHA_WindowCoveringDevice       *psDeviceInfo
  53. ) {
  54.     /* Fill in end point details */
  55.     psDeviceInfo->sEndPoint.u8EndPointNumber = u8EndPointIdentifier;
  56.     psDeviceInfo->sEndPoint.u16ManufacturerCode = ZCL_MANUFACTURER_CODE;
  57.     psDeviceInfo->sEndPoint.u16ProfileEnum = HA_PROFILE_ID;
  58.     psDeviceInfo->sEndPoint.bIsManufacturerSpecificProfile = FALSE;
  59.     psDeviceInfo->sEndPoint.u16NumberOfClusters = sizeof(tsHA_WindowCoveringDeviceClusterInstances) / sizeof(tsZCL_ClusterInstance);
  60.     psDeviceInfo->sEndPoint.psClusterInstance = (tsZCL_ClusterInstance*)&psDeviceInfo->sClusterInstance;
  61.     psDeviceInfo->sEndPoint.pCallBackFunctions = cbCallBack;
  62.  
  63.     /* Mandatory server clusters */
  64. #if (defined CLD_BASIC) && (defined BASIC_SERVER)
  65.     /* Create an instance of a Basic cluster as a server */
  66.     if (eCLD_BasicCreateBasic(
  67.                         &psDeviceInfo->sClusterInstance.sBasicServer,
  68.                         TRUE,
  69.                         &sCLD_Basic,
  70.                         &psDeviceInfo->sBasicServerCluster,
  71.                         &au8BasicClusterAttributeControlBits[0]) != E_ZCL_SUCCESS) {
  72.         return E_ZCL_FAIL;
  73.     }
  74. #endif
  75.  
  76. #if (defined CLD_IDENTIFY) && (defined IDENTIFY_SERVER)
  77.     /* Create an instance of an Identify cluster as a server */
  78.     if (eCLD_IdentifyCreateIdentify(
  79.                         &psDeviceInfo->sClusterInstance.sIdentifyServer,
  80.                         TRUE,
  81.                         &sCLD_Identify,
  82.                         &psDeviceInfo->sIdentifyServerCluster,
  83.                         &au8IdentifyAttributeControlBits[0],
  84.                         &psDeviceInfo->sIdentifyServerCustomDataStructure) != E_ZCL_SUCCESS) {
  85.         return E_ZCL_FAIL;
  86.     }
  87. #endif
  88.  
  89. #if (defined CLD_WINDOWCOVERING) && (defined WINDOWCOVERING_SERVER)
  90.     if (eCLD_WindowCoveringCreateWindowCovering(
  91.                         &psDeviceInfo->sClusterInstance.sWindowCoveringServer,
  92.                         TRUE,
  93.                         &sCLD_WindowCovering,
  94.                         &psDeviceInfo->sWindowCoveringServerCluster,
  95.                         &au8WindowCoveringAttributeControlBits[0],
  96.                         &psDeviceInfo->sWindowCoveringCustomDataStructure) != E_ZCL_SUCCESS) {
  97.         return E_ZCL_FAIL;
  98.     }
  99. #endif
  100.  
  101. #if (defined CLD_SCENES) && (defined SCENES_SERVER)
  102.     /* Create an instance of a Scenes cluster as a server */
  103.     if (eCLD_ScenesCreateScenes(
  104.                         &psDeviceInfo->sClusterInstance.sScenesServer,
  105.                         TRUE,
  106.                         &sCLD_Scenes,
  107.                         &psDeviceInfo->sScenesServerCluster,
  108.                         &au8ScenesAttributeControlBits[0],
  109.                         &psDeviceInfo->sScenesServerCustomDataStructure,
  110.                         &psDeviceInfo->sEndPoint) != E_ZCL_SUCCESS) {
  111.         return E_ZCL_FAIL;
  112.     }
  113. #endif
  114.  
  115. #if (defined CLD_GROUPS) && (defined GROUPS_SERVER)
  116.     /* Create an instance of a Groups cluster as a server */
  117.     if (eCLD_GroupsCreateGroups(&psDeviceInfo->sClusterInstance.sGroupsServer,
  118.                         TRUE,
  119.                         &sCLD_Groups,
  120.                         &psDeviceInfo->sGroupsServerCluster,
  121.                         &au8GroupsAttributeControlBits[0],
  122.                         &psDeviceInfo->sGroupsServerCustomDataStructure,
  123.                         &psDeviceInfo->sEndPoint) != E_ZCL_SUCCESS) {
  124.         return E_ZCL_FAIL;
  125.     }
  126. #endif
  127.  
  128. #ifdef CLD_OTA
  129.     #ifdef OTA_CLIENT
  130.         if (eOTA_Create(
  131.                 &psDeviceInfo->sClusterInstance.sOTAClient,
  132.                 FALSE,  /* client */
  133.                 &sCLD_OTA,
  134.                 &psDeviceInfo->sCLD_OTA,  /* cluster definition */
  135.                 u8EndPointIdentifier,
  136.                 NULL,
  137.                 &psDeviceInfo->sCLD_OTA_CustomDataStruct
  138.                 ) != E_ZCL_SUCCESS) {
  139.             // Need to convert from cluster specific to ZCL return type so we lose the extra information of the return code
  140.             return E_ZCL_FAIL;
  141.         }
  142.     #endif
  143.    
  144.     #ifdef OTA_SERVER
  145.         if (eOTA_Create(
  146.            &psDeviceInfo->sClusterInstance.sOTAServer,
  147.            TRUE,  /* Server */
  148.            &sCLD_OTA,
  149.            &psDeviceInfo->sCLD_ServerOTA,  /* cluster definition */
  150.            u8EndPointIdentifier,
  151.            NULL,
  152.            &psDeviceInfo->sCLD_OTA_ServerCustomDataStruct
  153.            ) != E_ZCL_SUCCESS) {
  154.             // Need to convert from cluster specific to ZCL return type so we lose the extra information of the return code
  155.             return E_ZCL_FAIL;
  156.         }
  157.     #endif    
  158. #endif
  159.  
  160.     return eZCL_Register(&psDeviceInfo->sEndPoint);
  161. }
  162.  
  163. /****************************************************************************/
  164. /***        Local Functions                                               ***/
  165. /****************************************************************************/
  166.  
  167. /****************************************************************************/
  168. /***        END OF FILE                                                   ***/
  169. /****************************************************************************/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement