MT.h 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687
  1. /*********************************************************************
  2. Filename: MT.h
  3. Revised: $Date: 2008-10-09 11:19:54 -0700 (Thu, 09 Oct 2008) $
  4. Revision: $Revision: 18246 $
  5. Description: MonitorTest Event Loop functions. Everything in the
  6. MonitorTest Task (except the serial driver).
  7. Copyright 2007 Texas Instruments Incorporated. All rights reserved.
  8. IMPORTANT: Your use of this Software is limited to those specific rights
  9. granted under the terms of a software license agreement between the user
  10. who downloaded the software, his/her employer (which must be your employer)
  11. and Texas Instruments Incorporated (the "License"). You may not use this
  12. Software unless you agree to abide by the terms of the License. The License
  13. limits your use, and you acknowledge, that the Software may not be modified,
  14. copied or distributed unless embedded on a Texas Instruments microcontroller
  15. or used solely and exclusively in conjunction with a Texas Instruments radio
  16. frequency transceiver, which is integrated into your product. Other than for
  17. the foregoing purpose, you may not use, reproduce, copy, prepare derivative
  18. works of, modify, distribute, perform, display or sell this Software and/or
  19. its documentation for any purpose.
  20. YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
  21. PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
  22. INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
  23. NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
  24. TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
  25. NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
  26. LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
  27. INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
  28. OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
  29. OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
  30. (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
  31. Should you have any questions regarding your right to use this Software,
  32. contact Texas Instruments Incorporated at www.TI.com.
  33. *********************************************************************/
  34. #ifndef MT_H
  35. #define MT_H
  36. #ifdef __cplusplus
  37. extern "C"
  38. {
  39. #endif
  40. /***************************************************************************************************
  41. * INCLUDES
  42. ***************************************************************************************************/
  43. #include "MT_RPC.h"
  44. #include "ZComDef.h"
  45. /***************************************************************************************************
  46. * MACROS
  47. ***************************************************************************************************/
  48. /***************************************************************************************************
  49. * CONSTANTS
  50. ***************************************************************************************************/
  51. //Special definitions for ZTOOL (Zigbee 0.7 release)
  52. #define ZTEST_DEFAULT_PARAM_LEN 0x10 //( 16 Bytes)
  53. #define ZTEST_DEFAULT_ADDR_LEN 0x08 //( 8 Bytes)
  54. #define ZTEST_DEFAULT_DATA_LEN 0x66 //(102 Bytes) - MAC,NWK
  55. #define ZTEST_DEFAULT_AF_DATA_LEN 0x20 //( 32 Bytes) - AF
  56. #define ZTEST_DEFAULT_SEC_LEN 0x0B
  57. /***************************************************************************************************
  58. * SYS COMMANDS
  59. ***************************************************************************************************/
  60. /* AQREQ 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. /* AREQ to host */
  78. #define MT_SYS_RESET_IND 0x80
  79. #define MT_SYS_OSAL_TIMER_EXPIRED 0x81
  80. /***************************************************************************************************
  81. * MAC COMMANDS
  82. ***************************************************************************************************/
  83. /* SREQ/SRSP */
  84. #define MT_MAC_RESET_REQ 0x01
  85. #define MT_MAC_INIT 0x02
  86. #define MT_MAC_START_REQ 0x03
  87. #define MT_MAC_SYNC_REQ 0x04
  88. #define MT_MAC_DATA_REQ 0x05
  89. #define MT_MAC_ASSOCIATE_REQ 0x06
  90. #define MT_MAC_DISASSOCIATE_REQ 0x07
  91. #define MT_MAC_GET_REQ 0x08
  92. #define MT_MAC_SET_REQ 0x09
  93. #define MT_MAC_GTS_REQ 0x0a
  94. #define MT_MAC_RX_ENABLE_REQ 0x0b
  95. #define MT_MAC_SCAN_REQ 0x0c
  96. #define MT_MAC_POLL_REQ 0x0d
  97. #define MT_MAC_PURGE_REQ 0x0e
  98. #define MT_MAC_SET_RX_GAIN_REQ 0x0f
  99. #define MT_MAC_SRC_MATCH_ENABLE 0x10
  100. #define MT_MAC_SRC_MATCH_ADD_ENTRY 0x11
  101. #define MT_MAC_SRC_MATCH_DEL_ENTRY 0x12
  102. #define MT_MAC_SRC_MATCH_CHECK_SRC_ADDR 0x13
  103. #define MT_MAC_SRC_MATCH_ACK_ALL_PENDING 0x14
  104. #define MT_MAC_SRC_MATCH_CHECK_ALL_PENDING 0x15
  105. /* AREQ from Host */
  106. #define MT_MAC_ASSOCIATE_RSP 0x50
  107. #define MT_MAC_ORPHAN_RSP 0x51
  108. /* AREQ to host */
  109. #define MT_MAC_SYNC_LOSS_IND 0x80
  110. #define MT_MAC_ASSOCIATE_IND 0x81
  111. #define MT_MAC_ASSOCIATE_CNF 0x82
  112. #define MT_MAC_BEACON_NOTIFY_IND 0x83
  113. #define MT_MAC_DATA_CNF 0x84
  114. #define MT_MAC_DATA_IND 0x85
  115. #define MT_MAC_DISASSOCIATE_IND 0x86
  116. #define MT_MAC_DISASSOCIATE_CNF 0x87
  117. #define MT_MAC_GTS_CNF 0x88
  118. #define MT_MAC_GTS_IND 0x89
  119. #define MT_MAC_ORPHAN_IND 0x8a
  120. #define MT_MAC_POLL_CNF 0x8b
  121. #define MT_MAC_SCAN_CNF 0x8c
  122. #define MT_MAC_COMM_STATUS_IND 0x8d
  123. #define MT_MAC_START_CNF 0x8e
  124. #define MT_MAC_RX_ENABLE_CNF 0x8f
  125. #define MT_MAC_PURGE_CNF 0x90
  126. /***************************************************************************************************
  127. * NWK COMMANDS
  128. ***************************************************************************************************/
  129. /* AREQ from host */
  130. #define MT_NWK_INIT 0x00
  131. /* SREQ/SRSP */
  132. #define MT_NLDE_DATA_REQ 0x01
  133. #define MT_NLME_NETWORK_FORMATION_REQ 0x02
  134. #define MT_NLME_PERMIT_JOINING_REQ 0x03
  135. #define MT_NLME_JOIN_REQ 0x04
  136. #define MT_NLME_LEAVE_REQ 0x05
  137. #define MT_NLME_RESET_REQ 0x06
  138. #define MT_NLME_GET_REQ 0x07
  139. #define MT_NLME_SET_REQ 0x08
  140. #define MT_NLME_NETWORK_DISCOVERY_REQ 0x09
  141. #define MT_NLME_ROUTE_DISCOVERY_REQ 0x0A
  142. #define MT_NLME_DIRECT_JOIN_REQ 0x0B
  143. #define MT_NLME_ORPHAN_JOIN_REQ 0x0C
  144. #define MT_NLME_START_ROUTER_REQ 0x0D
  145. /* AREQ to host */
  146. #define MT_NLDE_DATA_CONF 0x80
  147. #define MT_NLDE_DATA_IND 0x81
  148. #define MT_NLME_NETWORK_FORMATION_CONF 0x82
  149. #define MT_NLME_JOIN_CONF 0x83
  150. #define MT_NLME_JOIN_IND 0x84
  151. #define MT_NLME_LEAVE_CONF 0x85
  152. #define MT_NLME_LEAVE_IND 0x86
  153. #define MT_NLME_POLL_CONF 0x87
  154. #define MT_NLME_SYNC_IND 0x88
  155. #define MT_NLME_NETWORK_DISCOVERY_CONF 0x89
  156. #define MT_NLME_START_ROUTER_CONF 0x8A
  157. /***************************************************************************************************
  158. * AF COMMANDS
  159. ***************************************************************************************************/
  160. /* SREQ/SRSP */
  161. #define MT_AF_REGISTER 0x00
  162. #define MT_AF_DATA_REQUEST 0x01
  163. /* AREQ to host */
  164. #define MT_AF_DATA_CONFIRM 0x80
  165. #define MT_AF_INCOMING_MSG 0x81
  166. /***************************************************************************************************
  167. * ZDO COMMANDS
  168. ***************************************************************************************************/
  169. /* SREQ/SRSP */
  170. #define MT_ZDO_NWK_ADDR_REQ 0x00
  171. #define MT_ZDO_IEEE_ADDR_REQ 0x01
  172. #define MT_ZDO_NODE_DESC_REQ 0x02
  173. #define MT_ZDO_POWER_DESC_REQ 0x03
  174. #define MT_ZDO_SIMPLE_DESC_REQ 0x04
  175. #define MT_ZDO_ACTIVE_EP_REQ 0x05
  176. #define MT_ZDO_MATCH_DESC_REQ 0x06
  177. #define MT_ZDO_COMPLEX_DESC_REQ 0x07
  178. #define MT_ZDO_USER_DESC_REQ 0x08
  179. #define MT_ZDO_END_DEV_ANNCE 0x0A
  180. #define MT_ZDO_USER_DESC_SET 0x0B
  181. #define MT_ZDO_SERVICE_DISC_REQ 0x0C
  182. #define MT_ZDO_END_DEV_BIND_REQ 0x20
  183. #define MT_ZDO_BIND_REQ 0x21
  184. #define MT_ZDO_UNBIND_REQ 0x22
  185. #define MT_ZDO_MGMT_NWKDISC_REQ 0x30
  186. #define MT_ZDO_MGMT_LQI_REQ 0x31
  187. #define MT_ZDO_MGMT_RTG_REQ 0x32
  188. #define MT_ZDO_MGMT_BIND_REQ 0x33
  189. #define MT_ZDO_MGMT_LEAVE_REQ 0x34
  190. #define MT_ZDO_MGMT_DIRECT_JOIN_REQ 0x35
  191. #define MT_ZDO_MGMT_PERMIT_JOIN_REQ 0x36
  192. #define MT_ZDO_MGMT_NWK_UPDATE_REQ 0x37
  193. #define MT_ZDO_STARTUP_FROM_APP 0x40
  194. /* AREQ from host */
  195. #define MT_ZDO_AUTO_FIND_DESTINATION_REQ 0x41
  196. #define MT_ZDO_AUTO_ENDDEVICEBIND_REQ 0x42
  197. /* AREQ to host */
  198. #define MT_ZDO_NWK_ADDR_RSP 0x80
  199. #define MT_ZDO_IEEE_ADDR_RSP 0x81
  200. #define MT_ZDO_NODE_DESC_RSP 0x82
  201. #define MT_ZDO_POWER_DESC_RSP 0x83
  202. #define MT_ZDO_SIMPLE_DESC_RSP 0x84
  203. #define MT_ZDO_ACTIVE_EP_RSP 0x85
  204. #define MT_ZDO_MATCH_DESC_RSP 0x86
  205. #define MT_ZDO_COMPLEX_DESC_RSP 0x87
  206. #define MT_ZDO_USER_DESC_RSP 0x88
  207. #define MT_ZDO_USER_DESC_CONF 0x89
  208. #define MT_ZDO_SERVER_DISC_RSP 0x8A
  209. #define MT_ZDO_END_DEVICE_BIND_RSP 0xA0
  210. #define MT_ZDO_BIND_RSP 0xA1
  211. #define MT_ZDO_UNBIND_RSP 0xA2
  212. #define MT_ZDO_MGMT_NWK_DISC_RSP 0xB0
  213. #define MT_ZDO_MGMT_LQI_RSP 0xB1
  214. #define MT_ZDO_MGMT_RTG_RSP 0xB2
  215. #define MT_ZDO_MGMT_BIND_RSP 0xB3
  216. #define MT_ZDO_MGMT_LEAVE_RSP 0xB4
  217. #define MT_ZDO_MGMT_DIRECT_JOIN_RSP 0xB5
  218. #define MT_ZDO_MGMT_PERMIT_JOIN_RSP 0xB6
  219. #define MT_ZDO_STATE_CHANGE_IND 0xC0
  220. #define MT_ZDO_END_DEVICE_ANNCE_IND 0xC1
  221. #define MT_ZDO_MATCH_DESC_RSP_SENT 0xC2
  222. #define MT_ZDO_STATUS_ERROR_RSP 0xC3
  223. /***************************************************************************************************
  224. * SAPI COMMANDS
  225. ***************************************************************************************************/
  226. // SAPI MT Command Identifiers
  227. /* AREQ from Host */
  228. #define MT_SAPI_SYS_RESET 0x09
  229. /* SREQ/SRSP */
  230. #define MT_SAPI_START_REQ 0x00
  231. #define MT_SAPI_BIND_DEVICE_REQ 0x01
  232. #define MT_SAPI_ALLOW_BIND_REQ 0x02
  233. #define MT_SAPI_SEND_DATA_REQ 0x03
  234. #define MT_SAPI_READ_CFG_REQ 0x04
  235. #define MT_SAPI_WRITE_CFG_REQ 0x05
  236. #define MT_SAPI_GET_DEV_INFO_REQ 0x06
  237. #define MT_SAPI_FIND_DEV_REQ 0x07
  238. #define MT_SAPI_PMT_JOIN_REQ 0x08
  239. #define MT_SAPI_APP_REGISTER_REQ 0x0a
  240. /* AREQ to host */
  241. #define MT_SAPI_START_CNF 0x80
  242. #define MT_SAPI_BIND_CNF 0x81
  243. #define MT_SAPI_ALLOW_BIND_CNF 0x82
  244. #define MT_SAPI_SEND_DATA_CNF 0x83
  245. #define MT_SAPI_READ_CFG_RSP 0x84
  246. #define MT_SAPI_FIND_DEV_CNF 0x85
  247. #define MT_SAPI_DEV_INFO_RSP 0x86
  248. #define MT_SAPI_RCV_DATA_IND 0x87
  249. /***************************************************************************************************
  250. * UTIL COMMANDS
  251. ***************************************************************************************************/
  252. /* SREQ/SRSP: */
  253. #define MT_UTIL_GET_DEVICE_INFO 0x00
  254. #define MT_UTIL_GET_NV_INFO 0x01
  255. #define MT_UTIL_SET_PANID 0x02
  256. #define MT_UTIL_SET_CHANNELS 0x03
  257. #define MT_UTIL_SET_SECLEVEL 0x04
  258. #define MT_UTIL_SET_PRECFGKEY 0x05
  259. #define MT_UTIL_CALLBACK_SUB_CMD 0x06
  260. #define MT_UTIL_KEY_EVENT 0x07
  261. #define MT_UTIL_HEARTBEAT 0x08
  262. #define MT_UTIL_TIME_ALIVE 0x09
  263. #define MT_UTIL_LED_CONTROL 0x0A
  264. /***************************************************************************************************
  265. * DEBUG COMMANDS
  266. ***************************************************************************************************/
  267. /* SREQ/SRSP: */
  268. #define MT_DEBUG_SET_THRESHOLD 0x00
  269. /* AREQ */
  270. #define MT_DEBUG_MSG 0x80
  271. /***************************************************************************************************
  272. * APP COMMANDS
  273. ***************************************************************************************************/
  274. /* SREQ/SRSP: */
  275. #define MT_APP_MSG 0x00
  276. #define MT_APP_USER_TEST 0x01
  277. /* SRSP */
  278. #define MT_APP_RSP 0x80
  279. /*
  280. * Definitions to allow conditional compiling -
  281. * To use these in an embedded environment include them as a compiler
  282. * option (ex. "-DMT_NWK_FUNC" )
  283. */
  284. /* Task Event IDs - bit masks */
  285. #define MT_ZTOOL_SERIAL_RCV_CHAR 0x0001
  286. #define MT_ZAPP_SERIAL_RCV_CHAR 0x0002
  287. #define MT_ZTOOL_SERIAL_RCV_BUFFER_FULL 0x0004
  288. #define MT_ZAPP_SERIAL_RCV_BUFFER_FULL 0x0008
  289. #define MT_SERIAL_ZTOOL_XMT_READY 0x0010
  290. #define MT_SERIAL_ZAPP_XMT_READY 0x0020
  291. #define MT_MSG_SEQUENCE_EVT 0x0040
  292. #define MT_KEYPRESS_POLL_EVT 0x0080
  293. /* Message Command IDs */
  294. #define CMD_SERIAL_MSG 0x01
  295. #define CMD_DEBUG_MSG 0x02
  296. #define CMD_TX_MSG 0x03
  297. #define CB_FUNC 0x04
  298. #define CMD_SEQUENCE_MSG 0x05
  299. #define CMD_DEBUG_STR 0x06
  300. #define AF_INCOMING_MSG_FOR_MT 0x0F
  301. /* Error Response IDs */
  302. #define UNRECOGNIZED_COMMAND 0x00
  303. #define UNSUPPORTED_COMMAND 0x01
  304. #define RECEIVE_BUFFER_FULL 0x02
  305. /* Serial Message Command IDs */
  306. #define SPI_CMD_DEBUG_MSG 0x4003
  307. #define SPI_CMD_TRACE_SUB 0x0004
  308. #define SPI_CMD_TRACE_MSG 0x4004
  309. /* User CMD IDs */
  310. #define SPI_CMD_USER0 0x000A
  311. #define SPI_CMD_USER1 0x000B
  312. #define SPI_CMD_USER2 0x000C
  313. #define SPI_CMD_USER3 0x000D
  314. #define SPI_CMD_USER4 0x000E
  315. #define SPI_CMD_USER5 0x000F
  316. #define SPI_SYS_STRING_MSG 0x0015
  317. #define SPI_CMD_SYS_NETWORK_START 0x0020
  318. #define SPI_CMD_ZIGNET_DATA 0x0022
  319. /* system command response */
  320. #define SPI_CB_SYS_CALLBACK_SUB_RSP 0x1006
  321. #define SPI_CB_SYS_PING_RSP 0x1007
  322. #define SPI_CB_SYS_GET_DEVICE_INFO_RSP 0x1014
  323. #define SPI_CB_SYS_KEY_EVENT_RSP 0x1016
  324. #define SPI_CB_SYS_HEARTBEAT_RSP 0x1017
  325. #define SPI_CB_SYS_LED_CONTROL_RSP 0x1019
  326. /* Message Sequence definitions */
  327. #define SPI_CMD_SEQ_START 0x0600
  328. #define SPI_CMD_SEQ_WAIT 0x0601
  329. #define SPI_CMD_SEQ_END 0x0602
  330. #define SPI_CMD_SEQ_RESET 0x0603
  331. #define DEFAULT_WAIT_INTERVAL 5000 //5 seconds
  332. /* Serial Message Command Routing Bits */
  333. #define SPI_RESPONSE_BIT 0x1000
  334. #define SPI_SUBSCRIPTION_BIT 0x2000
  335. #define SPI_DEBUGTRACE_BIT 0x4000
  336. #define SPI_0DATA_MSG_LEN 5
  337. #define SPI_RESP_MSG_LEN_DEFAULT 6
  338. #define LEN_MAC_BEACON_MSDU 15
  339. #define LEN_MAC_COORDEXTND_ADDR 8
  340. #define LEN_MAC_ATTR_BYTE 1
  341. #define LEN_MAC_ATTR_INT 2
  342. #define SOP_FIELD 0
  343. #define CMD_FIELD_HI 1
  344. #define CMD_FIELD_LO 2
  345. #define DATALEN_FIELD 3
  346. #define DATA_BEGIN 4
  347. /* MT PACKET (For Test Tool): FIELD IDENTIFIERS */
  348. #define MT_MAC_CB_ID 0
  349. #define MT_OFFSET 1
  350. #define MT_SOP_FIELD MT_OFFSET + SOP_FIELD
  351. #define MT_CMD_FIELD_HI MT_OFFSET + CMD_FIELD_HI
  352. #define MT_CMD_FIELD_LO MT_OFFSET + CMD_FIELD_LO
  353. #define MT_DATALEN_FIELD MT_OFFSET + DATALEN_FIELD
  354. #define MT_DATA_BEGIN MT_OFFSET + DATA_BEGIN
  355. #define MT_INFO_HEADER_LEN 1
  356. #define MT_RAM_READ_RESP_LEN 0x02
  357. #define MT_RAM_WRITE_RESP_LEN 0x01
  358. /* Defines for the fields in the AF structures */
  359. #define AF_INTERFACE_BITS 0x07
  360. #define AF_INTERFACE_OFFSET 0x05
  361. #define AF_APP_DEV_VER_MASK 0x0F
  362. #define AF_APP_FLAGS_MASK 0x0F
  363. #define AF_TRANSTYPE_MASK 0x0F
  364. #define AF_TRANSDATATYPE_MASK 0x0F
  365. /* Defines for the semi-precision structure */
  366. #define AF_SEMI_PREC_SIGN 0x8000
  367. #define AF_SEMI_PREC_EXPONENT 0x7C00
  368. #define AF_SEMI_PREC_MANTISSA 0x03FF
  369. #define AF_SEMI_PREC_SIGN_OFFSET 0x0F
  370. #define AF_SEMI_PREC_EXP_OFFSET 0x0A
  371. /* Defines for the application commands accessed by MT */
  372. #define SRC_CHANGE_STATE 0x0000
  373. #define DRC_TOGGLE_STATE 0x0001
  374. #define DRC_TOGGLE_PRESET 0x0002
  375. #define OS_TOGGLE_STATE 0x0003
  376. #define SLC_RCV_SET_ONOFF 0x0004
  377. #define DLC_RCV_SET_ONOFF 0x0005
  378. #define DLC_RCV_SET_DIMBRIGHT 0x0006
  379. #define DLC_RCV_SET_PRESET 0x0007
  380. #define LSM_TOGGLE_STATE 0x0008
  381. #define DRC_DIMBRIGHT 0x0009
  382. #define TGEN_START 0x000a
  383. #define TGEN_STOP 0x000b
  384. #define TGEN_COUNT 0x000c
  385. #define DEBUG_GET 0x000d
  386. #define HW_TEST 0x000e
  387. #define HW_DISPLAY_RESULT 0x000f
  388. #define HW_SEND_STATUS 0x0010
  389. #if defined( APP_TP ) || defined ( APP_TP2 )
  390. #if defined( APP_TP )
  391. #define TP_SEND_NODATA 0x0011
  392. #else
  393. #define TP_SEND_BCAST_RSP 0x0011
  394. #endif
  395. #define TP_SEND_BUFFERTEST 0x0012
  396. #if defined (APP_TP)
  397. #define TP_SEND_UINT8 0x0013
  398. #define TP_SEND_INT8 0x0014
  399. #define TP_SEND_UINT16 0x0015
  400. #define TP_SEND_INT16 0x0016
  401. #define TP_SEND_SEMIPREC 0x0017
  402. #endif
  403. #define TP_SEND_FREEFORM 0x0018
  404. #if defined( APP_TP )
  405. #define TP_SEND_ABS_TIME 0x0019
  406. #define TP_SEND_REL_TIME 0x001A
  407. #define TP_SEND_CHAR_STRING 0x001B
  408. #define TP_SEND_OCTET_STRING 0x001C
  409. #endif
  410. #define TP_SET_DSTADDRESS 0x001D
  411. #if defined( APP_TP2 )
  412. #define TP_SEND_BUFFER_GROUP 0x001E
  413. #endif
  414. #define TP_SEND_BUFFER 0x001F
  415. #if defined( APP_TP )
  416. #define TP_SEND_CON_INT8 0x0020
  417. #define TP_SEND_CON_INT16 0x0021
  418. #define TP_SEND_CON_TIME 0x0022
  419. #define TP_SEND_MULT_KVP_8BIT 0x0023
  420. #define TP_SEND_MULT_KVP_16BIT 0x0024
  421. #define TP_SEND_MULT_KVP_TIME 0x0025
  422. #define TP_SEND_MULT_KVP_STRING 0x0026
  423. #endif
  424. #define TP_SEND_COUNTED_PKTS 0x0027
  425. #define TP_SEND_RESET_COUNTER 0x0028
  426. #define TP_SEND_GET_COUNTER 0x0029
  427. #if defined( APP_TP )
  428. #define TP_SEND_MULTI_KVP_STR_TIME 0x0030
  429. #endif
  430. #define TP_SET_PERMIT_JOIN 0x0040
  431. #define TP_ADD_GROUP 0x0041
  432. #define TP_REMOVE_GROUP 0x0042
  433. #define TP_SEND_UPDATE_KEY 0x0043
  434. #define TP_SEND_SWITCH_KEY 0x0044
  435. #if defined( APP_TP2 )
  436. #define TP_SEND_BUFFERTEST_GROUP 0x0045
  437. #define TP_SEND_ROUTE_DISC_REQ 0x0046
  438. #define TP_SEND_ROUTE_DISCOVERY 0x0047
  439. #define TP_SEND_NEW_ADDR 0x0048
  440. #define TP_SEND_NWK_UPDATE 0x0049
  441. #define TP_AK_SETUP_PARTNER 0x0050
  442. #define TP_AK_REQ_KEY 0x0051
  443. #define TP_AK_PARTNER_NWKADDR 0x0052
  444. #define TP_AK_PARTNER_EXTADDR7654 0x0053
  445. #define TP_AK_PARTNER_EXTADDR3210 0x0054
  446. #define TP_AK_PARTNER_SET 0x0055
  447. #define TP_AK_TYPE_SET 0x0056
  448. #define TP_FRAG_SKIP_BLOCK 0x0057
  449. #define TP_APS_REMOVE 0x0058
  450. #endif
  451. #endif
  452. #if defined ( OSAL_TOTAL_MEM )
  453. #define OSAL_MEM_STACK_HIGH_WATER 0x0100
  454. #define OSAL_MEM_HEAP_HIGH_WATER 0x0101
  455. #endif
  456. /* Capabilities - PING Response */
  457. #if defined (MT_SYS_FUNC)
  458. #define MT_CAP_SYS 0x0001
  459. #else
  460. #define MT_CAP_SYS 0x0000
  461. #endif
  462. #if defined ( MT_MAC_FUNC )
  463. #define MT_CAP_MAC 0x0002
  464. #else
  465. #define MT_CAP_MAC 0x0000
  466. #endif
  467. #if defined ( MT_NWK_FUNC )
  468. #define MT_CAP_NWK 0x0004
  469. #else
  470. #define MT_CAP_NWK 0x0000
  471. #endif
  472. #if defined ( MT_AF_FUNC )
  473. #define MT_CAP_AF 0x0008
  474. #else
  475. #define MT_CAP_AF 0x0000
  476. #endif
  477. #if defined ( MT_ZDO_FUNC )
  478. #define MT_CAP_ZDO 0x0010
  479. #else
  480. #define MT_CAP_ZDO 0x0000
  481. #endif
  482. #if defined ( MT_SAPI_FUNC )
  483. #define MT_CAP_SAPI 0x0020
  484. #else
  485. #define MT_CAP_SAPI 0x0000
  486. #endif
  487. #if defined ( MT_UTIL_FUNC )
  488. #define MT_CAP_UTIL 0x0040
  489. #else
  490. #define MT_CAP_UTIL 0x0000
  491. #endif
  492. #if defined ( MT_DEBUG_FUNC )
  493. #define MT_CAP_DEBUG 0x0080
  494. #else
  495. #define MT_CAP_DEBUG 0x0000
  496. #endif
  497. #if defined ( MT_APP_FUNC )
  498. #define MT_CAP_APP 0x0100
  499. #else
  500. #define MT_CAP_APP 0x0000
  501. #endif
  502. #if defined ( ZPORT )
  503. #define MT_CAP_ZOAD 0x1000
  504. #else
  505. #define MT_CAP_ZOAD 0x0000
  506. #endif
  507. /***************************************************************************************************
  508. * TYPEDEFS
  509. ***************************************************************************************************/
  510. typedef struct {
  511. uint16 waitInterval;
  512. byte *msg;
  513. void *next;
  514. } MT_msg_queue_t;
  515. /***************************************************************************************************
  516. * GLOBAL VARIABLES
  517. ***************************************************************************************************/
  518. extern byte MT_TaskID;
  519. extern byte debugThreshold;
  520. extern byte debugCompId;
  521. extern byte queueMsgs;
  522. extern MT_msg_queue_t *_pMtMsgQueue;
  523. extern MT_msg_queue_t *_pLastInQueue;
  524. extern MT_msg_queue_t *_pCurQueueElem;
  525. /*
  526. * Build and send a ZTool response message
  527. */
  528. extern void MT_BuildAndSendZToolResponse(uint8 cmdType, uint8 cmdId, uint8 dataLen, uint8 *dataPtr);
  529. /*
  530. * MonitorTest Format an SPI Message
  531. */
  532. extern void MT_BuildSPIMsg( uint8 cmdType, uint8 cmdId, byte *msg, byte dataLen, byte *dataPtr );
  533. /*
  534. * Temp test function
  535. */
  536. extern void MT_ProcessUserCmd( byte cmd );
  537. /*
  538. * MonitorTest function handling PhY commands
  539. */
  540. extern void MT_RadioCommandProcessing( uint16 cmd_id , byte len , byte *pData );
  541. /*
  542. * MonitorTest function handling PhY commands
  543. */
  544. extern void MT_PhyCommandProcessing( uint16 cmd_id , byte len , byte *pData );
  545. /*
  546. * MonitorTest function to copy a uint16 array to a byte array, little endian.
  547. */
  548. extern uint8 *MT_Word2Buf( uint8 *pBuf, uint16 *pWord, uint8 len );
  549. /*
  550. * MonitorTest function to reverse bytes in a buffer
  551. */
  552. extern void MT_ReverseBytes( byte *pData, byte len );
  553. /*
  554. * Process App Response Msg
  555. */
  556. extern void MTProcessAppRspMsg(byte *pData, byte len);
  557. /*
  558. * Initialize MT
  559. */
  560. extern void MT_Init(uint8 taskID);
  561. /*
  562. * Process incoming commands
  563. */
  564. extern void MT_ProcessIncoming(uint8 *pBuf);
  565. /*
  566. * Callback function to allocate message buffer
  567. */
  568. extern uint8 *MT_TransportAlloc(uint8 cmd0, uint8 len);
  569. /*
  570. * Callback function to send message buffer
  571. */
  572. extern void MT_TransportSend(uint8 *pBuf);
  573. /*
  574. * Utility function to build endpoint descriptor from incoming buffer
  575. */
  576. extern uint8 MT_BuildEndpointDesc( uint8 *pBuf, void *param );
  577. /***************************************************************************************************
  578. ***************************************************************************************************/
  579. #ifdef __cplusplus
  580. }
  581. #endif
  582. #endif /* MTEL_H */