ZGlobals.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393
  1. /**************************************************************************************************
  2. Filename: nwk_globals.h
  3. Revised: $Date: 2012-01-12 17:54:52 -0800 (Thu, 12 Jan 2012) $
  4. Revision: $Revision: 28926 $
  5. Description: User definable Z-Stack parameters.
  6. Copyright 2007-2011 Texas Instruments Incorporated. All rights reserved.
  7. IMPORTANT: Your use of this Software is limited to those specific rights
  8. granted under the terms of a software license agreement between the user
  9. who downloaded the software, his/her employer (which must be your employer)
  10. and Texas Instruments Incorporated (the "License"). You may not use this
  11. Software unless you agree to abide by the terms of the License. The License
  12. limits your use, and you acknowledge, that the Software may not be modified,
  13. copied or distributed unless embedded on a Texas Instruments microcontroller
  14. or used solely and exclusively in conjunction with a Texas Instruments radio
  15. frequency transceiver, which is integrated into your product. Other than for
  16. the foregoing purpose, you may not use, reproduce, copy, prepare derivative
  17. works of, modify, distribute, perform, display or sell this Software and/or
  18. its documentation for any purpose.
  19. YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
  20. PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
  21. INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
  22. NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
  23. TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
  24. NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
  25. LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
  26. INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
  27. OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
  28. OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
  29. (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
  30. Should you have any questions regarding your right to use this Software,
  31. contact Texas Instruments Incorporated at www.TI.com.
  32. **************************************************************************************************/
  33. #ifndef ZGLOBALS_H
  34. #define ZGLOBALS_H
  35. #ifdef __cplusplus
  36. extern "C" {
  37. #endif
  38. /*********************************************************************
  39. * INCLUDES
  40. */
  41. #include "ZComDef.h"
  42. /*********************************************************************
  43. * MACROS
  44. */
  45. #if defined( BUILD_ALL_DEVICES ) && !defined( ZSTACK_DEVICE_BUILD )
  46. #define ZSTACK_DEVICE_BUILD (DEVICE_BUILD_COORDINATOR | DEVICE_BUILD_ROUTER | DEVICE_BUILD_ENDDEVICE)
  47. #endif
  48. // Setup to work with the existing (old) compile flags
  49. #if !defined ( ZSTACK_DEVICE_BUILD )
  50. #if defined ( ZDO_COORDINATOR )
  51. #define ZSTACK_DEVICE_BUILD (DEVICE_BUILD_COORDINATOR)
  52. #elif defined ( RTR_NWK )
  53. #define ZSTACK_DEVICE_BUILD (DEVICE_BUILD_ROUTER)
  54. #else
  55. #define ZSTACK_DEVICE_BUILD (DEVICE_BUILD_ENDDEVICE)
  56. #endif
  57. #endif
  58. // Use the following to macros to make device type decisions
  59. #define ZG_BUILD_COORDINATOR_TYPE (ZSTACK_DEVICE_BUILD & DEVICE_BUILD_COORDINATOR)
  60. #define ZG_BUILD_RTR_TYPE (ZSTACK_DEVICE_BUILD & (DEVICE_BUILD_COORDINATOR | DEVICE_BUILD_ROUTER))
  61. #define ZG_BUILD_ENDDEVICE_TYPE (ZSTACK_DEVICE_BUILD & DEVICE_BUILD_ENDDEVICE)
  62. #define ZG_BUILD_RTRONLY_TYPE (ZSTACK_DEVICE_BUILD == DEVICE_BUILD_ROUTER)
  63. #define ZG_BUILD_JOINING_TYPE (ZSTACK_DEVICE_BUILD & (DEVICE_BUILD_ROUTER | DEVICE_BUILD_ENDDEVICE))
  64. #if ( ZSTACK_DEVICE_BUILD == DEVICE_BUILD_COORDINATOR )
  65. #define ZG_DEVICE_COORDINATOR_TYPE 1
  66. #else
  67. #define ZG_DEVICE_COORDINATOR_TYPE (zgDeviceLogicalType == ZG_DEVICETYPE_COORDINATOR)
  68. #endif
  69. #if ( ZSTACK_DEVICE_BUILD == (DEVICE_BUILD_ROUTER | DEVICE_BUILD_COORDINATOR) )
  70. #define ZG_DEVICE_RTR_TYPE 1
  71. #else
  72. #define ZG_DEVICE_RTR_TYPE ((zgDeviceLogicalType == ZG_DEVICETYPE_COORDINATOR) || (zgDeviceLogicalType == ZG_DEVICETYPE_ROUTER))
  73. #endif
  74. #if ( ZSTACK_DEVICE_BUILD == DEVICE_BUILD_ENDDEVICE )
  75. #define ZG_DEVICE_ENDDEVICE_TYPE 1
  76. #else
  77. #define ZG_DEVICE_ENDDEVICE_TYPE (zgDeviceLogicalType == ZG_DEVICETYPE_ENDDEVICE)
  78. #endif
  79. #define ZG_DEVICE_JOINING_TYPE ((zgDeviceLogicalType == ZG_DEVICETYPE_ROUTER) || (zgDeviceLogicalType == ZG_DEVICETYPE_ENDDEVICE))
  80. #if ( ZG_BUILD_RTR_TYPE )
  81. #if ( ZG_BUILD_ENDDEVICE_TYPE )
  82. #define ZSTACK_ROUTER_BUILD (ZG_BUILD_RTR_TYPE && ZG_DEVICE_RTR_TYPE)
  83. #else
  84. #define ZSTACK_ROUTER_BUILD 1
  85. #endif
  86. #else
  87. #define ZSTACK_ROUTER_BUILD 0
  88. #endif
  89. #if ( ZG_BUILD_ENDDEVICE_TYPE )
  90. #if ( ZG_BUILD_RTR_TYPE )
  91. #define ZSTACK_END_DEVICE_BUILD (ZG_BUILD_ENDDEVICE_TYPE && ZG_DEVICE_ENDDEVICE_TYPE)
  92. #else
  93. #define ZSTACK_END_DEVICE_BUILD 1
  94. #endif
  95. #else
  96. #define ZSTACK_END_DEVICE_BUILD 0
  97. #endif
  98. /*********************************************************************
  99. * CONSTANTS
  100. */
  101. // Values for ZCD_NV_LOGICAL_TYPE (zgDeviceLogicalType)
  102. #define ZG_DEVICETYPE_COORDINATOR 0x00
  103. #define ZG_DEVICETYPE_ROUTER 0x01
  104. #define ZG_DEVICETYPE_ENDDEVICE 0x02
  105. //#define DEVICE_LOGICAL_TYPE ZG_DEVICETYPE_COORDINATOR
  106. // Default Device Logical Type
  107. #if !defined ( DEVICE_LOGICAL_TYPE )
  108. #if ( ZG_BUILD_COORDINATOR_TYPE )
  109. // If capable, default to coordinator
  110. #define DEVICE_LOGICAL_TYPE ZG_DEVICETYPE_COORDINATOR
  111. #elif ( ZG_BUILD_RTR_TYPE )
  112. #define DEVICE_LOGICAL_TYPE ZG_DEVICETYPE_ROUTER
  113. #elif ( ZG_BUILD_ENDDEVICE_TYPE )
  114. // Must be an end device
  115. #define DEVICE_LOGICAL_TYPE ZG_DEVICETYPE_ENDDEVICE
  116. #else
  117. #error ZSTACK_DEVICE_BUILD must be defined as something!
  118. #endif
  119. #endif
  120. // Transmission retries numbers
  121. #if !defined ( MAX_POLL_FAILURE_RETRIES )
  122. #define MAX_POLL_FAILURE_RETRIES 1
  123. #endif
  124. #if !defined ( MAX_DATA_RETRIES )
  125. #define MAX_DATA_RETRIES 2
  126. #endif
  127. // NIB parameters
  128. #if !defined ( MAX_BCAST_RETRIES )
  129. #define MAX_BCAST_RETRIES 2
  130. #endif
  131. #if !defined ( PASSIVE_ACK_TIMEOUT )
  132. #define PASSIVE_ACK_TIMEOUT 5
  133. #endif
  134. #if !defined ( BCAST_DELIVERY_TIME )
  135. #define BCAST_DELIVERY_TIME 30
  136. #endif
  137. #if !defined ( ROUTE_DISCOVERY_TIME )
  138. #define ROUTE_DISCOVERY_TIME 5
  139. #endif
  140. #if !defined ( APS_DEFAULT_MAXBINDING_TIME )
  141. #define APS_DEFAULT_MAXBINDING_TIME 16000
  142. #endif
  143. #if !defined ( APS_DEFAULT_NONMEMBER_RADIUS )
  144. #define APS_DEFAULT_NONMEMBER_RADIUS 2
  145. #endif
  146. #if !defined ( APSF_DEFAULT_WINDOW_SIZE )
  147. #define APSF_DEFAULT_WINDOW_SIZE 1
  148. #endif
  149. #if !defined ( APSF_DEFAULT_INTERFRAME_DELAY )
  150. #define APSF_DEFAULT_INTERFRAME_DELAY 50
  151. #endif
  152. // Concentrator values
  153. #if !defined ( CONCENTRATOR_ENABLE )
  154. #define CONCENTRATOR_ENABLE false // true if concentrator is enabled
  155. #endif
  156. #if !defined ( CONCENTRATOR_DISCOVERY_TIME )
  157. #define CONCENTRATOR_DISCOVERY_TIME 0
  158. #endif
  159. #if !defined ( CONCENTRATOR_RADIUS )
  160. #define CONCENTRATOR_RADIUS 0x0a
  161. #endif
  162. #if !defined ( CONCENTRATOR_ROUTE_CACHE )
  163. #define CONCENTRATOR_ROUTE_CACHE false // true if concentrator has route cache
  164. #endif
  165. // The hop count radius for concentrator route discoveries
  166. #if !defined ( CONCENTRATOR_RADIUS )
  167. #define CONCENTRATOR_RADIUS 0x0a
  168. #endif
  169. #if !defined ( START_DELAY )
  170. #define START_DELAY 0x0a
  171. #endif
  172. #if !defined ( SAPI_ENDPOINT )
  173. #define SAPI_ENDPOINT 0xe0
  174. #endif
  175. #define ZG_STARTUP_CLEAR 0x00
  176. #define ZG_STARTUP_SET 0xFF
  177. #if !defined ( ZG_TRUSTCENTER_ADDR )
  178. #define ZG_TRUSTCENTER_ADDR NWK_PAN_COORD_ADDR
  179. #endif
  180. // Backwards compatible - AMI changed name to SE
  181. #if defined ( AMI_PROFILE ) || defined ( SE_PROFILE )
  182. #define TC_LINKKEY_JOIN
  183. #endif
  184. //--------------------------------------------------------------------
  185. // Security modes
  186. //--------------------------------------------------------------------
  187. #define ZG_SECURITY_NONE 0
  188. #define ZG_SECURITY_RESIDENTIAL 1
  189. #define ZG_SECURITY_PRO_STANDARD 1 // For now, same as residential
  190. #define ZG_SECURITY_PRO_HIGH 3
  191. #define ZG_SECURITY_SE_STANDARD 4
  192. #if ( SECURE == 0 )
  193. #undef ZG_SECURITY_MODE
  194. #define ZG_SECURITY_MODE ZG_SECURITY_NONE
  195. #else
  196. #if !defined ( ZG_SECURITY_MODE )
  197. #if defined ( TC_LINKKEY_JOIN )
  198. #define ZG_SECURITY_MODE ZG_SECURITY_SE_STANDARD
  199. #else
  200. #if !defined ( ZIGBEEPRO )
  201. #define ZG_SECURITY_MODE ZG_SECURITY_RESIDENTIAL
  202. #else
  203. // #define ZG_SECURITY_MODE ZG_SECURITY_PRO_HIGH
  204. #define ZG_SECURITY_MODE ZG_SECURITY_PRO_STANDARD // Default for Pro Release is Standard (residential)
  205. #endif
  206. #endif
  207. #endif
  208. #endif
  209. //--------------------------------------------------------------------
  210. // Security settings
  211. //--------------------------------------------------------------------
  212. #if !defined ( ZG_SECURE_DYNAMIC )
  213. #define ZG_SECURE_DYNAMIC 1
  214. #endif
  215. #if ( ZG_SECURE_DYNAMIC == 1 )
  216. #define ZG_SECURE_ENABLED ( SECURE && ( zgSecurityMode != ZG_SECURITY_NONE ) )
  217. #define ZG_CHECK_SECURITY_MODE ( zgSecurityMode )
  218. #else
  219. #define ZG_SECURE_ENABLED ( SECURE )
  220. #define ZG_CHECK_SECURITY_MODE ( ZG_SECURITY_MODE )
  221. #endif
  222. /*********************************************************************
  223. * TYPEDEFS
  224. */
  225. /*********************************************************************
  226. * NWK GLOBAL VARIABLES
  227. */
  228. extern uint16 zgPollRate;
  229. extern uint16 zgQueuedPollRate;
  230. extern uint16 zgResponsePollRate;
  231. extern uint16 zgRejoinPollRate;
  232. // Variables for number of transmission retries
  233. extern uint8 zgMaxDataRetries;
  234. extern uint8 zgMaxPollFailureRetries;
  235. extern uint32 zgDefaultChannelList;
  236. extern uint8 zgDefaultStartingScanDuration;
  237. extern uint8 zgStackProfile;
  238. extern uint8 zgIndirectMsgTimeout;
  239. extern uint8 zgSecurityMode;
  240. extern uint8 zgSecurePermitJoin;
  241. extern uint16 zgTrustCenterAddr;
  242. extern uint8 zgRouteDiscoveryTime;
  243. extern uint8 zgRouteExpiryTime;
  244. extern uint8 zgExtendedPANID[];
  245. extern uint8 zgMaxBcastRetires;
  246. extern uint8 zgPassiveAckTimeout;
  247. extern uint8 zgBcastDeliveryTime;
  248. extern uint8 zgNwkMode;
  249. extern uint8 zgConcentratorEnable;
  250. extern uint8 zgConcentratorDiscoveryTime;
  251. extern uint8 zgConcentratorRadius;
  252. extern uint8 zgConcentratorRC;
  253. extern uint8 zgNwkSrcRtgExpiryTime;
  254. extern uint8 zgRouterOffAssocCleanup;
  255. /*********************************************************************
  256. * APS GLOBAL VARIABLES
  257. */
  258. extern uint8 zgApscMaxFrameRetries;
  259. extern uint16 zgApscAckWaitDurationPolled;
  260. extern uint8 zgApsAckWaitMultiplier;
  261. extern uint16 zgApsDefaultMaxBindingTime;
  262. extern uint8 zgApsUseExtendedPANID[Z_EXTADDR_LEN];
  263. extern uint8 zgApsUseInsecureJoin;
  264. extern uint8 zgApsNonMemberRadius;
  265. /*********************************************************************
  266. * SECURITY GLOBAL VARIABLES
  267. */
  268. extern uint8 zgPreConfigKeys;
  269. extern uint8 zgUseDefaultTCLK;
  270. /*********************************************************************
  271. * ZDO GLOBAL VARIABLES
  272. */
  273. extern uint16 zgConfigPANID;
  274. extern uint8 zgDeviceLogicalType;
  275. extern uint8 zgNwkMgrMinTransmissions;
  276. #if !defined MT_TASK
  277. extern uint8 zgZdoDirectCB;
  278. #endif
  279. /*********************************************************************
  280. * APPLICATION VARIABLES
  281. */
  282. extern uint8 zgNwkMgrMode;
  283. /*********************************************************************
  284. * FUNCTIONS
  285. */
  286. /*
  287. * Initialize the Z-Stack Globals.
  288. */
  289. extern uint8 zgInit( void );
  290. /*
  291. * Initialize the RAM Items table with NV values.
  292. * setDefault - if calling from outside ZGlobal use FALSE.
  293. */
  294. extern void zgInitItems( uint8 setDefault );
  295. /*
  296. * Get Startup Options (ZCD_NV_STARTUP_OPTION NV Item)
  297. */
  298. extern uint8 zgReadStartupOptions( void );
  299. /*
  300. * Write Startup Options (ZCD_NV_STARTUP_OPTION NV Item)
  301. *
  302. * action - ZG_STARTUP_SET set bit, ZG_STARTUP_CLEAR to clear bit.
  303. * The set bit is an OR operation, and the clear bit is an
  304. * AND ~(bitOptions) operation.
  305. * bitOptions - which bits to perform action on:
  306. * ZCD_STARTOPT_DEFAULT_CONFIG_STATE
  307. * ZDC_STARTOPT_DEFAULT_NETWORK_STATE
  308. *
  309. * Returns - ZSUCCESS if successful
  310. */
  311. extern uint8 zgWriteStartupOptions( uint8 action, uint8 bitOptions );
  312. /*
  313. * Set RAM variables from set-NV, if it exist in the zgItemTable
  314. */
  315. extern void zgSetItem( uint16 id, uint16 len, void *buf );
  316. /*********************************************************************
  317. *********************************************************************/
  318. #ifdef __cplusplus
  319. }
  320. #endif
  321. #endif /* ZGLOBALS_H */