zcl_closures.c 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682
  1. /**************************************************************************************************
  2. Filename: zcl_closures.c
  3. Revised: $Date: 2011-05-02 10:30:51 -0700 (Mon, 02 May 2011) $
  4. Revision: $Revision: 25832 $
  5. Description: Zigbee Cluster Library - Closures.
  6. Copyright 2006-2011 Texas Instruments Incorporated. All rights reserved.
  7. IMPORTANT: Your use of this Software is limited to those specific rights
  8. granted under the terms of a software license agreement between the user
  9. who downloaded the software, his/her employer (which must be your employer)
  10. and Texas Instruments Incorporated (the "License"). You may not use this
  11. Software unless you agree to abide by the terms of the License. The License
  12. limits your use, and you acknowledge, that the Software may not be modified,
  13. copied or distributed unless embedded on a Texas Instruments microcontroller
  14. or used solely and exclusively in conjunction with a Texas Instruments radio
  15. frequency transceiver, which is integrated into your product. Other than for
  16. the foregoing purpose, you may not use, reproduce, copy, prepare derivative
  17. works of, modify, distribute, perform, display or sell this Software and/or
  18. its documentation for any purpose.
  19. YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
  20. PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
  21. INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
  22. NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
  23. TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
  24. NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
  25. LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
  26. INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
  27. OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
  28. OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
  29. (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
  30. Should you have any questions regarding your right to use this Software,
  31. contact Texas Instruments Incorporated at www.TI.com.
  32. **************************************************************************************************/
  33. /*********************************************************************
  34. * INCLUDES
  35. */
  36. #include "ZComDef.h"
  37. #include "OSAL.h"
  38. #include "zcl.h"
  39. #include "zcl_general.h"
  40. #include "zcl_closures.h"
  41. #if defined ( INTER_PAN )
  42. #include "stub_aps.h"
  43. #endif
  44. /*********************************************************************
  45. * MACROS
  46. */
  47. /*********************************************************************
  48. * CONSTANTS
  49. */
  50. /*********************************************************************
  51. * TYPEDEFS
  52. */
  53. typedef struct zclClosuresCBRec
  54. {
  55. struct zclClosuresCBRec *next;
  56. uint8 endpoint; // Used to link it into the endpoint descriptor
  57. zclClosures_AppCallbacks_t *CBs; // Pointer to Callback function
  58. } zclClosuresCBRec_t;
  59. /*********************************************************************
  60. * GLOBAL VARIABLES
  61. */
  62. /*********************************************************************
  63. * GLOBAL FUNCTIONS
  64. */
  65. /*********************************************************************
  66. * LOCAL VARIABLES
  67. */
  68. static zclClosuresCBRec_t *zclClosuresCBs = (zclClosuresCBRec_t *)NULL;
  69. static uint8 zclClosuresPluginRegisted = FALSE;
  70. /*********************************************************************
  71. * LOCAL FUNCTIONS
  72. */
  73. static ZStatus_t zclClosures_HdlIncoming( zclIncoming_t *pInMsg );
  74. static ZStatus_t zclClosures_HdlInSpecificCommands( zclIncoming_t *pInMsg );
  75. static zclClosures_AppCallbacks_t *zclClosures_FindCallbacks( uint8 endpoint );
  76. static ZStatus_t zclClosures_ProcessInClosuresCmds( zclIncoming_t *pInMsg );
  77. #ifdef ZCL_DOORLOCK
  78. static ZStatus_t zclClosures_ProcessInDoorLock( zclIncoming_t *pInMsg,
  79. zclClosures_AppCallbacks_t *pCBs );
  80. #endif //ZCL_DOORLOCK
  81. #ifdef ZCL_WINDOWCOVERING
  82. static ZStatus_t zclClosures_ProcessInWindowCovering( zclIncoming_t *pInMsg,
  83. zclClosures_AppCallbacks_t *pCBs );
  84. #endif //ZCL_WINDOWCOVERING
  85. /*********************************************************************
  86. * @fn zclClosures_RegisterCmdCallbacks
  87. *
  88. * @brief Register an applications command callbacks
  89. *
  90. * @param endpoint - application's endpoint
  91. * @param callbacks - pointer to the callback record.
  92. *
  93. * @return ZMemError if not able to allocate
  94. */
  95. ZStatus_t zclClosures_RegisterCmdCallbacks( uint8 endpoint, zclClosures_AppCallbacks_t *callbacks )
  96. {
  97. zclClosuresCBRec_t *pNewItem;
  98. zclClosuresCBRec_t *pLoop;
  99. // Register as a ZCL Plugin
  100. if ( !zclClosuresPluginRegisted )
  101. {
  102. zcl_registerPlugin( ZCL_CLUSTER_ID_CLOSURES_SHADE_CONFIG,
  103. ZCL_CLUSTER_ID_CLOSURES_WINDOW_COVERING,
  104. zclClosures_HdlIncoming );
  105. zclClosuresPluginRegisted = TRUE;
  106. }
  107. // Fill in the new profile list
  108. pNewItem = osal_mem_alloc( sizeof( zclClosuresCBRec_t ) );
  109. if ( pNewItem == NULL )
  110. return (ZMemError);
  111. pNewItem->next = (zclClosuresCBRec_t *)NULL;
  112. pNewItem->endpoint = endpoint;
  113. pNewItem->CBs = callbacks;
  114. // Find spot in list
  115. if ( zclClosuresCBs == NULL )
  116. {
  117. zclClosuresCBs = pNewItem;
  118. }
  119. else
  120. {
  121. // Look for end of list
  122. pLoop = zclClosuresCBs;
  123. while ( pLoop->next != NULL )
  124. pLoop = pLoop->next;
  125. // Put new item at end of list
  126. pLoop->next = pNewItem;
  127. }
  128. return ( ZSuccess );
  129. }
  130. /*********************************************************************
  131. * @fn zclClosures_FindCallbacks
  132. *
  133. * @brief Find the callbacks for an endpoint
  134. *
  135. * @param endpoint
  136. *
  137. * @return pointer to the callbacks
  138. */
  139. static zclClosures_AppCallbacks_t *zclClosures_FindCallbacks( uint8 endpoint )
  140. {
  141. zclClosuresCBRec_t *pCBs;
  142. pCBs = zclClosuresCBs;
  143. while ( pCBs )
  144. {
  145. if ( pCBs->endpoint == endpoint )
  146. return ( pCBs->CBs );
  147. pCBs = pCBs->next;
  148. }
  149. return ( (zclClosures_AppCallbacks_t *)NULL );
  150. }
  151. /*********************************************************************
  152. * @fn zclClosures_HdlIncoming
  153. *
  154. * @brief Callback from ZCL to process incoming Commands specific
  155. * to this cluster library or Profile commands for attributes
  156. * that aren't in the attribute list
  157. *
  158. * @param pInMsg - pointer to the incoming message
  159. * @param logicalClusterID
  160. *
  161. * @return ZStatus_t
  162. */
  163. static ZStatus_t zclClosures_HdlIncoming( zclIncoming_t *pInMsg )
  164. {
  165. ZStatus_t stat = ZSuccess;
  166. #if defined ( INTER_PAN )
  167. if ( StubAPS_InterPan( pInMsg->msg->srcAddr.panId, pInMsg->msg->srcAddr.endPoint ) )
  168. return ( stat ); // Cluster not supported thru Inter-PAN
  169. #endif
  170. if ( zcl_ClusterCmd( pInMsg->hdr.fc.type ) )
  171. {
  172. // Is this a manufacturer specific command?
  173. if ( pInMsg->hdr.fc.manuSpecific == 0 )
  174. {
  175. stat = zclClosures_HdlInSpecificCommands( pInMsg );
  176. }
  177. else
  178. {
  179. // We don't support any manufacturer specific command.
  180. stat = ZFailure;
  181. }
  182. }
  183. else
  184. {
  185. // Handle all the normal (Read, Write...) commands -- should never get here
  186. stat = ZFailure;
  187. }
  188. return ( stat );
  189. }
  190. /*********************************************************************
  191. * @fn zclClosures_HdlInSpecificCommands
  192. *
  193. * @brief Callback from ZCL to process incoming Commands specific
  194. * to this cluster library
  195. * @param pInMsg - pointer to the incoming message
  196. *
  197. * @return ZStatus_t
  198. */
  199. static ZStatus_t zclClosures_HdlInSpecificCommands( zclIncoming_t *pInMsg )
  200. {
  201. ZStatus_t stat;
  202. zclClosures_AppCallbacks_t *pCBs;
  203. // make sure endpoint exists
  204. pCBs = zclClosures_FindCallbacks( pInMsg->msg->endPoint );
  205. if ( pCBs == NULL )
  206. return ( ZFailure );
  207. switch ( pInMsg->msg->clusterId )
  208. {
  209. case ZCL_CLOSURES_LOGICAL_CLUSTER_ID_SHADE_CONFIG:
  210. stat = zclClosures_ProcessInClosuresCmds( pInMsg );
  211. break;
  212. case ZCL_CLUSTER_ID_CLOSURES_DOOR_LOCK:
  213. #ifdef ZCL_DOORLOCK
  214. stat = zclClosures_ProcessInDoorLock( pInMsg, pCBs );
  215. #endif //ZCL_DOORLOCK
  216. break;
  217. case ZCL_CLUSTER_ID_CLOSURES_WINDOW_COVERING:
  218. #ifdef ZCL_WINDOWCOVERING
  219. stat = zclClosures_ProcessInWindowCovering( pInMsg, pCBs );
  220. #endif //ZCL_WINDOWCOVERING
  221. break;
  222. default:
  223. stat = ZFailure;
  224. break;
  225. }
  226. return ( stat );
  227. }
  228. /*********************************************************************
  229. * @fn zclSS_ProcessInClosuresCmds
  230. *
  231. * @brief Callback from ZCL to process incoming Commands specific
  232. * to this cluster library on a command ID basis
  233. * @param pInMsg - pointer to the incoming message
  234. *
  235. * @return ZStatus_t
  236. */
  237. static ZStatus_t zclClosures_ProcessInClosuresCmds( zclIncoming_t *pInMsg )
  238. {
  239. ZStatus_t stat = ZFailure;
  240. // there are no specific command for this cluster yet.
  241. // instead of suppressing a compiler warnings( for a code porting reasons )
  242. // fake unused call here and keep the code skeleton intact
  243. (void)pInMsg;
  244. if ( stat != ZFailure )
  245. zclClosures_FindCallbacks( 0 );
  246. return ( stat );
  247. }
  248. #ifdef ZCL_DOORLOCK
  249. /*********************************************************************
  250. * @fn zclClosures_ProcessInDoorLock
  251. *
  252. * @brief Process in the received DoorLock Command.
  253. *
  254. * @param pInMsg - pointer to the incoming message
  255. * @param pCBs - pointer to the Application callback functions
  256. *
  257. * @return ZStatus_t
  258. */
  259. static ZStatus_t zclClosures_ProcessInDoorLock( zclIncoming_t *pInMsg,
  260. zclClosures_AppCallbacks_t *pCBs )
  261. {
  262. if ( zcl_ServerCmd( pInMsg->hdr.fc.direction ) )
  263. {
  264. switch(pInMsg->hdr.commandID)
  265. {
  266. case COMMAND_CLOSURES_LOCK_DOOR:
  267. case COMMAND_CLOSURES_UNLOCK_DOOR:
  268. if ( pCBs->pfnDoorLock )
  269. {
  270. pCBs->pfnDoorLock( pInMsg->hdr.commandID, &(pInMsg->msg->srcAddr), pInMsg->hdr.transSeqNum );
  271. }
  272. break;
  273. default:
  274. return ( ZCL_STATUS_UNSUP_CLUSTER_COMMAND ); // Error ignore the command
  275. }
  276. }
  277. else
  278. {
  279. switch(pInMsg->hdr.commandID)
  280. {
  281. case COMMAND_CLOSURES_LOCK_DOOR_RESPONSE:
  282. case COMMAND_CLOSURES_UNLOCK_DOOR_RESPONSE:
  283. if ( pCBs->pfnDoorLockRes )
  284. {
  285. pCBs->pfnDoorLockRes( pInMsg->hdr.commandID, &(pInMsg->msg->srcAddr), pInMsg->hdr.transSeqNum );
  286. }
  287. break;
  288. default:
  289. return ( ZCL_STATUS_UNSUP_CLUSTER_COMMAND ); // Error ignore the command
  290. }
  291. }
  292. return ( ZCL_STATUS_CMD_HAS_RSP );
  293. }
  294. /*********************************************************************
  295. * @fn zclClosures_SendDoorLockRequest
  296. *
  297. * @brief Call to send out a Door Lock/ Door Unlock Request Command
  298. *
  299. * @param srcEP - Sending application's endpoint
  300. * @param dstAddr - where you want the message to go
  301. * @param cmd - either COMMAND_DOOR_LOCK or COMMAND_DOOR_UNLOCK
  302. * @param clusterID - cluster whose commands and attributes lock and unlock
  303. the door
  304. * @param disableDefaultRsp - decides default response is necessary or not
  305. * @param seqNum - sequence number of the command packet
  306. *
  307. * @return ZStatus_t
  308. */
  309. ZStatus_t zclClosures_SendDoorLockRequest( uint8 srcEP, afAddrType_t *dstAddr,
  310. uint8 cmd, uint16 clusterID,
  311. uint8 disableDefaultRsp, uint8 seqNum )
  312. {
  313. return zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_CLOSURES_DOOR_LOCK,
  314. cmd, TRUE, ZCL_FRAME_CLIENT_SERVER_DIR,
  315. disableDefaultRsp, 0, seqNum, 0, NULL );
  316. }
  317. /*********************************************************************
  318. * @fn zclClosures_SendDoorLockResponse
  319. *
  320. * @brief Call to send out a Door Lock/ Door Unlock Response Command
  321. *
  322. * @param srcEP - Sending application's endpoint
  323. * @param dstAddr - where you want the message to go
  324. * @param cmd - either COMMAND_DOOR_LOCK or COMMAND_DOOR_UNLOCK
  325. * @param clusterID - cluster whose commands and attributes lock and unlock
  326. the door
  327. * @param disableDefaultRsp - decides default response is necessary or not
  328. * @param seqNum - sequence number of the command packet
  329. * @param status - status of the Door Lock/ Door Unlock Request Command
  330. *
  331. * @return ZStatus_t
  332. */
  333. ZStatus_t zclClosures_SendDoorLockResponse( uint8 srcEP, afAddrType_t *dstAddr,
  334. uint8 cmd, uint16 clusterID,
  335. uint8 disableDefaultRsp, uint8 seqNum,
  336. uint8 status )
  337. {
  338. uint8 payload[DOORLOCK_RES_PAYLOAD_LEN];
  339. payload[0] = status;
  340. return zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_CLOSURES_DOOR_LOCK,
  341. cmd, TRUE, ZCL_FRAME_SERVER_CLIENT_DIR,
  342. disableDefaultRsp, 0, seqNum,
  343. DOORLOCK_RES_PAYLOAD_LEN, payload );
  344. }
  345. #endif //ZCL_DOORLOCK
  346. #ifdef ZCL_WINDOWCOVERING
  347. /*********************************************************************
  348. * @fn zclClosures_ProcessInWindowCovering
  349. *
  350. * @brief Process in the received Window Covering cluster Command.
  351. *
  352. * @param pInMsg - pointer to the incoming message
  353. *
  354. * @return ZStatus_t
  355. */
  356. static ZStatus_t zclClosures_ProcessInWindowCovering( zclIncoming_t *pInMsg,
  357. zclClosures_AppCallbacks_t *pCBs )
  358. {
  359. ZStatus_t status = ZCL_STATUS_SUCCESS;
  360. uint8 *pData = pInMsg->pData;
  361. if ( zcl_ServerCmd( pInMsg->hdr.fc.direction ) )
  362. {
  363. switch ( pInMsg->hdr.commandID )
  364. {
  365. case COMMAND_CLOSURES_UP_OPEN:
  366. if ( pCBs->pfnWindowCoveringUpOpen )
  367. {
  368. pCBs->pfnWindowCoveringUpOpen();
  369. }
  370. break;
  371. case COMMAND_CLOSURES_DOWN_CLOSE:
  372. if ( pCBs->pfnWindowCoveringDownClose )
  373. {
  374. pCBs->pfnWindowCoveringDownClose();
  375. }
  376. break;
  377. case COMMAND_CLOSURES_STOP:
  378. if ( pCBs->pfnWindowCoveringStop )
  379. {
  380. pCBs->pfnWindowCoveringStop();
  381. }
  382. break;
  383. case COMMAND_CLOSURES_GO_TO_LIFT_SETPOINT:
  384. if ( pCBs->pfnWindowCoveringGotoLiftSetpoint )
  385. {
  386. status = pCBs->pfnWindowCoveringGotoLiftSetpoint( pData[0] );
  387. }
  388. break;
  389. case COMMAND_CLOSURES_GO_TO_LIFT_VALUE:
  390. if ( pCBs->pfnWindowCoveringGotoLiftValue )
  391. {
  392. if ( pCBs->pfnWindowCoveringGotoLiftValue( BUILD_UINT16( pData[0], pData[1] ) ) == FALSE )
  393. {
  394. status = ZCL_STATUS_INVALID_VALUE;
  395. }
  396. }
  397. break;
  398. case COMMAND_CLOSURES_GO_TO_LIFT_PERCENTAGE:
  399. if ( pCBs->pfnWindowCoveringGotoLiftPercentage )
  400. {
  401. if ( pCBs->pfnWindowCoveringGotoLiftPercentage( pData[0] ) == FALSE )
  402. {
  403. status = ZCL_STATUS_INVALID_VALUE;
  404. }
  405. }
  406. break;
  407. case COMMAND_CLOSURES_GO_TO_TILT_SETPOINT:
  408. if ( pCBs->pfnWindowCoveringGotoTiltSetpoint )
  409. {
  410. status = pCBs->pfnWindowCoveringGotoTiltSetpoint( pData[0] );
  411. }
  412. break;
  413. case COMMAND_CLOSURES_GO_TO_TILT_VALUE:
  414. if ( pCBs->pfnWindowCoveringGotoTiltValue )
  415. {
  416. if ( pCBs->pfnWindowCoveringGotoTiltValue( BUILD_UINT16( pData[0], pData[1] ) ) == FALSE )
  417. {
  418. status = ZCL_STATUS_INVALID_VALUE;
  419. }
  420. }
  421. break;
  422. case COMMAND_CLOSURES_GO_TO_TILT_PERCENTAGE:
  423. if ( pCBs->pfnWindowCoveringGotoTiltPercentage )
  424. {
  425. if ( pCBs->pfnWindowCoveringGotoTiltPercentage( pData[0] ) == FALSE )
  426. {
  427. status = ZCL_STATUS_INVALID_VALUE;
  428. }
  429. }
  430. break;
  431. case COMMAND_CLOSURES_PROGRAM_SETPOINT:
  432. if ( pCBs->pfnWindowCoveringProgramSetpoint )
  433. {
  434. programSetpointPayload_t setpoint;
  435. if( pInMsg->pDataLen == ZCL_WC_PROGRAMSETPOINTREQ_VER1_PAYLOADLEN )
  436. {
  437. setpoint.version = programSetpointVersion1;
  438. setpoint.setpointType = (setpointType_t)pData[0];
  439. setpoint.setpointIndex = pData[1];
  440. setpoint.setpointValue = BUILD_UINT16( pData[2], pData[3] );
  441. }
  442. else if( pInMsg->pDataLen == ZCL_WC_PROGRAMSETPOINTREQ_VER2_PAYLOADLEN )
  443. {
  444. setpoint.version = programSetpointVersion2;
  445. setpoint.setpointIndex = pData[0];
  446. }
  447. else
  448. {
  449. return ZCL_STATUS_INVALID_VALUE;
  450. }
  451. if ( pCBs->pfnWindowCoveringProgramSetpoint( &setpoint ) == FALSE )
  452. {
  453. status = ZCL_STATUS_INSUFFICIENT_SPACE;
  454. }
  455. }
  456. break;
  457. default:
  458. return( ZCL_STATUS_UNSUP_CLUSTER_COMMAND );
  459. }
  460. }
  461. // no Client command
  462. return ( status );
  463. }
  464. /*********************************************************************
  465. * @fn zclClosures_WCSimpleRequest
  466. *
  467. * @brief Call to send out a Window Covering command with no payload
  468. * as Up/Open, Down/Close or Stop
  469. *
  470. * @param srcEP - Sending application's endpoint
  471. * @param dstAddr - where you want the message to go
  472. * @param cmd - Command ID
  473. * @param disableDefaultRsp - decides default response is necessary or not
  474. * @param seqNum - sequence number of the command packet
  475. *
  476. * @return ZStatus_t
  477. */
  478. ZStatus_t zclClosures_WCSimpleRequest( uint8 srcEP, afAddrType_t *dstAddr,
  479. uint8 cmd, uint8 disableDefaultRsp, uint8 seqNum )
  480. {
  481. return zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_CLOSURES_WINDOW_COVERING,
  482. cmd, TRUE, ZCL_FRAME_CLIENT_SERVER_DIR,
  483. disableDefaultRsp, 0, seqNum, 0, NULL );
  484. }
  485. /*********************************************************************
  486. * @fn zclClosures_SendGoToSetpointRequest
  487. *
  488. * @brief Call to send out a Go to Setpoint Request Command
  489. *
  490. * @param srcEP - Sending application's endpoint
  491. * @param dstAddr - where you want the message to go
  492. * @param cmd - Command ID for COMMAND_CLOSURES_GO_TO_LIFT_SETPOINT
  493. * or COMMAND_CLOSURES_GO_TO_TILT_SETPOINT
  494. * @param disableDefaultRsp - decides default response is necessary or not
  495. * @param seqNum - sequence number of the command packet
  496. * @param SetpointIndex - payload
  497. *
  498. * @return ZStatus_t
  499. */
  500. ZStatus_t zclClosures_WCSendGoToSetpointRequest( uint8 srcEP, afAddrType_t *dstAddr,
  501. uint8 cmd, uint8 disableDefaultRsp,
  502. uint8 seqNum, uint8 SetpointIndex )
  503. {
  504. uint8 buf[ZCL_WC_GOTOSETPOINTREQ_PAYLOADLEN];
  505. buf[0] = SetpointIndex;
  506. return zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_CLOSURES_WINDOW_COVERING,
  507. cmd, TRUE, ZCL_FRAME_CLIENT_SERVER_DIR,
  508. disableDefaultRsp, 0, seqNum,
  509. ZCL_WC_GOTOSETPOINTREQ_PAYLOADLEN, buf );
  510. }
  511. /*********************************************************************
  512. * @fn zclClosures_WCSendGoToValueRequest
  513. *
  514. * @brief Call to send out a Go to Value Request Command
  515. *
  516. * @param srcEP - Sending application's endpoint
  517. * @param dstAddr - where you want the message to go
  518. * @param cmd - Command ID for COMMAND_CLOSURES_GO_TO_LIFT_VALUE
  519. * @param disableDefaultRsp - decides default response is necessary or not
  520. * @param seqNum - sequence number of the command packet
  521. * @param liftValue - payload
  522. *
  523. * @return ZStatus_t
  524. */
  525. ZStatus_t zclClosures_WCSendGoToValueRequest( uint8 srcEP, afAddrType_t *dstAddr,
  526. uint8 cmd, uint8 disableDefaultRsp,
  527. uint8 seqNum, uint16 Value )
  528. {
  529. uint8 buf[ZCL_WC_GOTOVALUEREQ_PAYLOADLEN];
  530. buf[0] = LO_UINT16( Value );
  531. buf[1] = HI_UINT16( Value );
  532. return zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_CLOSURES_WINDOW_COVERING,
  533. cmd, TRUE, ZCL_FRAME_CLIENT_SERVER_DIR,
  534. disableDefaultRsp, 0, seqNum,
  535. ZCL_WC_GOTOVALUEREQ_PAYLOADLEN, buf );
  536. }
  537. /*********************************************************************
  538. * @fn zclClosures_WCSendGoToPercentageRequest
  539. *
  540. * @brief Call to send out a Go to Percentage Request Command
  541. *
  542. * @param srcEP - Sending application's endpoint
  543. * @param dstAddr - where you want the message to go
  544. * @param cmd - Command ID e.g. COMMAND_CLOSURES_GO_TO_LIFT_PERCENTAGE
  545. * @param disableDefaultRsp - decides default response is necessary or not
  546. * @param seqNum - sequence number of the command packet
  547. * @param percentageLiftValue - payload
  548. *
  549. * @return ZStatus_t
  550. */
  551. ZStatus_t zclClosures_WCSendGoToPercentageRequest( uint8 srcEP, afAddrType_t *dstAddr,
  552. uint8 cmd, uint8 disableDefaultRsp,
  553. uint8 seqNum, uint8 percentageValue )
  554. {
  555. uint8 buf[ZCL_WC_GOTOPERCENTAGEREQ_PAYLOADLEN];
  556. buf[0] = percentageValue;
  557. return zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_CLOSURES_WINDOW_COVERING,
  558. cmd, TRUE, ZCL_FRAME_CLIENT_SERVER_DIR,
  559. disableDefaultRsp, 0, seqNum,
  560. ZCL_WC_GOTOPERCENTAGEREQ_PAYLOADLEN, buf );
  561. }
  562. /*********************************************************************
  563. * @fn zclClosures_WCSendProgramSetpointRequest
  564. *
  565. * @brief Call to send out a Program Setpoint Request Command
  566. *
  567. * @param srcEP - Sending application's endpoint
  568. * @param dstAddr - where you want the message to go
  569. * @param cmd - Command ID for COMMAND_CLOSURES_PROGRAM_SETPOINT
  570. * @param disableDefaultRsp - decides default response is necessary or not
  571. * @param seqNum - sequence number of the command packet
  572. * @param programSetpoint - contains payload information
  573. *
  574. * @return ZStatus_t
  575. */
  576. ZStatus_t zclClosures_WCSendProgramSetpointRequest( uint8 srcEP, afAddrType_t *dstAddr,
  577. uint8 cmd, uint8 disableDefaultRsp,
  578. uint8 seqNum, programSetpointPayload_t *programSetpoint )
  579. {
  580. uint8 buf[ZCL_WC_PROGRAMSETPOINTREQ_VER1_PAYLOADLEN];
  581. uint8 len;
  582. if( programSetpoint->version == programSetpointVersion1 )
  583. {
  584. buf[0] = programSetpoint->setpointType;
  585. buf[1] = programSetpoint->setpointIndex;
  586. buf[2] = LO_UINT16( programSetpoint->setpointValue );
  587. buf[3] = HI_UINT16( programSetpoint->setpointValue );
  588. len = ZCL_WC_PROGRAMSETPOINTREQ_VER1_PAYLOADLEN;
  589. }
  590. else if( programSetpoint->version == programSetpointVersion2 )
  591. {
  592. buf[0] = programSetpoint->setpointIndex;
  593. len = ZCL_WC_PROGRAMSETPOINTREQ_VER2_PAYLOADLEN;
  594. }
  595. else
  596. {
  597. return( ZFailure );
  598. }
  599. return zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_CLOSURES_WINDOW_COVERING,
  600. cmd, TRUE, ZCL_FRAME_CLIENT_SERVER_DIR,
  601. disableDefaultRsp, 0, seqNum, len, buf );
  602. }
  603. #endif //ZCL_WINDOWCOVERING
  604. /********************************************************************************************
  605. *********************************************************************************************/