MT.h 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766
  1. /******************************************************************************
  2. Filename: MT.h
  3. Revised: $Date: 2012-02-14 16:13:32 -0800 (Tue, 14 Feb 2012) $
  4. Revision: $Revision: 29289 $
  5. Description: MonitorTest command and response definitions.
  6. Copyright 2007-2012 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. #ifndef MT_H
  34. #define MT_H
  35. #ifdef __cplusplus
  36. extern "C"
  37. {
  38. #endif
  39. /***************************************************************************************************
  40. * INCLUDES
  41. ***************************************************************************************************/
  42. #include "MT_RPC.h"
  43. #include "ZComDef.h"
  44. /***************************************************************************************************
  45. * MACROS
  46. ***************************************************************************************************/
  47. /***************************************************************************************************
  48. * CONSTANTS
  49. ***************************************************************************************************/
  50. //Special definitions for ZTOOL (Zigbee 0.7 release)
  51. #define ZTEST_DEFAULT_PARAM_LEN 0x10 //( 16 Bytes)
  52. #define ZTEST_DEFAULT_ADDR_LEN 0x08 //( 8 Bytes)
  53. #define ZTEST_DEFAULT_DATA_LEN 0x66 //(102 Bytes)
  54. #define ZTEST_DEFAULT_AF_DATA_LEN 0x20 //( 32 Bytes) - AF
  55. #define ZTEST_DEFAULT_SEC_LEN 0x0B
  56. #define ZTEST_DEFAULT_SEC_PARAM_LEN 0x1C //( 28 Bytes)
  57. /***************************************************************************************************
  58. * SYS COMMANDS
  59. ***************************************************************************************************/
  60. /* AREQ from host */
  61. #define MT_SYS_RESET_REQ 0x00
  62. /* SREQ/SRSP */
  63. #define MT_SYS_PING 0x01
  64. #define MT_SYS_VERSION 0x02
  65. #define MT_SYS_SET_EXTADDR 0x03
  66. #define MT_SYS_GET_EXTADDR 0x04
  67. #define MT_SYS_RAM_READ 0x05
  68. #define MT_SYS_RAM_WRITE 0x06
  69. #define MT_SYS_OSAL_NV_ITEM_INIT 0x07
  70. #define MT_SYS_OSAL_NV_READ 0x08
  71. #define MT_SYS_OSAL_NV_WRITE 0x09
  72. #define MT_SYS_OSAL_START_TIMER 0x0A
  73. #define MT_SYS_OSAL_STOP_TIMER 0x0B
  74. #define MT_SYS_RANDOM 0x0C
  75. #define MT_SYS_ADC_READ 0x0D
  76. #define MT_SYS_GPIO 0x0E
  77. #define MT_SYS_STACK_TUNE 0x0F
  78. #define MT_SYS_SET_TIME 0x10
  79. #define MT_SYS_GET_TIME 0x11
  80. #define MT_SYS_OSAL_NV_DELETE 0x12
  81. #define MT_SYS_OSAL_NV_LENGTH 0x13
  82. #define MT_SYS_SET_TX_POWER 0x14
  83. /* AREQ to host */
  84. #define MT_SYS_RESET_IND 0x80
  85. #define MT_SYS_OSAL_TIMER_EXPIRED 0x81
  86. /***************************************************************************************************
  87. * MAC COMMANDS
  88. ***************************************************************************************************/
  89. /* SREQ/SRSP */
  90. #define MT_MAC_RESET_REQ 0x01
  91. #define MT_MAC_INIT 0x02
  92. #define MT_MAC_START_REQ 0x03
  93. #define MT_MAC_SYNC_REQ 0x04
  94. #define MT_MAC_DATA_REQ 0x05
  95. #define MT_MAC_ASSOCIATE_REQ 0x06
  96. #define MT_MAC_DISASSOCIATE_REQ 0x07
  97. #define MT_MAC_GET_REQ 0x08
  98. #define MT_MAC_SET_REQ 0x09
  99. #define MT_MAC_GTS_REQ 0x0a
  100. #define MT_MAC_RX_ENABLE_REQ 0x0b
  101. #define MT_MAC_SCAN_REQ 0x0c
  102. #define MT_MAC_POLL_REQ 0x0d
  103. #define MT_MAC_PURGE_REQ 0x0e
  104. #define MT_MAC_SET_RX_GAIN_REQ 0x0f
  105. /* Security PIB SREQ */
  106. #define MT_MAC_SECURITY_GET_REQ 0x10
  107. #define MT_MAC_SECURITY_SET_REQ 0x11
  108. /* AREQ from Host */
  109. #define MT_MAC_ASSOCIATE_RSP 0x50
  110. #define MT_MAC_ORPHAN_RSP 0x51
  111. /* AREQ to host */
  112. #define MT_MAC_SYNC_LOSS_IND 0x80
  113. #define MT_MAC_ASSOCIATE_IND 0x81
  114. #define MT_MAC_ASSOCIATE_CNF 0x82
  115. #define MT_MAC_BEACON_NOTIFY_IND 0x83
  116. #define MT_MAC_DATA_CNF 0x84
  117. #define MT_MAC_DATA_IND 0x85
  118. #define MT_MAC_DISASSOCIATE_IND 0x86
  119. #define MT_MAC_DISASSOCIATE_CNF 0x87
  120. #define MT_MAC_GTS_CNF 0x88
  121. #define MT_MAC_GTS_IND 0x89
  122. #define MT_MAC_ORPHAN_IND 0x8a
  123. #define MT_MAC_POLL_CNF 0x8b
  124. #define MT_MAC_SCAN_CNF 0x8c
  125. #define MT_MAC_COMM_STATUS_IND 0x8d
  126. #define MT_MAC_START_CNF 0x8e
  127. #define MT_MAC_RX_ENABLE_CNF 0x8f
  128. #define MT_MAC_PURGE_CNF 0x90
  129. /***************************************************************************************************
  130. * NWK COMMANDS
  131. ***************************************************************************************************/
  132. /* AREQ from host */
  133. #define MT_NWK_INIT 0x00
  134. /* SREQ/SRSP */
  135. #define MT_NLDE_DATA_REQ 0x01
  136. #define MT_NLME_NETWORK_FORMATION_REQ 0x02
  137. #define MT_NLME_PERMIT_JOINING_REQ 0x03
  138. #define MT_NLME_JOIN_REQ 0x04
  139. #define MT_NLME_LEAVE_REQ 0x05
  140. #define MT_NLME_RESET_REQ 0x06
  141. #define MT_NLME_GET_REQ 0x07
  142. #define MT_NLME_SET_REQ 0x08
  143. #define MT_NLME_NETWORK_DISCOVERY_REQ 0x09
  144. #define MT_NLME_ROUTE_DISCOVERY_REQ 0x0A
  145. #define MT_NLME_DIRECT_JOIN_REQ 0x0B
  146. #define MT_NLME_ORPHAN_JOIN_REQ 0x0C
  147. #define MT_NLME_START_ROUTER_REQ 0x0D
  148. /* AREQ to host */
  149. #define MT_NLDE_DATA_CONF 0x80
  150. #define MT_NLDE_DATA_IND 0x81
  151. #define MT_NLME_NETWORK_FORMATION_CONF 0x82
  152. #define MT_NLME_JOIN_CONF 0x83
  153. #define MT_NLME_JOIN_IND 0x84
  154. #define MT_NLME_LEAVE_CONF 0x85
  155. #define MT_NLME_LEAVE_IND 0x86
  156. #define MT_NLME_POLL_CONF 0x87
  157. #define MT_NLME_SYNC_IND 0x88
  158. #define MT_NLME_NETWORK_DISCOVERY_CONF 0x89
  159. #define MT_NLME_START_ROUTER_CONF 0x8A
  160. /***************************************************************************************************
  161. * AF COMMANDS
  162. ***************************************************************************************************/
  163. /* SREQ/SRSP */
  164. #define MT_AF_REGISTER 0x00
  165. #define MT_AF_DATA_REQUEST 0x01 /* AREQ optional, but no AREQ response. */
  166. #define MT_AF_DATA_REQUEST_EXT 0x02 /* AREQ optional, but no AREQ response. */
  167. #define MT_AF_DATA_REQUEST_SRCRTG 0x03
  168. #define MT_AF_INTER_PAN_CTL 0x10
  169. #define MT_AF_DATA_STORE 0x11
  170. #define MT_AF_DATA_RETRIEVE 0x12
  171. #define MT_AF_APSF_CONFIG_SET 0x13
  172. /* AREQ to host */
  173. #define MT_AF_DATA_CONFIRM 0x80
  174. #define MT_AF_INCOMING_MSG 0x81
  175. #define MT_AF_INCOMING_MSG_EXT 0x82
  176. /***************************************************************************************************
  177. * ZDO COMMANDS
  178. ***************************************************************************************************/
  179. /* SREQ/SRSP */
  180. #define MT_ZDO_NWK_ADDR_REQ 0x00
  181. #define MT_ZDO_IEEE_ADDR_REQ 0x01
  182. #define MT_ZDO_NODE_DESC_REQ 0x02
  183. #define MT_ZDO_POWER_DESC_REQ 0x03
  184. #define MT_ZDO_SIMPLE_DESC_REQ 0x04
  185. #define MT_ZDO_ACTIVE_EP_REQ 0x05
  186. #define MT_ZDO_MATCH_DESC_REQ 0x06
  187. #define MT_ZDO_COMPLEX_DESC_REQ 0x07
  188. #define MT_ZDO_USER_DESC_REQ 0x08
  189. #define MT_ZDO_END_DEV_ANNCE 0x0A
  190. #define MT_ZDO_USER_DESC_SET 0x0B
  191. #define MT_ZDO_SERVICE_DISC_REQ 0x0C
  192. #define MT_ZDO_END_DEV_BIND_REQ 0x20
  193. #define MT_ZDO_BIND_REQ 0x21
  194. #define MT_ZDO_UNBIND_REQ 0x22
  195. #define MT_ZDO_SET_LINK_KEY 0x23
  196. #define MT_ZDO_REMOVE_LINK_KEY 0x24
  197. #define MT_ZDO_GET_LINK_KEY 0x25
  198. #define MT_ZDO_NWK_DISCOVERY_REQ 0x26
  199. #define MT_ZDO_JOIN_REQ 0x27
  200. #define MT_ZDO_MGMT_NWKDISC_REQ 0x30
  201. #define MT_ZDO_MGMT_LQI_REQ 0x31
  202. #define MT_ZDO_MGMT_RTG_REQ 0x32
  203. #define MT_ZDO_MGMT_BIND_REQ 0x33
  204. #define MT_ZDO_MGMT_LEAVE_REQ 0x34
  205. #define MT_ZDO_MGMT_DIRECT_JOIN_REQ 0x35
  206. #define MT_ZDO_MGMT_PERMIT_JOIN_REQ 0x36
  207. #define MT_ZDO_MGMT_NWK_UPDATE_REQ 0x37
  208. /* AREQ optional, but no AREQ response. */
  209. #define MT_ZDO_MSG_CB_REGISTER 0x3E
  210. #define MT_ZDO_MSG_CB_REMOVE 0x3F
  211. #define MT_ZDO_STARTUP_FROM_APP 0x40
  212. /* AREQ from host */
  213. #define MT_ZDO_AUTO_FIND_DESTINATION_REQ 0x41
  214. /* AREQ to host */
  215. #define MT_ZDO_AREQ_TO_HOST 0x80 /* Mark the start of the ZDO CId AREQs to host. */
  216. #define MT_ZDO_NWK_ADDR_RSP /* 0x80 */ ((uint8)NWK_addr_req | 0x80)
  217. #define MT_ZDO_IEEE_ADDR_RSP /* 0x81 */ ((uint8)IEEE_addr_req | 0x80)
  218. #define MT_ZDO_NODE_DESC_RSP /* 0x82 */ ((uint8)Node_Desc_req | 0x80)
  219. #define MT_ZDO_POWER_DESC_RSP /* 0x83 */ ((uint8)Power_Desc_req | 0x80)
  220. #define MT_ZDO_SIMPLE_DESC_RSP /* 0x84 */ ((uint8)Simple_Desc_req | 0x80)
  221. #define MT_ZDO_ACTIVE_EP_RSP /* 0x85 */ ((uint8)Active_EP_req | 0x80)
  222. #define MT_ZDO_MATCH_DESC_RSP /* 0x86 */ ((uint8)Match_Desc_req | 0x80)
  223. #define MT_ZDO_COMPLEX_DESC_RSP 0x87
  224. #define MT_ZDO_USER_DESC_RSP 0x88
  225. // /* 0x92 */ ((uint8)Discovery_Cache_req | 0x80)
  226. #define MT_ZDO_USER_DESC_CONF 0x89
  227. #define MT_ZDO_SERVER_DISC_RSP 0x8A
  228. #define MT_ZDO_END_DEVICE_BIND_RSP /* 0xA0 */ ((uint8)End_Device_Bind_req | 0x80)
  229. #define MT_ZDO_BIND_RSP /* 0xA1 */ ((uint8)Bind_req | 0x80)
  230. #define MT_ZDO_UNBIND_RSP /* 0xA2 */ ((uint8)Unbind_req | 0x80)
  231. #define MT_ZDO_MGMT_NWK_DISC_RSP /* 0xB0 */ ((uint8)Mgmt_NWK_Disc_req | 0x80)
  232. #define MT_ZDO_MGMT_LQI_RSP /* 0xB1 */ ((uint8)Mgmt_Lqi_req | 0x80)
  233. #define MT_ZDO_MGMT_RTG_RSP /* 0xB2 */ ((uint8)Mgmt_Rtg_req | 0x80)
  234. #define MT_ZDO_MGMT_BIND_RSP /* 0xB3 */ ((uint8)Mgmt_Bind_req | 0x80)
  235. #define MT_ZDO_MGMT_LEAVE_RSP /* 0xB4 */ ((uint8)Mgmt_Leave_req | 0x80)
  236. #define MT_ZDO_MGMT_DIRECT_JOIN_RSP /* 0xB5 */ ((uint8)Mgmt_Direct_Join_req | 0x80)
  237. #define MT_ZDO_MGMT_PERMIT_JOIN_RSP /* 0xB6 */ ((uint8)Mgmt_Permit_Join_req | 0x80)
  238. // /* 0xB8 */ ((uint8)Mgmt_NWK_Update_req | 0x80)
  239. #define MT_ZDO_STATE_CHANGE_IND 0xC0
  240. #define MT_ZDO_END_DEVICE_ANNCE_IND 0xC1
  241. #define MT_ZDO_MATCH_DESC_RSP_SENT 0xC2
  242. #define MT_ZDO_STATUS_ERROR_RSP 0xC3
  243. #define MT_ZDO_SRC_RTG_IND 0xC4
  244. #define MT_ZDO_BEACON_NOTIFY_IND 0xC5
  245. #define MT_ZDO_JOIN_CNF 0xC6
  246. #define MT_ZDO_NWK_DISCOVERY_CNF 0xC7
  247. #define MT_ZDO_CONCENTRATOR_IND_CB 0xC8
  248. #define MT_ZDO_LEAVE_IND 0xC9
  249. #define MT_ZDO_MSG_CB_INCOMING 0xFF
  250. // Some arbitrarily chosen value for a default error status msg.
  251. #define MtZdoDef_rsp 0x0040
  252. /***************************************************************************************************
  253. * SAPI COMMANDS
  254. ***************************************************************************************************/
  255. // SAPI MT Command Identifiers
  256. /* AREQ from Host */
  257. #define MT_SAPI_SYS_RESET 0x09
  258. /* SREQ/SRSP */
  259. #define MT_SAPI_START_REQ 0x00
  260. #define MT_SAPI_BIND_DEVICE_REQ 0x01
  261. #define MT_SAPI_ALLOW_BIND_REQ 0x02
  262. #define MT_SAPI_SEND_DATA_REQ 0x03
  263. #define MT_SAPI_READ_CFG_REQ 0x04
  264. #define MT_SAPI_WRITE_CFG_REQ 0x05
  265. #define MT_SAPI_GET_DEV_INFO_REQ 0x06
  266. #define MT_SAPI_FIND_DEV_REQ 0x07
  267. #define MT_SAPI_PMT_JOIN_REQ 0x08
  268. #define MT_SAPI_APP_REGISTER_REQ 0x0a
  269. /* AREQ to host */
  270. #define MT_SAPI_START_CNF 0x80
  271. #define MT_SAPI_BIND_CNF 0x81
  272. #define MT_SAPI_ALLOW_BIND_CNF 0x82
  273. #define MT_SAPI_SEND_DATA_CNF 0x83
  274. #define MT_SAPI_READ_CFG_RSP 0x84
  275. #define MT_SAPI_FIND_DEV_CNF 0x85
  276. #define MT_SAPI_DEV_INFO_RSP 0x86
  277. #define MT_SAPI_RCV_DATA_IND 0x87
  278. /***************************************************************************************************
  279. * UTIL COMMANDS
  280. ***************************************************************************************************/
  281. /* SREQ/SRSP: */
  282. #define MT_UTIL_GET_DEVICE_INFO 0x00
  283. #define MT_UTIL_GET_NV_INFO 0x01
  284. #define MT_UTIL_SET_PANID 0x02
  285. #define MT_UTIL_SET_CHANNELS 0x03
  286. #define MT_UTIL_SET_SECLEVEL 0x04
  287. #define MT_UTIL_SET_PRECFGKEY 0x05
  288. #define MT_UTIL_CALLBACK_SUB_CMD 0x06
  289. #define MT_UTIL_KEY_EVENT 0x07
  290. #define MT_UTIL_TIME_ALIVE 0x09
  291. #define MT_UTIL_LED_CONTROL 0x0A
  292. #define MT_UTIL_TEST_LOOPBACK 0x10
  293. #define MT_UTIL_DATA_REQ 0x11
  294. #define MT_UTIL_SRC_MATCH_ENABLE 0x20
  295. #define MT_UTIL_SRC_MATCH_ADD_ENTRY 0x21
  296. #define MT_UTIL_SRC_MATCH_DEL_ENTRY 0x22
  297. #define MT_UTIL_SRC_MATCH_CHECK_SRC_ADDR 0x23
  298. #define MT_UTIL_SRC_MATCH_ACK_ALL_PENDING 0x24
  299. #define MT_UTIL_SRC_MATCH_CHECK_ALL_PENDING 0x25
  300. #define MT_UTIL_ADDRMGR_EXT_ADDR_LOOKUP 0x40
  301. #define MT_UTIL_ADDRMGR_NWK_ADDR_LOOKUP 0x41
  302. #define MT_UTIL_APSME_LINK_KEY_DATA_GET 0x44
  303. #define MT_UTIL_APSME_LINK_KEY_NV_ID_GET 0x45
  304. #define MT_UTIL_ASSOC_COUNT 0x48
  305. #define MT_UTIL_ASSOC_FIND_DEVICE 0x49
  306. #define MT_UTIL_ASSOC_GET_WITH_ADDRESS 0x4A
  307. #define MT_UTIL_APSME_REQUEST_KEY_CMD 0x4B
  308. #define MT_UTIL_ZCL_KEY_EST_INIT_EST 0x80
  309. #define MT_UTIL_ZCL_KEY_EST_SIGN 0x81
  310. /* AREQ from/to host */
  311. #define MT_UTIL_SYNC_REQ 0xE0
  312. #define MT_UTIL_ZCL_KEY_ESTABLISH_IND 0xE1
  313. /***************************************************************************************************
  314. * DEBUG COMMANDS
  315. ***************************************************************************************************/
  316. /* SREQ/SRSP: */
  317. #define MT_DEBUG_SET_THRESHOLD 0x00
  318. #define MT_DEBUG_MAC_DATA_DUMP 0x10
  319. /* AREQ */
  320. #define MT_DEBUG_MSG 0x80
  321. /***************************************************************************************************
  322. * APP COMMANDS
  323. ***************************************************************************************************/
  324. /* SREQ/SRSP: */
  325. #define MT_APP_MSG 0x00
  326. #define MT_APP_USER_TEST 0x01
  327. /* SRSP */
  328. #define MT_APP_RSP 0x80
  329. /***************************************************************************************************
  330. * FILE SYSTEM COMMANDS
  331. ***************************************************************************************************/
  332. #define MT_OTA_FILE_READ_REQ 0x00
  333. #define MT_OTA_NEXT_IMG_REQ 0x01
  334. #define MT_OTA_FILE_READ_RSP 0x80
  335. #define MT_OTA_NEXT_IMG_RSP 0x81
  336. #define MT_OTA_STATUS_IND 0x82
  337. /*
  338. * Definitions to allow conditional compiling -
  339. * To use these in an embedded environment include them as a compiler
  340. * option (ex. "-DMT_NWK_FUNC" )
  341. */
  342. /* Task Event IDs - bit masks */
  343. #define MT_ZTOOL_SERIAL_RCV_CHAR 0x0001
  344. #define MT_ZTOOL_SERIAL_RCV_BUFFER_FULL 0x0002
  345. #define MT_SERIAL_ZTOOL_XMT_READY 0x0004
  346. #define MT_ZAPP_SERIAL_RCV_CHAR MT_ZTOOL_SERIAL_RCV_CHAR
  347. #define MT_ZAPP_SERIAL_RCV_BUFFER_FULL MT_ZTOOL_SERIAL_RCV_BUFFER_FULL
  348. #define MT_SERIAL_ZAPP_XMT_READY MT_SERIAL_ZTOOL_XMT_READY
  349. #define MT_AF_EXEC_EVT 0x0008
  350. #define MT_SECONDARY_INIT_EVENT 0x0010
  351. #define MT_MSG_SEQUENCE_EVT 0x0040
  352. #define MT_KEYPRESS_POLL_EVT 0x0080
  353. /* SYS_OSAL_EVENT ID's */
  354. #define MT_SYS_OSAL_EVENT_0 0x0800
  355. #define MT_SYS_OSAL_EVENT_1 0x0400
  356. #define MT_SYS_OSAL_EVENT_2 0x0200
  357. #define MT_SYS_OSAL_EVENT_3 0x0100
  358. #define MT_SYS_OSAL_EVENT_MASK (MT_SYS_OSAL_EVENT_0 | MT_SYS_OSAL_EVENT_1 | \
  359. MT_SYS_OSAL_EVENT_2 | MT_SYS_OSAL_EVENT_3)
  360. /* Message Command IDs */
  361. #define CMD_SERIAL_MSG 0x01
  362. #define CMD_DEBUG_MSG 0x02
  363. #define CMD_TX_MSG 0x03
  364. #define CB_FUNC 0x04
  365. #define CMD_SEQUENCE_MSG 0x05
  366. #define CMD_DEBUG_STR 0x06
  367. #define AF_INCOMING_MSG_FOR_MT 0x0F
  368. /* Error Response IDs */
  369. #define UNRECOGNIZED_COMMAND 0x00
  370. #define UNSUPPORTED_COMMAND 0x01
  371. #define RECEIVE_BUFFER_FULL 0x02
  372. /* Serial Message Command IDs */
  373. #define SPI_CMD_DEBUG_MSG 0x4003
  374. #define SPI_CMD_TRACE_SUB 0x0004
  375. #define SPI_CMD_TRACE_MSG 0x4004
  376. /* User CMD IDs */
  377. #define SPI_CMD_USER0 0x000A
  378. #define SPI_CMD_USER1 0x000B
  379. #define SPI_CMD_USER2 0x000C
  380. #define SPI_CMD_USER3 0x000D
  381. #define SPI_CMD_USER4 0x000E
  382. #define SPI_CMD_USER5 0x000F
  383. #define SPI_SYS_STRING_MSG 0x0015
  384. #define SPI_CMD_SYS_NETWORK_START 0x0020
  385. #define SPI_CMD_ZIGNET_DATA 0x0022
  386. /* system command response */
  387. #define SPI_CB_SYS_CALLBACK_SUB_RSP 0x1006
  388. #define SPI_CB_SYS_PING_RSP 0x1007
  389. #define SPI_CB_SYS_GET_DEVICE_INFO_RSP 0x1014
  390. #define SPI_CB_SYS_KEY_EVENT_RSP 0x1016
  391. #define SPI_CB_SYS_HEARTBEAT_RSP 0x1017
  392. #define SPI_CB_SYS_LED_CONTROL_RSP 0x1019
  393. /* Message Sequence definitions */
  394. #define SPI_CMD_SEQ_START 0x0600
  395. #define SPI_CMD_SEQ_WAIT 0x0601
  396. #define SPI_CMD_SEQ_END 0x0602
  397. #define SPI_CMD_SEQ_RESET 0x0603
  398. #define DEFAULT_WAIT_INTERVAL 5000 //5 seconds
  399. /* Serial Message Command Routing Bits */
  400. #define SPI_RESPONSE_BIT 0x1000
  401. #define SPI_SUBSCRIPTION_BIT 0x2000
  402. #define SPI_DEBUGTRACE_BIT 0x4000
  403. #define SPI_0DATA_MSG_LEN 5
  404. #define SPI_RESP_MSG_LEN_DEFAULT 6
  405. #define LEN_MAC_BEACON_MSDU 15
  406. #define LEN_MAC_COORDEXTND_ADDR 8
  407. #define LEN_MAC_ATTR_BYTE 1
  408. #define LEN_MAC_ATTR_INT 2
  409. #define SOP_FIELD 0
  410. #define CMD_FIELD_HI 1
  411. #define CMD_FIELD_LO 2
  412. #define DATALEN_FIELD 3
  413. #define DATA_BEGIN 4
  414. /* MT PACKET (For Test Tool): FIELD IDENTIFIERS */
  415. #define MT_MAC_CB_ID 0
  416. #define MT_OFFSET 1
  417. #define MT_SOP_FIELD MT_OFFSET + SOP_FIELD
  418. #define MT_CMD_FIELD_HI MT_OFFSET + CMD_FIELD_HI
  419. #define MT_CMD_FIELD_LO MT_OFFSET + CMD_FIELD_LO
  420. #define MT_DATALEN_FIELD MT_OFFSET + DATALEN_FIELD
  421. #define MT_DATA_BEGIN MT_OFFSET + DATA_BEGIN
  422. #define MT_INFO_HEADER_LEN 1
  423. #define MT_RAM_READ_RESP_LEN 0x02
  424. #define MT_RAM_WRITE_RESP_LEN 0x01
  425. /* Defines for the fields in the AF structures */
  426. #define AF_INTERFACE_BITS 0x07
  427. #define AF_INTERFACE_OFFSET 0x05
  428. #define AF_APP_DEV_VER_MASK 0x0F
  429. #define AF_APP_FLAGS_MASK 0x0F
  430. #define AF_TRANSTYPE_MASK 0x0F
  431. #define AF_TRANSDATATYPE_MASK 0x0F
  432. #define TGEN_START 0x000a
  433. #define TGEN_STOP 0x000b
  434. #define TGEN_COUNT 0x000c
  435. #define DEBUG_GET 0x000d
  436. #define HW_TEST 0x000e
  437. #define HW_DISPLAY_RESULT 0x000f
  438. #define HW_SEND_STATUS 0x0010
  439. #if defined( APP_TP ) || defined ( APP_TP2 )
  440. #if defined( APP_TP )
  441. #define TP_SEND_NODATA 0x0011
  442. #else
  443. #define TP_SEND_BCAST_RSP 0x0011
  444. #endif
  445. #define TP_SEND_BUFFERTEST 0x0012
  446. #if defined (APP_TP)
  447. #define TP_SEND_UINT8 0x0013
  448. #define TP_SEND_INT8 0x0014
  449. #define TP_SEND_UINT16 0x0015
  450. #define TP_SEND_INT16 0x0016
  451. #define TP_SEND_SEMIPREC 0x0017
  452. #endif
  453. #define TP_SEND_FREEFORM 0x0018
  454. #if defined( APP_TP )
  455. #define TP_SEND_ABS_TIME 0x0019
  456. #define TP_SEND_REL_TIME 0x001A
  457. #define TP_SEND_CHAR_STRING 0x001B
  458. #define TP_SEND_OCTET_STRING 0x001C
  459. #endif
  460. #define TP_SET_DSTADDRESS 0x001D
  461. #if defined( APP_TP2 )
  462. #define TP_SEND_BUFFER_GROUP 0x001E
  463. #endif
  464. #define TP_SEND_BUFFER 0x001F
  465. #if defined( APP_TP )
  466. #define TP_SEND_CON_INT8 0x0020
  467. #define TP_SEND_CON_INT16 0x0021
  468. #define TP_SEND_CON_TIME 0x0022
  469. #define TP_SEND_MULT_KVP_8BIT 0x0023
  470. #define TP_SEND_MULT_KVP_16BIT 0x0024
  471. #define TP_SEND_MULT_KVP_TIME 0x0025
  472. #define TP_SEND_MULT_KVP_STRING 0x0026
  473. #endif
  474. #define TP_SEND_COUNTED_PKTS 0x0027
  475. #define TP_SEND_RESET_COUNTER 0x0028
  476. #define TP_SEND_GET_COUNTER 0x0029
  477. #if defined( APP_TP )
  478. #define TP_SEND_MULTI_KVP_STR_TIME 0x0030
  479. #endif
  480. #define TP_SET_PERMIT_JOIN 0x0040
  481. #define TP_ADD_GROUP 0x0041
  482. #define TP_REMOVE_GROUP 0x0042
  483. #define TP_SEND_UPDATE_KEY 0x0043
  484. #define TP_SEND_SWITCH_KEY 0x0044
  485. #if defined( APP_TP2 )
  486. #define TP_SEND_BUFFERTEST_GROUP 0x0045
  487. #define TP_SEND_ROUTE_DISC_REQ 0x0046
  488. #define TP_SEND_ROUTE_DISCOVERY 0x0047
  489. #define TP_SEND_NEW_ADDR 0x0048
  490. #define TP_SEND_NWK_UPDATE 0x0049
  491. #define TP_AK_SETUP_PARTNER 0x0050
  492. #define TP_AK_REQ_KEY 0x0051
  493. #define TP_AK_PARTNER_NWKADDR 0x0052
  494. #define TP_AK_PARTNER_EXTADDR7654 0x0053
  495. #define TP_AK_PARTNER_EXTADDR3210 0x0054
  496. #define TP_AK_PARTNER_SET 0x0055
  497. #define TP_AK_TYPE_SET 0x0056
  498. #define TP_FRAG_SKIP_BLOCK 0x0057
  499. #define TP_APS_REMOVE 0x0058
  500. #define TP_NWK_ADDR_CONFLICT 0x0059
  501. #endif
  502. #endif
  503. #if defined ( OSAL_TOTAL_MEM )
  504. #define OSAL_MEM_STACK_HIGH_WATER 0x0100
  505. #define OSAL_MEM_HEAP_HIGH_WATER 0x0101
  506. #endif
  507. /* Capabilities - PING Response */
  508. #if defined (MT_SYS_FUNC)
  509. #define MT_CAP_SYS 0x0001
  510. #else
  511. #define MT_CAP_SYS 0x0000
  512. #endif
  513. #if defined ( MT_MAC_FUNC )
  514. #define MT_CAP_MAC 0x0002
  515. #else
  516. #define MT_CAP_MAC 0x0000
  517. #endif
  518. #if defined ( MT_NWK_FUNC )
  519. #define MT_CAP_NWK 0x0004
  520. #else
  521. #define MT_CAP_NWK 0x0000
  522. #endif
  523. #if defined ( MT_AF_FUNC )
  524. #define MT_CAP_AF 0x0008
  525. #else
  526. #define MT_CAP_AF 0x0000
  527. #endif
  528. #if defined ( MT_ZDO_FUNC )
  529. #define MT_CAP_ZDO 0x0010
  530. #else
  531. #define MT_CAP_ZDO 0x0000
  532. #endif
  533. #if defined ( MT_SAPI_FUNC )
  534. #define MT_CAP_SAPI 0x0020
  535. #else
  536. #define MT_CAP_SAPI 0x0000
  537. #endif
  538. #if defined ( MT_UTIL_FUNC )
  539. #define MT_CAP_UTIL 0x0040
  540. #else
  541. #define MT_CAP_UTIL 0x0000
  542. #endif
  543. #if defined ( MT_DEBUG_FUNC )
  544. #define MT_CAP_DEBUG 0x0080
  545. #else
  546. #define MT_CAP_DEBUG 0x0000
  547. #endif
  548. #if defined ( MT_APP_FUNC )
  549. #define MT_CAP_APP 0x0100
  550. #else
  551. #define MT_CAP_APP 0x0000
  552. #endif
  553. #if defined ( ZPORT )
  554. #define MT_CAP_ZOAD 0x1000
  555. #else
  556. #define MT_CAP_ZOAD 0x0000
  557. #endif
  558. /* ZNP NV items, 1-4 2-bytes each, 5-6 16-bytes each */
  559. #define ZNP_NV_APP_ITEM_1 0x0F01
  560. #define ZNP_NV_APP_ITEM_2 0x0F02
  561. #define ZNP_NV_APP_ITEM_3 0x0F03
  562. #define ZNP_NV_APP_ITEM_4 0x0F04
  563. #define ZNP_NV_APP_ITEM_5 0x0F05
  564. #define ZNP_NV_APP_ITEM_6 0x0F06
  565. #define ZNP_NV_RF_TEST_PARMS 0x0F07
  566. /***************************************************************************************************
  567. * TYPEDEFS
  568. ***************************************************************************************************/
  569. typedef struct {
  570. uint16 waitInterval;
  571. byte *msg;
  572. void *next;
  573. } MT_msg_queue_t;
  574. /***************************************************************************************************
  575. * GLOBAL VARIABLES
  576. ***************************************************************************************************/
  577. extern byte MT_TaskID;
  578. extern byte debugThreshold;
  579. extern byte debugCompId;
  580. extern byte queueMsgs;
  581. extern MT_msg_queue_t *_pMtMsgQueue;
  582. extern MT_msg_queue_t *_pLastInQueue;
  583. extern MT_msg_queue_t *_pCurQueueElem;
  584. /*
  585. * Build and send a ZTool response message
  586. */
  587. extern void MT_BuildAndSendZToolResponse(uint8 cmdType, uint8 cmdId, uint8 dataLen, uint8 *dataPtr);
  588. /*
  589. * MonitorTest Format an SPI Message
  590. */
  591. extern void MT_BuildSPIMsg( uint8 cmdType, uint8 cmdId, byte *msg, byte dataLen, byte *dataPtr );
  592. /*
  593. * Temp test function
  594. */
  595. extern void MT_ProcessUserCmd( byte cmd );
  596. /*
  597. * MonitorTest function handling PhY commands
  598. */
  599. extern void MT_RadioCommandProcessing( uint16 cmd_id , byte len , byte *pData );
  600. /*
  601. * MonitorTest function handling PhY commands
  602. */
  603. extern void MT_PhyCommandProcessing( uint16 cmd_id , byte len , byte *pData );
  604. /*
  605. * MonitorTest function to copy a uint16 array to a byte array, little endian.
  606. */
  607. extern uint8 *MT_Word2Buf( uint8 *pBuf, uint16 *pWord, uint8 len );
  608. /*
  609. * MonitorTest function to reverse bytes in a buffer
  610. */
  611. extern void MT_ReverseBytes( byte *pData, byte len );
  612. /*
  613. * Process App Response Msg
  614. */
  615. extern void MTProcessAppRspMsg(byte *pData, byte len);
  616. /*
  617. * Secondary initialization of MT.
  618. */
  619. extern void MT_Init(void);
  620. /*
  621. * Process incoming commands
  622. */
  623. extern void MT_ProcessIncoming(uint8 *pBuf);
  624. /*
  625. * Callback function to allocate message buffer
  626. */
  627. extern uint8 *MT_TransportAlloc(uint8 cmd0, uint8 len);
  628. /*
  629. * Callback function to send message buffer
  630. */
  631. extern void MT_TransportSend(uint8 *pBuf);
  632. /*
  633. * Utility function to build endpoint descriptor from incoming buffer
  634. */
  635. extern uint8 MT_BuildEndpointDesc( uint8 *pBuf, void *param );
  636. /***************************************************************************************************
  637. ***************************************************************************************************/
  638. #ifdef __cplusplus
  639. }
  640. #endif
  641. #endif