zcl_cc.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649
  1. /**************************************************************************************************
  2. Filename: zcl_cc.c
  3. Revised: $Date: 2011-04-13 10:27:39 -0700 (Wed, 13 Apr 2011) $
  4. Revision: $Revision: 25679 $
  5. Description: Zigbee Cluster Library - Commissioning Cluster
  6. Copyright 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_cc.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 zclCCCBRec
  54. {
  55. struct zclCCCBRec *next;
  56. uint8 endpoint; // Used to link it into the endpoint descriptor
  57. zclCC_AppCallbacks_t *CBs; // Pointer to Callback function
  58. } zclCCCBRec_t;
  59. /*********************************************************************
  60. * GLOBAL VARIABLES
  61. */
  62. /*********************************************************************
  63. * GLOBAL FUNCTIONS
  64. */
  65. /*********************************************************************
  66. * LOCAL VARIABLES
  67. */
  68. static zclCCCBRec_t *zclCCCBs = (zclCCCBRec_t *)NULL;
  69. static uint8 zclCCPluginRegisted = FALSE;
  70. /*********************************************************************
  71. * LOCAL FUNCTIONS
  72. */
  73. /*
  74. * Callback from ZCL to process incoming Commands specific to this cluster library
  75. */
  76. static ZStatus_t zclCC_HdlIncoming( zclIncoming_t *pInMsg );
  77. /*
  78. * Function to process incoming Commands specific to this cluster library
  79. */
  80. static ZStatus_t zclCC_HdlInSpecificCommands( zclIncoming_t *pInMsg );
  81. /*
  82. * Process received Restart Device Command
  83. */
  84. static ZStatus_t zclCC_ProcessInCmd_RestartDevice( zclIncoming_t *pInMsg, zclCC_AppCallbacks_t *pCBs );
  85. /*
  86. * Process received Save Startup Parameters Command
  87. */
  88. static ZStatus_t zclCC_ProcessInCmd_SaveStartupParams( zclIncoming_t *pInMsg, zclCC_AppCallbacks_t *pCBs );
  89. /*
  90. * Process received Restore Startup Parameters Command
  91. */
  92. static ZStatus_t zclCC_ProcessInCmd_RestoreStartupParams( zclIncoming_t *pInMsg, zclCC_AppCallbacks_t *pCBs );
  93. /*
  94. * Process received Reset Startup Parameters Command
  95. */
  96. static ZStatus_t zclCC_ProcessInCmd_ResetStartupParams( zclIncoming_t *pInMsg, zclCC_AppCallbacks_t *pCBs );
  97. /*
  98. * Process received Restart Device Response
  99. */
  100. static ZStatus_t zclCC_ProcessInCmd_RestartDeviceRsp( zclIncoming_t *pInMsg, zclCC_AppCallbacks_t *pCBs );
  101. /*
  102. * Process received Save Startup Parameters Response
  103. */
  104. static ZStatus_t zclCC_ProcessInCmd_SaveStartupParamsRsp( zclIncoming_t *pInMsg, zclCC_AppCallbacks_t *pCBs );
  105. /*
  106. * Process received Restore Startup Parameters Response
  107. */
  108. static ZStatus_t zclCC_ProcessInCmd_RestoreStartupParamsRsp( zclIncoming_t *pInMsg, zclCC_AppCallbacks_t *pCBs );
  109. /*
  110. * Process received Reset Startup Parameters Response
  111. */
  112. static ZStatus_t zclCC_ProcessInCmd_ResetStartupParamsRsp( zclIncoming_t *pInMsg, zclCC_AppCallbacks_t *pCBs );
  113. /*********************************************************************
  114. * @fn zclCC_RegisterCmdCallbacks
  115. *
  116. * @brief Register an applications command callbacks
  117. *
  118. * @param endpoint - application's endpoint
  119. * @param callbacks - pointer to the callback record.
  120. *
  121. * @return ZSuccess if successful. ZMemError if not able to allocate
  122. */
  123. ZStatus_t zclCC_RegisterCmdCallbacks( uint8 endpoint, zclCC_AppCallbacks_t *callbacks )
  124. {
  125. zclCCCBRec_t *pNewItem;
  126. zclCCCBRec_t *pLoop;
  127. // Register as a ZCL Plugin
  128. if ( !zclCCPluginRegisted )
  129. {
  130. zcl_registerPlugin( ZCL_CLUSTER_ID_GEN_COMMISSIONING,
  131. ZCL_CLUSTER_ID_GEN_COMMISSIONING,
  132. zclCC_HdlIncoming );
  133. zclCCPluginRegisted = TRUE;
  134. }
  135. // Fill in the new profile list
  136. pNewItem = osal_mem_alloc( sizeof( zclCCCBRec_t ) );
  137. if ( pNewItem == NULL )
  138. {
  139. return ( ZMemError );
  140. }
  141. pNewItem->next = (zclCCCBRec_t *)NULL;
  142. pNewItem->endpoint = endpoint;
  143. pNewItem->CBs = callbacks;
  144. // Find spot in list
  145. if ( zclCCCBs == NULL )
  146. {
  147. zclCCCBs = pNewItem;
  148. }
  149. else
  150. {
  151. // Look for end of list
  152. pLoop = zclCCCBs;
  153. while ( pLoop->next != NULL )
  154. {
  155. pLoop = pLoop->next;
  156. }
  157. // Put new item at end of list
  158. pLoop->next = pNewItem;
  159. }
  160. return ( ZSuccess );
  161. }
  162. /*********************************************************************
  163. * @fn zclCC_FindCallbacks
  164. *
  165. * @brief Find the callbacks for an endpoint
  166. *
  167. * @param endpoint
  168. *
  169. * @return pointer to the callbacks
  170. */
  171. static zclCC_AppCallbacks_t *zclCC_FindCallbacks( uint8 endpoint )
  172. {
  173. zclCCCBRec_t *pCBs;
  174. pCBs = zclCCCBs;
  175. while ( pCBs != NULL )
  176. {
  177. if ( pCBs->endpoint == endpoint )
  178. {
  179. return ( pCBs->CBs );
  180. }
  181. pCBs = pCBs->next;
  182. }
  183. return ( (zclCC_AppCallbacks_t *)NULL );
  184. }
  185. /*********************************************************************
  186. * @fn zclCC_HdlIncoming
  187. *
  188. * @brief Callback from ZCL to process incoming Commands specific
  189. * to this cluster library or Profile commands for attributes
  190. * that aren't in the attribute list
  191. *
  192. * @param pInMsg - pointer to the incoming message
  193. *
  194. * @return ZStatus_t
  195. */
  196. static ZStatus_t zclCC_HdlIncoming( zclIncoming_t *pInMsg )
  197. {
  198. ZStatus_t stat = ZSuccess;
  199. #if defined ( INTER_PAN )
  200. if ( StubAPS_InterPan( pInMsg->msg->srcAddr.panId, pInMsg->msg->srcAddr.endPoint ) )
  201. {
  202. return ( stat ); // Cluster not supported thru Inter-PAN
  203. }
  204. #endif
  205. if ( zcl_ClusterCmd( pInMsg->hdr.fc.type ) )
  206. {
  207. // Is this a manufacturer specific command?
  208. if ( pInMsg->hdr.fc.manuSpecific == 0 )
  209. {
  210. stat = zclCC_HdlInSpecificCommands( pInMsg );
  211. }
  212. else
  213. {
  214. // We don't support any manufacturer specific command.
  215. stat = ZFailure;
  216. }
  217. }
  218. else
  219. {
  220. // Handle all the normal (Read, Write...) commands -- should never get here
  221. stat = ZFailure;
  222. }
  223. return ( stat );
  224. }
  225. /*********************************************************************
  226. * @fn zclCC_HdlInSpecificCommands
  227. *
  228. * @brief Function to process incoming Commands specific
  229. * to this cluster library
  230. * @param pInMsg - pointer to the incoming message
  231. *
  232. * @return ZStatus_t
  233. */
  234. static ZStatus_t zclCC_HdlInSpecificCommands( zclIncoming_t *pInMsg )
  235. {
  236. ZStatus_t stat;
  237. zclCC_AppCallbacks_t *pCBs;
  238. // Make sure endpoint exists
  239. pCBs = zclCC_FindCallbacks( pInMsg->msg->endPoint );
  240. if ( pCBs == NULL )
  241. {
  242. return ( ZFailure );
  243. }
  244. if ( zcl_ServerCmd( pInMsg->hdr.fc.direction ) )
  245. {
  246. // Process Client commands, received by server
  247. switch ( pInMsg->hdr.commandID )
  248. {
  249. case COMMAND_CC_RESTART_DEVICE:
  250. stat = zclCC_ProcessInCmd_RestartDevice( pInMsg, pCBs );
  251. break;
  252. case COMMAND_CC_SAVE_STARTUP_PARAMS:
  253. stat = zclCC_ProcessInCmd_SaveStartupParams( pInMsg, pCBs );
  254. break;
  255. case COMMAND_CC_RESTORE_STARTUP_PARAMS:
  256. stat = zclCC_ProcessInCmd_RestoreStartupParams( pInMsg, pCBs );
  257. break;
  258. case COMMAND_CC_RESET_STARTUP_PARAMS:
  259. stat = zclCC_ProcessInCmd_ResetStartupParams( pInMsg, pCBs );
  260. break;
  261. default:
  262. stat = ZFailure;
  263. break;
  264. }
  265. }
  266. else
  267. {
  268. switch ( pInMsg->hdr.commandID )
  269. {
  270. case COMMAND_CC_RESTART_DEVICE_RSP:
  271. stat = zclCC_ProcessInCmd_RestartDeviceRsp( pInMsg, pCBs );
  272. break;
  273. case COMMAND_CC_SAVE_STARTUP_PARAMS_RSP:
  274. stat = zclCC_ProcessInCmd_SaveStartupParamsRsp( pInMsg, pCBs );
  275. break;
  276. case COMMAND_CC_RESTORE_STARTUP_PARAMS_RSP:
  277. stat = zclCC_ProcessInCmd_RestoreStartupParamsRsp( pInMsg, pCBs );
  278. break;
  279. case COMMAND_CC_RESET_STARTUP_PARAMS_RSP:
  280. stat = zclCC_ProcessInCmd_ResetStartupParamsRsp( pInMsg, pCBs );
  281. break;
  282. default:
  283. stat = ZFailure;
  284. break;
  285. }
  286. }
  287. return ( stat );
  288. }
  289. /*********************************************************************
  290. * @fn zclCC_ProcessInCmd_RestartDevice
  291. *
  292. * @brief Process in the received Restart Device Command.
  293. *
  294. * @param pInMsg - pointer to the incoming message
  295. * @param pCBs - pointer to the Application callback
  296. *
  297. * @return ZStatus_t - status of the command processing
  298. */
  299. static ZStatus_t zclCC_ProcessInCmd_RestartDevice( zclIncoming_t *pInMsg,
  300. zclCC_AppCallbacks_t *pCBs )
  301. {
  302. if ( pCBs->pfnRestart_Device )
  303. {
  304. zclCCRestartDevice_t cmd;
  305. cmd.options = pInMsg->pData[0];
  306. cmd.delay = pInMsg->pData[1];
  307. cmd.jitter = pInMsg->pData[2];
  308. pCBs->pfnRestart_Device( &cmd, &(pInMsg->msg->srcAddr), pInMsg->hdr.transSeqNum );
  309. return ZCL_STATUS_CMD_HAS_RSP;
  310. }
  311. return ZFailure;
  312. }
  313. /*********************************************************************
  314. * @fn zclCC_ProcessInCmd_SaveStartupParams
  315. *
  316. * @brief Process in the received Save Startup Parameters Command.
  317. *
  318. * @param pInMsg - pointer to the incoming message
  319. * @param pCBs - pointer to the Application callback
  320. *
  321. * @return ZStatus_t - status of the command processing
  322. */
  323. static ZStatus_t zclCC_ProcessInCmd_SaveStartupParams( zclIncoming_t *pInMsg,
  324. zclCC_AppCallbacks_t *pCBs )
  325. {
  326. if ( pCBs->pfnSave_StartupParams )
  327. {
  328. zclCCStartupParams_t cmd;
  329. cmd.options = pInMsg->pData[0];
  330. cmd.index = pInMsg->pData[1];
  331. pCBs->pfnSave_StartupParams( &cmd, &(pInMsg->msg->srcAddr), pInMsg->hdr.transSeqNum );
  332. return ZCL_STATUS_CMD_HAS_RSP;
  333. }
  334. return ZFailure;
  335. }
  336. /*********************************************************************
  337. * @fn zclCC_ProcessInCmd_RestoreStartupParams
  338. *
  339. * @brief Process in the received Restore Startup Parameters Command.
  340. *
  341. * @param pInMsg - pointer to the incoming message
  342. * @param pCBs - pointer to the Application callback
  343. *
  344. * @return ZStatus_t - status of the command processing
  345. */
  346. static ZStatus_t zclCC_ProcessInCmd_RestoreStartupParams( zclIncoming_t *pInMsg,
  347. zclCC_AppCallbacks_t *pCBs )
  348. {
  349. if ( pCBs->pfnRestore_StartupParams )
  350. {
  351. zclCCStartupParams_t cmd;
  352. cmd.options = pInMsg->pData[0];
  353. cmd.index = pInMsg->pData[1];
  354. pCBs->pfnRestore_StartupParams( &cmd, &(pInMsg->msg->srcAddr), pInMsg->hdr.transSeqNum );
  355. return ZCL_STATUS_CMD_HAS_RSP;
  356. }
  357. return ZFailure;
  358. }
  359. /*********************************************************************
  360. * @fn zclCC_ProcessInCmd_ResetStartupParams
  361. *
  362. * @brief Process in the received Reset Startup Parameters Command.
  363. *
  364. * @param pInMsg - pointer to the incoming message
  365. * @param pCBs - pointer to the Application callback
  366. *
  367. * @return ZStatus_t - status of the command processing
  368. */
  369. static ZStatus_t zclCC_ProcessInCmd_ResetStartupParams( zclIncoming_t *pInMsg,
  370. zclCC_AppCallbacks_t *pCBs )
  371. {
  372. if ( pCBs->pfnReset_StartupParams )
  373. {
  374. zclCCStartupParams_t cmd;
  375. cmd.options = pInMsg->pData[0];
  376. cmd.index = pInMsg->pData[1];
  377. pCBs->pfnReset_StartupParams( &cmd, &(pInMsg->msg->srcAddr), pInMsg->hdr.transSeqNum );
  378. return ZCL_STATUS_CMD_HAS_RSP;
  379. }
  380. return ZFailure;
  381. }
  382. /*********************************************************************
  383. * @fn zclCC_ProcessInCmd_RestartDeviceRsp
  384. *
  385. * @brief Process in the received Restart Device Response
  386. *
  387. * @param pInMsg - pointer to the incoming message
  388. * @param pCBs - pointer to the Application callback
  389. *
  390. * @return ZStatus_t - status of the command processing
  391. */
  392. static ZStatus_t zclCC_ProcessInCmd_RestartDeviceRsp( zclIncoming_t *pInMsg,
  393. zclCC_AppCallbacks_t *pCBs )
  394. {
  395. if ( pCBs->pfnRestart_DeviceRsp )
  396. {
  397. zclCCServerParamsRsp_t rsp;
  398. rsp.status = pInMsg->pData[0];
  399. pCBs->pfnRestart_DeviceRsp( &rsp, &(pInMsg->msg->srcAddr), pInMsg->hdr.transSeqNum );
  400. return ZSuccess;
  401. }
  402. return ZFailure;
  403. }
  404. /*********************************************************************
  405. * @fn zclCC_ProcessInCmd_SaveStartupParamsRsp
  406. *
  407. * @brief Process in the received Save Startup Parameters Response
  408. *
  409. * @param pInMsg - pointer to the incoming message
  410. * @param pCBs - pointer to the Application callback
  411. *
  412. * @return ZStatus_t - status of the command processing
  413. */
  414. static ZStatus_t zclCC_ProcessInCmd_SaveStartupParamsRsp( zclIncoming_t *pInMsg,
  415. zclCC_AppCallbacks_t *pCBs )
  416. {
  417. if ( pCBs->pfnSave_StartupParamsRsp )
  418. {
  419. zclCCServerParamsRsp_t rsp;
  420. rsp.status = pInMsg->pData[0];
  421. pCBs->pfnSave_StartupParamsRsp( &rsp, &(pInMsg->msg->srcAddr), pInMsg->hdr.transSeqNum );
  422. return ZSuccess;
  423. }
  424. return ZFailure;
  425. }
  426. /*********************************************************************
  427. * @fn zclCC_ProcessInCmd_RestoreStartupParamsRsp
  428. *
  429. * @brief Process in the received Restore Startup Parameters Response
  430. *
  431. * @param pInMsg - pointer to the incoming message
  432. * @param pCBs - pointer to the Application callback
  433. *
  434. * @return ZStatus_t - status of the command processing
  435. */
  436. static ZStatus_t zclCC_ProcessInCmd_RestoreStartupParamsRsp( zclIncoming_t *pInMsg,
  437. zclCC_AppCallbacks_t *pCBs )
  438. {
  439. if ( pCBs->pfnRestore_StartupParamsRsp )
  440. {
  441. zclCCServerParamsRsp_t rsp;
  442. rsp.status = pInMsg->pData[0];
  443. pCBs->pfnRestore_StartupParamsRsp( &rsp, &(pInMsg->msg->srcAddr), pInMsg->hdr.transSeqNum );
  444. return ZSuccess;
  445. }
  446. return ZFailure;
  447. }
  448. /*********************************************************************
  449. * @fn zclCC_ProcessInCmd_ResetStartupParamsRsp
  450. *
  451. * @brief Process in the received Reset Startup Parameters Response
  452. *
  453. * @param pInMsg - pointer to the incoming message
  454. * @param pCBs - pointer to the Application callback
  455. *
  456. * @return ZStatus_t - status of the command processing
  457. */
  458. static ZStatus_t zclCC_ProcessInCmd_ResetStartupParamsRsp( zclIncoming_t *pInMsg,
  459. zclCC_AppCallbacks_t *pCBs )
  460. {
  461. if ( pCBs->pfnReset_StartupParamsRsp )
  462. {
  463. zclCCServerParamsRsp_t rsp;
  464. rsp.status = pInMsg->pData[0];
  465. pCBs->pfnReset_StartupParamsRsp( &rsp, &(pInMsg->msg->srcAddr), pInMsg->hdr.transSeqNum );
  466. return ZSuccess;
  467. }
  468. return ZFailure;
  469. }
  470. /*********************************************************************
  471. * @fn zclCC_Send_RestartDevice
  472. *
  473. * @brief Call to send out a Restart Device command
  474. *
  475. * @param srcEP - Sending application's endpoint
  476. * @param dstAddr - where you want the message to go
  477. * @param pCmd - pointer to Restart Command data structure
  478. * @param disableDefaultRsp - disable default response
  479. * @param seqNum - ZCL sequence number
  480. *
  481. * @return ZStatus_t
  482. */
  483. ZStatus_t zclCC_Send_RestartDevice( uint8 srcEP, afAddrType_t *dstAddr,
  484. zclCCRestartDevice_t *pCmd,
  485. uint8 disableDefaultRsp, uint8 seqNum )
  486. {
  487. uint8 buf[CC_PACKET_LEN_RESTART_DEVICE];
  488. buf[0] = pCmd->options;
  489. buf[1] = pCmd->delay;
  490. buf[2] = pCmd->jitter;
  491. return zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_GEN_COMMISSIONING,
  492. COMMAND_CC_RESTART_DEVICE, TRUE,
  493. ZCL_FRAME_CLIENT_SERVER_DIR, disableDefaultRsp, 0,
  494. seqNum, CC_PACKET_LEN_RESTART_DEVICE, buf );
  495. }
  496. /*********************************************************************
  497. * @fn zclCC_Send_StartupParamsCmd
  498. *
  499. * @brief Call to send out a Startup parameter command (Restore, Save, Reset)
  500. *
  501. * @param srcEP - Sending application's endpoint
  502. * @param dstAddr - where you want the message to go
  503. * @param pCmd - pointer to Startup Parameter Command data structure
  504. * @param cmdId - Command type ( Restore, Save or Reset)
  505. * @param disableDefaultRsp - disable default response
  506. * @param seqNum - ZCL sequence number
  507. *
  508. * @return ZStatus_t
  509. */
  510. ZStatus_t zclCC_Send_StartupParamsCmd( uint8 srcEP, afAddrType_t *dstAddr,
  511. zclCCStartupParams_t *pCmd, uint8 cmdId,
  512. uint8 disableDefaultRsp, uint8 seqNum )
  513. {
  514. uint8 buf[CC_PACKET_LEN_STARTUP_PARAMS_CMD];
  515. buf[0] = pCmd->options;
  516. buf[1] = pCmd->index;
  517. return zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_GEN_COMMISSIONING,
  518. cmdId, TRUE, ZCL_FRAME_CLIENT_SERVER_DIR,
  519. disableDefaultRsp, 0, seqNum,
  520. CC_PACKET_LEN_STARTUP_PARAMS_CMD, buf );
  521. }
  522. /*********************************************************************
  523. * @fn zclCC_Send_ServerParamsRsp
  524. *
  525. * @brief Call to send out a Server Parameters Response to a client request
  526. *
  527. * @param srcEP - Sending application's endpoint
  528. * @param dstAddr - where you want the message to go
  529. * @param pRsp - pointer to Startup Parameter Response data structure
  530. * @param cmdId - Command type ( Restore, Save or Reset)
  531. * @param disableDefaultRsp - disable default response
  532. * @param seqNum - ZCL sequence number
  533. *
  534. * @return ZStatus_t
  535. */
  536. ZStatus_t zclCC_Send_ServerParamsRsp( uint8 srcEP, afAddrType_t *dstAddr,
  537. zclCCServerParamsRsp_t *pRsp, uint8 cmdId,
  538. uint8 disableDefaultRsp, uint8 seqNum )
  539. {
  540. return zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_GEN_COMMISSIONING,
  541. cmdId, TRUE, ZCL_FRAME_SERVER_CLIENT_DIR,
  542. disableDefaultRsp, 0, seqNum,
  543. CC_PACKET_LEN_SERVER_RSP, &(pRsp->status) );
  544. }
  545. /********************************************************************************************
  546. *********************************************************************************************/