ZComDef.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  1. /**************************************************************************************************
  2. Filename: ZComDef.h
  3. Revised: $Date: 2008-10-07 14:47:15 -0700 (Tue, 07 Oct 2008) $
  4. Revision: $Revision: 18212 $
  5. Description: Type definitions and macros.
  6. Copyright 2004-2007 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 ZCOMDEF_H
  34. #define ZCOMDEF_H
  35. #ifdef __cplusplus
  36. extern "C"
  37. {
  38. #endif
  39. /*********************************************************************
  40. * INCLUDES
  41. */
  42. #include "comdef.h"
  43. #include "saddr.h"
  44. /*********************************************************************
  45. * CONSTANTS
  46. */
  47. #define osal_cpyExtAddr(a, b) sAddrExtCpy((a), (const uint8 *)(b))
  48. #define osal_ExtAddrEqual(a, b) sAddrExtCmp((const uint8 *)(a), (const uint8 *)(b))
  49. #define osal_copyAddress(a, b) sAddrCpy( (sAddr_t *)(a), (const sAddr_t *)(b) )
  50. /*********************************************************************
  51. * CONSTANTS
  52. */
  53. // Build Device Types - Used during compilation
  54. // These are the types of devices to build
  55. // Bit masked into ZSTACK_DEVICE_BUILD
  56. #define DEVICE_BUILD_COORDINATOR 0x01
  57. #define DEVICE_BUILD_ROUTER 0x02
  58. #define DEVICE_BUILD_ENDDEVICE 0x04
  59. /*** Return Values ***/
  60. #define ZSUCCESS SUCCESS
  61. /*** Component IDs ***/
  62. #define COMPID_OSAL 0
  63. #define COMPID_MTEL 1
  64. #define COMPID_MTSPCI 2
  65. #define COMPID_NWK 3
  66. #define COMPID_NWKIF 4
  67. #define COMPID_MACCB 5
  68. #define COMPID_MAC 6
  69. #define COMPID_APP 7
  70. #define COMPID_TEST 8
  71. #define COMPID_RTG 9
  72. #define COMPID_DATA 11
  73. /* Temp CompIDs for testing */
  74. #define COMPID_TEST_NWK_STARTUP 20
  75. #define COMPID_TEST_SCAN_CONFIRM 21
  76. #define COMPID_TEST_ASSOC_CONFIRM 22
  77. #define COMPID_TEST_REMOTE_DATA_CONFIRM 23
  78. // OSAL NV item IDs
  79. #define ZCD_NV_EXTADDR 0x0001
  80. #define ZCD_NV_BOOTCOUNTER 0x0002
  81. #define ZCD_NV_STARTUP_OPTION 0x0003
  82. #define ZCD_NV_START_DELAY 0x0004
  83. // NWK Layer NV item IDs
  84. #define ZCD_NV_NIB 0x0021
  85. #define ZCD_NV_DEVICE_LIST 0x0022
  86. #define ZCD_NV_ADDRMGR 0x0023
  87. #define ZCD_NV_POLL_RATE 0x0024
  88. #define ZCD_NV_QUEUED_POLL_RATE 0x0025
  89. #define ZCD_NV_RESPONSE_POLL_RATE 0x0026
  90. #define ZCD_NV_REJOIN_POLL_RATE 0x0027
  91. #define ZCD_NV_DATA_RETRIES 0x0028
  92. #define ZCD_NV_POLL_FAILURE_RETRIES 0x0029
  93. #define ZCD_NV_STACK_PROFILE 0x002A
  94. #define ZCD_NV_INDIRECT_MSG_TIMEOUT 0x002B
  95. #define ZCD_NV_ROUTE_EXPIRY_TIME 0x002C
  96. #define ZCD_NV_EXTENDED_PAN_ID 0x002D
  97. #define ZCD_NV_BCAST_RETRIES 0x002E
  98. #define ZCD_NV_PASSIVE_ACK_TIMEOUT 0x002F
  99. #define ZCD_NV_BCAST_DELIVERY_TIME 0x0030
  100. #define ZCD_NV_NWK_MODE 0x0031
  101. #define ZCD_NV_CONCENTRATOR_ENABLE 0x0032
  102. #define ZCD_NV_CONCENTRATOR_DISCOVERY 0x0033
  103. #define ZCD_NV_CONCENTRATOR_RADIUS 0x0034
  104. #define ZCD_NV_MAX_SOURCE_ROUTE 0x0035
  105. #define ZCD_NV_CONCENTRATOR_RC 0x0036
  106. #define ZCD_NV_NWK_MGR_MODE 0x0037
  107. // APS Layer NV item IDs
  108. #define ZCD_NV_BINDING_TABLE 0x0041
  109. #define ZCD_NV_GROUP_TABLE 0x0042
  110. #define ZCD_NV_APS_FRAME_RETRIES 0x0043
  111. #define ZCD_NV_APS_ACK_WAIT_DURATION 0x0044
  112. #define ZCD_NV_APS_ACK_WAIT_MULTIPLIER 0x0045
  113. #define ZCD_NV_BINDING_TIME 0x0046
  114. #define ZCD_NV_APS_USE_EXT_PANID 0x0047
  115. #define ZCD_NV_APS_USE_INSECURE_JOIN 0x0048
  116. #define ZCD_NV_APSF_WINDOW_SIZE 0x0049 // Window size for fregmentation
  117. #define ZCD_NV_APSF_INTERFRAME_DELAY 0x004A // The delay between tx blocks when using fragmentaition
  118. #define ZCD_NV_APS_NONMEMBER_RADIUS 0x004B // Multicast non_member radius
  119. #define ZCD_NV_APS_LINK_KEY_TABLE 0x004C
  120. // Security NV Item IDs
  121. #define ZCD_NV_SECURITY_LEVEL 0x0061
  122. #define ZCD_NV_PRECFGKEY 0x0062
  123. #define ZCD_NV_PRECFGKEYS_ENABLE 0x0063
  124. #define ZCD_NV_SECURITY_MODE 0x0064
  125. #define ZCD_NV_SECURE_PERMIT_JOIN 0x0065
  126. #define ZCD_NV_SECURE_PRECFG_TCLINKKEY 0x0066
  127. #define ZCD_NV_SECURE_TCLINKKEY_TXFRAME 0x0067 // Trust Center Link Key tx Frame counter
  128. #define ZCD_NV_SECURE_TCLINKKEY_RXFRAME 0x0068 // Trust Center Link Key rx Frame counter
  129. #define ZCD_NV_lOCAL_CERTIFICATE 0x0069
  130. #define ZCD_NV_STATIC_PRIVATE_KEY 0x006a
  131. #define ZCD_NV_CA_PUBLIC_KEY 0x006b
  132. #define ZCD_NV_STATIC_PUBLIC_KEY 0x006c
  133. // ZDO NV Item IDs
  134. #define ZCD_NV_USERDESC 0x0081
  135. #define ZCD_NV_NWKKEY 0x0082
  136. #define ZCD_NV_PANID 0x0083
  137. #define ZCD_NV_CHANLIST 0x0084
  138. #define ZCD_NV_LEAVE_CTRL 0x0085
  139. #define ZCD_NV_SCAN_DURATION 0x0086
  140. #define ZCD_NV_LOGICAL_TYPE 0x0087
  141. // ZCL NV item IDs
  142. #define ZCD_NV_SCENE_TABLE 0x0091
  143. // Non-standard NV item IDs
  144. #define ZCD_NV_SAPI_ENDPOINT 0x00A1
  145. // NV Items Reserved for applications (user applications)
  146. // 0x0201 – 0x0FFF
  147. // ZCD_NV_STARTUP_OPTION values
  148. // These are bit weighted - you can OR these together.
  149. // Setting one of these bits will set their associated NV items
  150. // to code initialized values.
  151. #define ZCD_STARTOPT_DEFAULT_CONFIG_STATE 0x01
  152. #define ZCD_STARTOPT_DEFAULT_NETWORK_STATE 0x02
  153. #define ZCD_STARTOPT_AUTO_START 0x04
  154. #define ZCD_STARTOPT_CLEAR_CONFIG ZCD_STARTOPT_DEFAULT_CONFIG_STATE
  155. #define ZCD_STARTOPT_CLEAR_STATE ZCD_STARTOPT_DEFAULT_NETWORK_STATE
  156. // NV Item Length
  157. #define ZCL_KEY_ESTABLISHMENT_PUBLIC_KEY_LENGTH 22
  158. #define ZCL_KEY_ESTABLSIHMENT_PRIVATE_KEY_LENTGH 21
  159. #define ZCL_KEY_ESTABLISHMENT_CERTIFICATE_LENGTH 48
  160. /*********************************************************************
  161. * TYPEDEFS
  162. */
  163. /*** Data Types ***/
  164. typedef uint8 byte;
  165. typedef uint16 UINT16;
  166. typedef int16 INT16;
  167. enum
  168. {
  169. AddrNotPresent = 0,
  170. AddrGroup = 1,
  171. Addr16Bit = 2,
  172. Addr64Bit = 3,
  173. AddrBroadcast = 15
  174. };
  175. #define Z_EXTADDR_LEN 8
  176. typedef byte ZLongAddr_t[Z_EXTADDR_LEN];
  177. typedef struct
  178. {
  179. union
  180. {
  181. uint16 shortAddr;
  182. ZLongAddr_t extAddr;
  183. } addr;
  184. byte addrMode;
  185. } zAddrType_t;
  186. // Redefined Generic Status Return Values for code backwards compatibility
  187. #define ZSuccess SUCCESS
  188. #define ZFailure FAILURE
  189. #define ZInvalidParameter INVALIDPARAMETER
  190. // ZStack status values must start at 0x10, after the generic status values (defined in comdef.h)
  191. #define ZMemError 0x10
  192. #define ZBufferFull 0x11
  193. #define ZUnsupportedMode 0x12
  194. #define ZMacMemError 0x13
  195. #define ZSapiInProgress 0x20
  196. #define ZSapiTimeout 0x21
  197. #define ZSapiInit 0x22
  198. // APS status values
  199. #define ZApsFail 0xb1
  200. #define ZApsTableFull 0xb2
  201. #define ZApsIllegalRequest 0xb3
  202. #define ZApsInvalidBinding 0xb4
  203. #define ZApsUnsupportedAttrib 0xb5
  204. #define ZApsNotSupported 0xb6
  205. #define ZApsNoAck 0xb7
  206. #define ZApsDuplicateEntry 0xb8
  207. #define ZApsNoBoundDevice 0xb9
  208. #define ZApsNotAllowed 0xba
  209. #define ZApsNotAuthenticated 0xbb
  210. // Security status values
  211. #define ZSecNoKey 0xa1
  212. #define ZSecOldFrmCount 0xa2
  213. #define ZSecMaxFrmCount 0xa3
  214. #define ZSecCcmFail 0xa4
  215. // NWK status values
  216. #define ZNwkInvalidParam 0xc1
  217. #define ZNwkInvalidRequest 0xc2
  218. #define ZNwkNotPermitted 0xc3
  219. #define ZNwkStartupFailure 0xc4
  220. #define ZNwkAlreadyPresent 0xc5
  221. #define ZNwkSyncFailure 0xc6
  222. #define ZNwkTableFull 0xc7
  223. #define ZNwkUnknownDevice 0xc8
  224. #define ZNwkUnsupportedAttribute 0xc9
  225. #define ZNwkNoNetworks 0xca
  226. #define ZNwkLeaveUnconfirmed 0xcb
  227. #define ZNwkNoAck 0xcc // not in spec
  228. #define ZNwkNoRoute 0xcd
  229. // MAC status values
  230. #define ZMacSuccess 0x00
  231. #define ZMacBeaconLoss 0xe0
  232. #define ZMacChannelAccessFailure 0xe1
  233. #define ZMacDenied 0xe2
  234. #define ZMacDisableTrxFailure 0xe3
  235. #define ZMacFailedSecurityCheck 0xe4
  236. #define ZMacFrameTooLong 0xe5
  237. #define ZMacInvalidGTS 0xe6
  238. #define ZMacInvalidHandle 0xe7
  239. #define ZMacInvalidParameter 0xe8
  240. #define ZMacNoACK 0xe9
  241. #define ZMacNoBeacon 0xea
  242. #define ZMacNoData 0xeb
  243. #define ZMacNoShortAddr 0xec
  244. #define ZMacOutOfCap 0xed
  245. #define ZMacPANIDConflict 0xee
  246. #define ZMacRealignment 0xef
  247. #define ZMacTransactionExpired 0xf0
  248. #define ZMacTransactionOverFlow 0xf1
  249. #define ZMacTxActive 0xf2
  250. #define ZMacUnAvailableKey 0xf3
  251. #define ZMacUnsupportedAttribute 0xf4
  252. #define ZMacUnsupported 0xf5
  253. #define ZMacSrcMatchInvalidIndex 0xff
  254. typedef Status_t ZStatus_t;
  255. typedef struct
  256. {
  257. uint8 txCounter; // Counter of transmission success/failures
  258. uint8 txCost; // Average of sending rssi values if link staus is enabled
  259. // i.e. NWK_LINK_STATUS_PERIOD is defined as non zero
  260. uint8 rxLqi; // average of received rssi values
  261. // needs to be converted to link cost (1-7) before used
  262. uint8 inKeySeqNum; // security key sequence number
  263. uint32 inFrmCntr; // security frame counter..
  264. uint16 txFailure; // higher values indicate more failures
  265. } linkInfo_t;
  266. /*********************************************************************
  267. * Global System Messages
  268. */
  269. #define SPI_INCOMING_ZTOOL_PORT 0x21 // Raw data from ZTool Port (not implemented)
  270. #define SPI_INCOMING_ZAPP_DATA 0x22 // Raw data from the ZAPP port (see serialApp.c)
  271. #define MT_SYS_APP_MSG 0x23 // Raw data from an MT Sys message
  272. #define MT_SYS_APP_RSP_MSG 0x24 // Raw data output for an MT Sys message
  273. #define AF_DATA_CONFIRM_CMD 0xFD // Data confirmation
  274. #define AF_INCOMING_MSG_CMD 0x1A // Incoming MSG type message
  275. #define AF_INCOMING_KVP_CMD 0x1B // Incoming KVP type message
  276. #define AF_INCOMING_GRP_KVP_CMD 0x1C // Incoming Group KVP type message
  277. //#define KEY_CHANGE 0xC0 // Key Events
  278. #define ZDO_NEW_DSTADDR 0xD0 // ZDO has received a new DstAddr for this app
  279. #define ZDO_STATE_CHANGE 0xD1 // ZDO has changed the device's network state
  280. #define ZDO_MATCH_DESC_RSP_SENT 0xD2 // ZDO match descriptor response was sent
  281. #define ZDO_CB_MSG 0xD3 // ZDO incoming message callback
  282. #define ZDO_NETWORK_REPORT 0xD4 // ZDO received a Network Report message
  283. #define ZDO_NETWORK_UPDATE 0xD5 // ZDO received a Network Update message
  284. #define NM_CHANNEL_INTERFERE 0x31 // NwkMgr received a Channel Interference message
  285. #define NM_ED_SCAN_CONFIRM 0x32 // NwkMgr received an ED Scan Confirm message
  286. #define SAPS_CHANNEL_CHANGE 0x33 // Stub APS has changed the device's channel
  287. #define ZCL_INCOMING_MSG 0x34 // Incoming ZCL foundation message
  288. #define ZCL_KEY_ESTABLISH_IND 0x35 // ZCL Key Establishment Completion Indication
  289. // OSAL System Message IDs/Events Reserved for applications (user applications)
  290. // 0xE0 – 0xFC
  291. /*********************************************************************
  292. * GLOBAL VARIABLES
  293. */
  294. /*********************************************************************
  295. * FUNCTIONS
  296. */
  297. /*********************************************************************
  298. *********************************************************************/
  299. #ifdef __cplusplus
  300. }
  301. #endif
  302. #endif /* ZCOMDEF_H */