MT_SAPI.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621
  1. /**************************************************************************************************
  2. Filename: MT_SAPI.c
  3. Revised: $Date: 2010-05-25 10:12:39 -0700 (Tue, 25 May 2010) $
  4. Revision: $Revision: 22614 $
  5. Description: MonitorTest functions for the Simple API.
  6. Copyright 2007-2010 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 "AddrMgr.h"
  38. #include "OSAL.h"
  39. #include "OSAL_Nv.h"
  40. #include "OnBoard.h"
  41. #include "MT.h"
  42. #include "MT_SAPI.h"
  43. #include "MT_UART.h"
  44. /***************************************************************************************************
  45. * GLOBAL VARIABLES
  46. ***************************************************************************************************/
  47. #if defined ( MT_SAPI_CB_FUNC )
  48. uint16 _sapiCallbackSub;
  49. #endif
  50. /***************************************************************************************************
  51. * LOCAL FUNCTIONS
  52. ***************************************************************************************************/
  53. void MT_SapiSystemReset(uint8 *pBuf);
  54. void MT_SapiStart(uint8* pBuf);
  55. void MT_SapiBindDevice(uint8 *pBuf);
  56. void MT_SapiAllowBind(uint8 *pBuf);
  57. void MT_SapiSendData(uint8 *pBuf);
  58. void MT_SapiReadCfg(uint8 *pBuf);
  59. void MT_SapiWriteCfg(uint8 *pBuf);
  60. void MT_SapiGetDevInfo(uint8 *pBuf);
  61. void MT_SapiFindDev(uint8 *pBuf);
  62. void MT_SapiPermitJoin(uint8 *pBuf);
  63. void MT_SapiAppRegister(uint8 *pBuf);
  64. #if defined ( MT_SAPI_FUNC )
  65. /***************************************************************************************************
  66. * @fn MT_sapiCommandProcessing
  67. *
  68. * @brief Process all the SAPI commands that are issued by test tool
  69. *
  70. * @param pBuf - pointer to received buffer
  71. *
  72. * @return MT_RPC_SUCCESS if command processed, MT_RPC_ERR_COMMAND_ID if not.
  73. ***************************************************************************************************/
  74. uint8 MT_SapiCommandProcessing(uint8 *pBuf)
  75. {
  76. uint8 status = MT_RPC_SUCCESS;
  77. switch (pBuf[MT_RPC_POS_CMD1])
  78. {
  79. case MT_SAPI_START_REQ:
  80. MT_SapiStart(pBuf);
  81. break;
  82. case MT_SAPI_BIND_DEVICE_REQ:
  83. MT_SapiBindDevice(pBuf);
  84. break;
  85. case MT_SAPI_ALLOW_BIND_REQ:
  86. MT_SapiAllowBind(pBuf);
  87. break;
  88. case MT_SAPI_SEND_DATA_REQ:
  89. MT_SapiSendData(pBuf);
  90. break;
  91. case MT_SAPI_READ_CFG_REQ:
  92. MT_SapiReadCfg(pBuf);
  93. break;
  94. case MT_SAPI_WRITE_CFG_REQ:
  95. MT_SapiWriteCfg(pBuf);
  96. break;
  97. case MT_SAPI_GET_DEV_INFO_REQ:
  98. MT_SapiGetDevInfo(pBuf);
  99. break;
  100. case MT_SAPI_FIND_DEV_REQ:
  101. MT_SapiFindDev(pBuf);
  102. break;
  103. case MT_SAPI_PMT_JOIN_REQ:
  104. MT_SapiPermitJoin(pBuf);
  105. break;
  106. case MT_SAPI_SYS_RESET:
  107. MT_SapiSystemReset(pBuf);
  108. break;
  109. case MT_SAPI_APP_REGISTER_REQ:
  110. MT_SapiAppRegister(pBuf);
  111. break;
  112. default:
  113. status = MT_RPC_ERR_COMMAND_ID;
  114. break;
  115. }
  116. return status;
  117. }
  118. /***************************************************************************************************
  119. * @fn MT_SapiSystemReset
  120. *
  121. * @brief Process SAPI System Reset
  122. *
  123. * @param pBuf - pointer to received buffer
  124. *
  125. * @return none
  126. ***************************************************************************************************/
  127. void MT_SapiSystemReset(uint8 *pBuf)
  128. {
  129. zb_SystemReset();
  130. }
  131. /***************************************************************************************************
  132. * @fn MT_SapiStart
  133. *
  134. * @brief Process SAPI Start
  135. *
  136. * @param pBuf - pointer to received buffer
  137. *
  138. * @return none
  139. ***************************************************************************************************/
  140. void MT_SapiStart(uint8 *pBuf)
  141. {
  142. zb_StartRequest();
  143. /* Build and send back the response */
  144. MT_BuildAndSendZToolResponse(((uint8)MT_RPC_CMD_SRSP | (uint8)MT_RPC_SYS_SAPI), MT_SAPI_START_REQ, 0, NULL);
  145. }
  146. /***************************************************************************************************
  147. * @fn MT_SapiAppRegister
  148. *
  149. * @brief Process SAPI App Register
  150. *
  151. * @param pBuf - pointer to received buffer
  152. *
  153. * @return none
  154. ***************************************************************************************************/
  155. void MT_SapiAppRegister(uint8 *pBuf)
  156. {
  157. uint8 ret = ZApsIllegalRequest;
  158. /* check if sapi is alredy registered with an endpoint */
  159. if ( (sapi_epDesc.endPoint == 0) && (*pBuf != 0) )
  160. {
  161. ret = MT_BuildEndpointDesc( pBuf+MT_RPC_FRAME_HDR_SZ, &sapi_epDesc );
  162. if ( ret == ZSuccess )
  163. {
  164. ret = afRegister( &sapi_epDesc );
  165. // Turn off match descriptor response by default
  166. afSetMatch(sapi_epDesc.simpleDesc->EndPoint, FALSE);
  167. }
  168. if ( ret != ZSuccess )
  169. {
  170. sapi_epDesc.endPoint = 0;
  171. }
  172. }
  173. /* Build and send back the response */
  174. MT_BuildAndSendZToolResponse(((uint8)MT_RPC_CMD_SRSP | (uint8)MT_RPC_SYS_SAPI),
  175. MT_SAPI_APP_REGISTER_REQ, 1, &ret);
  176. }
  177. /***************************************************************************************************
  178. * @fn MT_SapiBindDevice
  179. *
  180. * @brief Process SAPI Bind Device Command
  181. *
  182. * @param pBuf - pointer to received buffer
  183. *
  184. * @return none
  185. ***************************************************************************************************/
  186. void MT_SapiBindDevice(uint8 *pBuf)
  187. {
  188. uint8 cmdId;
  189. /* parse header */
  190. cmdId = pBuf[MT_RPC_POS_CMD1];
  191. pBuf += MT_RPC_FRAME_HDR_SZ;
  192. if (AddrMgrExtAddrValid(pBuf+3))
  193. {
  194. zb_BindDevice(pBuf[0], BUILD_UINT16(pBuf[1], pBuf[2]), &pBuf[3]);
  195. }
  196. else
  197. {
  198. zb_BindDevice(pBuf[0], BUILD_UINT16(pBuf[1], pBuf[2]), (uint8 *)NULL);
  199. }
  200. /* Build and send back the response */
  201. MT_BuildAndSendZToolResponse(((uint8)MT_RPC_CMD_SRSP | (uint8)MT_RPC_SYS_SAPI), cmdId, 0, NULL);
  202. }
  203. /***************************************************************************************************
  204. * @fn MT_SapiAllowBind
  205. *
  206. * @brief Process SAPI Allow Bind
  207. *
  208. * @param pBuf - pointer to received buffer
  209. *
  210. * @return none
  211. ***************************************************************************************************/
  212. void MT_SapiAllowBind(uint8 *pBuf)
  213. {
  214. uint8 cmdId;
  215. /* parse header */
  216. cmdId = pBuf[MT_RPC_POS_CMD1];
  217. pBuf += MT_RPC_FRAME_HDR_SZ;
  218. zb_AllowBind(pBuf[0]);
  219. /* Build and send back the response */
  220. MT_BuildAndSendZToolResponse(((uint8)MT_RPC_CMD_SRSP | (uint8)MT_RPC_SYS_SAPI), cmdId, 0, NULL);
  221. }
  222. /***************************************************************************************************
  223. * @fn MT_SapiSendData
  224. *
  225. * @brief Process SAPI Send Data Command
  226. *
  227. * @param pBuf - pointer to received buffer
  228. *
  229. * @return none
  230. ***************************************************************************************************/
  231. void MT_SapiSendData(uint8 *pBuf)
  232. {
  233. uint8 cmdId;
  234. uint16 destination, command;
  235. uint8 len, handle, txOption, radius;
  236. /* parse header */
  237. cmdId = pBuf[MT_RPC_POS_CMD1];
  238. pBuf += MT_RPC_FRAME_HDR_SZ;
  239. /* Destination */
  240. destination = BUILD_UINT16(pBuf[0], pBuf[1]);
  241. /* Command */
  242. command = BUILD_UINT16(pBuf[2], pBuf[3]);
  243. /* Handle */
  244. handle = pBuf[4];
  245. /* txOption */
  246. txOption = pBuf[5];
  247. /* Radius */
  248. radius = pBuf[6];
  249. /* Length */
  250. len = pBuf[7];
  251. zb_SendDataRequest(destination, command, len, &pBuf[8], handle, txOption, radius);
  252. /* Build and send back the response */
  253. MT_BuildAndSendZToolResponse(((uint8)MT_RPC_CMD_SRSP | (uint8)MT_RPC_SYS_SAPI), cmdId, 0, NULL);
  254. }
  255. /***************************************************************************************************
  256. * @fn MT_SapiReadCfg
  257. *
  258. * @brief Process SAPI Read Config Commands
  259. *
  260. * @param pBuf - pointer to received buffer
  261. *
  262. * @return none
  263. ***************************************************************************************************/
  264. void MT_SapiReadCfg(uint8 *pBuf)
  265. {
  266. uint8 len, retStatus;
  267. uint8 cfgId, cmdId;
  268. uint8 *pRetBuf;
  269. /* Parse header */
  270. cmdId = pBuf[MT_RPC_POS_CMD1];
  271. cfgId = pBuf[MT_RPC_POS_DAT0];
  272. /* Length of item in NV memory */
  273. len = (uint8)osal_nv_item_len(cfgId);
  274. pRetBuf = osal_mem_alloc(len+3);
  275. if (pRetBuf != NULL)
  276. {
  277. if (len && ((cfgId != ZCD_NV_NIB) && (cfgId != ZCD_NV_DEVICE_LIST) &&
  278. (cfgId != ZCD_NV_ADDRMGR) && (cfgId != ZCD_NV_NWKKEY)))
  279. {
  280. if ((zb_ReadConfiguration(cfgId, len, pRetBuf+3)) == ZSUCCESS)
  281. {
  282. retStatus = ZSuccess;
  283. }
  284. else
  285. {
  286. retStatus = ZFailure;
  287. }
  288. }
  289. else
  290. {
  291. retStatus = ZInvalidParameter;
  292. }
  293. if (retStatus != ZSuccess)
  294. {
  295. /* Don't return garbage with error */
  296. len = 0;
  297. }
  298. /* Status */
  299. pRetBuf[0] = retStatus;
  300. /* Config ID */
  301. pRetBuf[1] = cfgId;
  302. /* NV item length */
  303. pRetBuf[2] = len;
  304. /* Build and send back the response */
  305. MT_BuildAndSendZToolResponse(((uint8)MT_RPC_CMD_SRSP | (uint8)MT_RPC_SYS_SAPI), cmdId, len+3, pRetBuf );
  306. osal_mem_free(pRetBuf);
  307. }
  308. }
  309. /***************************************************************************************************
  310. * @fn MT_SpiWriteCfg
  311. *
  312. * @brief Process Write Configuration Command
  313. *
  314. * @param pBuf - pointer to received buffer
  315. *
  316. * @return none
  317. ***************************************************************************************************/
  318. void MT_SapiWriteCfg(uint8 *pBuf)
  319. {
  320. uint8 retValue, cmdId;
  321. /* Parse header */
  322. cmdId = pBuf[MT_RPC_POS_CMD1];
  323. pBuf += MT_RPC_FRAME_HDR_SZ;
  324. if ((pBuf[0] != ZCD_NV_NIB) && (pBuf[0] != ZCD_NV_DEVICE_LIST) &&
  325. (pBuf[0] != ZCD_NV_ADDRMGR) && (pBuf[0] != ZCD_NV_NWKKEY))
  326. {
  327. if ((zb_WriteConfiguration(pBuf[0], pBuf[1], &pBuf[2])) == ZSUCCESS)
  328. {
  329. retValue = ZSuccess;
  330. }
  331. else
  332. {
  333. retValue = ZFailure;
  334. }
  335. }
  336. else
  337. {
  338. retValue = ZInvalidParameter;
  339. }
  340. /* Build and send back the response */
  341. MT_BuildAndSendZToolResponse(((uint8)MT_RPC_CMD_SRSP | (uint8)MT_RPC_SYS_SAPI), cmdId, 1, &retValue );
  342. }
  343. /***************************************************************************************************
  344. * @fn MT_SapiGetDevInfo
  345. *
  346. * @brief Process Get Device Info command
  347. *
  348. * @param pBuf - pointer to received buffer
  349. *
  350. * @return none
  351. ***************************************************************************************************/
  352. void MT_SapiGetDevInfo(uint8 *pBuf)
  353. {
  354. uint8 *pRetBuf;
  355. uint8 cmdId;
  356. /* parse header */
  357. cmdId = pBuf[MT_RPC_POS_CMD1];
  358. pBuf += MT_RPC_FRAME_HDR_SZ;
  359. pRetBuf = osal_mem_alloc(Z_EXTADDR_LEN+1);
  360. if (pRetBuf)
  361. {
  362. zb_GetDeviceInfo(pBuf[0], pRetBuf+1);
  363. pRetBuf[0] = pBuf[0];
  364. /* Build and send back the response */
  365. MT_BuildAndSendZToolResponse(((uint8)MT_RPC_CMD_SRSP | (uint8)MT_RPC_SYS_SAPI), cmdId, Z_EXTADDR_LEN+1, pRetBuf );
  366. osal_mem_free(pRetBuf);
  367. }
  368. }
  369. /***************************************************************************************************
  370. * @fn MT_SapiFindDev
  371. *
  372. * @brief Process Find Device Command
  373. *
  374. * @param pBuf - pointer to received buffer
  375. *
  376. * @return none
  377. ***************************************************************************************************/
  378. void MT_SapiFindDev(uint8 *pBuf)
  379. {
  380. uint8 cmdId;
  381. /* parse header */
  382. cmdId = pBuf[MT_RPC_POS_CMD1];
  383. pBuf += MT_RPC_FRAME_HDR_SZ;
  384. /* Currently only supports IEEE search */
  385. zb_FindDeviceRequest(ZB_IEEE_SEARCH, pBuf);
  386. /* Build and send back the response */
  387. MT_BuildAndSendZToolResponse(((uint8)MT_RPC_CMD_SRSP | (uint8)MT_RPC_SYS_SAPI), cmdId, 0, NULL );
  388. }
  389. /***************************************************************************************************
  390. * @fn MT_SapiPermitJoin
  391. *
  392. * @brief Process Permit Join Command
  393. *
  394. * @param pBuf - pointer to received buffer
  395. *
  396. * @return none
  397. ***************************************************************************************************/
  398. void MT_SapiPermitJoin(uint8 *pBuf)
  399. {
  400. uint8 retValue, cmdId;
  401. /* parse header */
  402. cmdId = pBuf[MT_RPC_POS_CMD1];
  403. pBuf += MT_RPC_FRAME_HDR_SZ;
  404. retValue = (zb_PermitJoiningRequest(BUILD_UINT16(pBuf[0], pBuf[1]), pBuf[2]));
  405. /* Build and send back the response */
  406. MT_BuildAndSendZToolResponse(((uint8)MT_RPC_CMD_SRSP | (uint8)MT_RPC_SYS_SAPI), cmdId, 1, &retValue );
  407. }
  408. #endif /* MT_SAPI_FUNC */
  409. #if defined ( MT_SAPI_CB_FUNC )
  410. /***************************************************************************************************
  411. * @fn zb_MTCallbackStartConfirm
  412. *
  413. * @brief Process the callback subscription for zb_StartConfirm
  414. *
  415. * @param Status - status
  416. *
  417. * @return none
  418. ***************************************************************************************************/
  419. void zb_MTCallbackStartConfirm( uint8 status )
  420. {
  421. /* Build and send back the response */
  422. MT_BuildAndSendZToolResponse(((uint8)MT_RPC_CMD_AREQ | (uint8)MT_RPC_SYS_SAPI), MT_SAPI_START_CNF, 1, &status);
  423. }
  424. /***************************************************************************************************
  425. * @fn zb_MTCallbackSendDataConfirm
  426. *
  427. * @brief Process the callback subscription for zb_SendDataConfirm
  428. *
  429. * @param
  430. *
  431. * @return none
  432. ***************************************************************************************************/
  433. void zb_MTCallbackSendDataConfirm(uint8 handle, uint8 status)
  434. {
  435. uint8 retArray[2];
  436. retArray[0] = handle;
  437. retArray[1] = status;
  438. /* Build and send back the response */
  439. MT_BuildAndSendZToolResponse(((uint8)MT_RPC_CMD_AREQ | (uint8)MT_RPC_SYS_SAPI), MT_SAPI_SEND_DATA_CNF, 2, retArray);
  440. }
  441. /***************************************************************************************************
  442. * @fn zb_MTCallbackBindConfirm
  443. *
  444. * @brief Process the callback subscription for zb_BindConfirm
  445. *
  446. * @param
  447. *
  448. * @return none
  449. ***************************************************************************************************/
  450. void zb_MTCallbackBindConfirm( uint16 commandId, uint8 status )
  451. {
  452. uint8 retArray[3];
  453. retArray[0] = LO_UINT16(commandId);
  454. retArray[1] = HI_UINT16(commandId);
  455. retArray[2] = status;
  456. /* Build and send back the response */
  457. MT_BuildAndSendZToolResponse(((uint8)MT_RPC_CMD_AREQ | (uint8)MT_RPC_SYS_SAPI), MT_SAPI_BIND_CNF, 3, retArray);
  458. }
  459. /***************************************************************************************************
  460. * @fn zb_MTCallbackAllowBindConfirm
  461. *
  462. * @brief Indicates when another device attempted to bind to this device
  463. *
  464. * @param
  465. *
  466. * @return none
  467. ***************************************************************************************************/
  468. void zb_MTCallbackAllowBindConfirm( uint16 source )
  469. {
  470. uint8 retArray[2];
  471. retArray[0] = LO_UINT16(source);
  472. retArray[1] = HI_UINT16(source);
  473. /* Build and send back the response */
  474. MT_BuildAndSendZToolResponse(((uint8)MT_RPC_CMD_AREQ | (uint8)MT_RPC_SYS_SAPI), MT_SAPI_ALLOW_BIND_CNF, 3, retArray);
  475. }
  476. /***************************************************************************************************
  477. * @fn zb_MTCallbackFindDeviceConfirm
  478. *
  479. * @brief Process the callback subscription for zb_FindDeviceConfirm
  480. *
  481. * @param
  482. *
  483. * @return none
  484. ***************************************************************************************************/
  485. void zb_MTCallbackFindDeviceConfirm( uint8 searchType, uint8 *searchKey, uint8 *result )
  486. {
  487. uint8 retArray[SPI_CB_SAPI_FIND_DEV_CNF_LEN];
  488. uint16 addr = *((uint16*)searchKey);
  489. // Currently only supports IEEE Addr Search
  490. retArray[0] = ZB_IEEE_SEARCH;
  491. retArray[1] = LO_UINT16(addr);
  492. retArray[2] = HI_UINT16(addr);
  493. osal_memcpy(&retArray[3], result, Z_EXTADDR_LEN);
  494. /* Build and send back the response */
  495. MT_BuildAndSendZToolResponse(((uint8)MT_RPC_CMD_AREQ | (uint8)MT_RPC_SYS_SAPI), MT_SAPI_FIND_DEV_CNF, 11, retArray);
  496. }
  497. /***************************************************************************************************
  498. * @fn zb_MTCallbackReceiveDataIndication
  499. *
  500. * @brief Process the callback subscription for zb_ReceiveDataIndication
  501. *
  502. * @param
  503. *
  504. * @return none
  505. ***************************************************************************************************/
  506. void zb_MTCallbackReceiveDataIndication( uint16 source, uint16 command, uint16 len, uint8 *pData )
  507. {
  508. uint8 *memPtr;
  509. int8 i;
  510. uint8 msgLen = 6 + len;
  511. memPtr = osal_mem_alloc(msgLen);
  512. if (memPtr)
  513. {
  514. memPtr[0] = LO_UINT16(source);
  515. memPtr[1] = HI_UINT16(source);
  516. memPtr[2] = LO_UINT16(command);
  517. memPtr[3] = HI_UINT16(command);
  518. memPtr[4] = LO_UINT16(len);
  519. memPtr[5] = HI_UINT16(len);
  520. for (i=0; i<len; i++)
  521. {
  522. memPtr[6+i] = pData[i];
  523. }
  524. /* Build and send back the response */
  525. MT_BuildAndSendZToolResponse(((uint8)MT_RPC_CMD_AREQ | (uint8)MT_RPC_SYS_SAPI), MT_SAPI_RCV_DATA_IND, msgLen, memPtr);
  526. osal_mem_free( memPtr );
  527. }
  528. }
  529. #endif /* MT_SAPI_CB_FUNC */
  530. /***************************************************************************************************
  531. ***************************************************************************************************/