ZGlobals.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  1. /**************************************************************************************************
  2. Filename: nwk_globals.h
  3. Revised: $Date: 2006-11-02 11:26:08 -0800 (Thu, 02 Nov 2006) $
  4. Revision: $Revision: 12495 $
  5. Description: User definable Z-Stack parameters.
  6. Copyright 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 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 ( APS_DEFAULT_MAXBINDING_TIME )
  138. #define APS_DEFAULT_MAXBINDING_TIME 16000
  139. #endif
  140. #if !defined ( APSF_DEFAULT_WINDOW_SIZE )
  141. #define APS_DEFAULT_WINDOW_SIZE 3
  142. #endif
  143. #if !defined ( APSF_DEFAULT_INTERFRAME_DELAY )
  144. #define APS_DEFAULT_INTERFRAME_DELAY 50
  145. #endif
  146. #if !defined ( APS_DEFAULT_NONMEMBER_RADIUS )
  147. #define APS_DEFAULT_NONMEMBER_RADIUS 2
  148. #endif
  149. // Concentrator values
  150. #if !defined ( CONCENTRATOR_ENABLE )
  151. #define CONCENTRATOR_ENABLE false // true if concentrator is enabled
  152. #endif
  153. #if !defined ( CONCENTRATOR_DISCOVERY_TIME )
  154. #define CONCENTRATOR_DISCOVERY_TIME 0
  155. #endif
  156. #if !defined ( CONCENTRATOR_RADIUS )
  157. #define CONCENTRATOR_RADIUS 0x0a
  158. #endif
  159. #if !defined ( CONCENTRATOR_ROUTE_CACHE )
  160. #define CONCENTRATOR_ROUTE_CACHE false // true if concentrator has route cache
  161. #endif
  162. #if !defined ( MAX_SOURCE_ROUTE )
  163. #define MAX_SOURCE_ROUTE 0x0c
  164. #endif
  165. #if !defined ( START_DELAY )
  166. #define START_DELAY 0x0a
  167. #endif
  168. #if !defined ( SAPI_ENDPOINT )
  169. #define SAPI_ENDPOINT 0xe0
  170. #endif
  171. #define ZG_STARTUP_CLEAR 0x00
  172. #define ZG_STARTUP_SET 0xFF
  173. // Backwards compatible - AMI changed name to SE
  174. #if defined ( AMI_PROFILE )
  175. #define SE_PROFILE
  176. #endif
  177. //--------------------------------------------------------------------
  178. // Security modes
  179. //--------------------------------------------------------------------
  180. #define ZG_SECURITY_NONE 0
  181. #define ZG_SECURITY_RESIDENTIAL 1
  182. #define ZG_SECURITY_PRO_STANDARD 1 // For now, same as residential
  183. #define ZG_SECURITY_PRO_HIGH 3
  184. #define ZG_SECURITY_SE_STANDARD 4
  185. #if ( SECURE == 0 )
  186. #undef ZG_SECURITY_MODE
  187. #define ZG_SECURITY_MODE ZG_SECURITY_NONE
  188. #else
  189. #if !defined ( ZG_SECURITY_MODE )
  190. #if defined ( SE_PROFILE )
  191. #define ZG_SECURITY_MODE ZG_SECURITY_SE_STANDARD
  192. #else
  193. #if !defined ( ZIGBEEPRO )
  194. #define ZG_SECURITY_MODE ZG_SECURITY_RESIDENTIAL
  195. #else
  196. // #define ZG_SECURITY_MODE ZG_SECURITY_PRO_HIGH
  197. #define ZG_SECURITY_MODE ZG_SECURITY_PRO_STANDARD // Default for Pro Release is Standard (residential)
  198. #endif
  199. #endif
  200. #endif
  201. #endif
  202. //--------------------------------------------------------------------
  203. // Security settings
  204. //--------------------------------------------------------------------
  205. #if !defined ( ZG_SECURE_DYNAMIC )
  206. #define ZG_SECURE_DYNAMIC 1
  207. #endif
  208. #if ( ZG_SECURE_DYNAMIC == 1 )
  209. #define ZG_SECURE_ENABLED ( SECURE && ( zgSecurityMode != ZG_SECURITY_NONE ) )
  210. #define ZG_CHECK_SECURITY_MODE ( zgSecurityMode )
  211. #else
  212. #define ZG_SECURE_ENABLED ( SECURE )
  213. #define ZG_CHECK_SECURITY_MODE ( ZG_SECURITY_MODE )
  214. #endif
  215. /*********************************************************************
  216. * TYPEDEFS
  217. */
  218. /*********************************************************************
  219. * NWK GLOBAL VARIABLES
  220. */
  221. extern uint16 zgPollRate;
  222. extern uint16 zgQueuedPollRate;
  223. extern uint16 zgResponsePollRate;
  224. extern uint16 zgRejoinPollRate;
  225. // Variables for number of transmission retries
  226. extern uint8 zgMaxDataRetries;
  227. extern uint8 zgMaxPollFailureRetries;
  228. extern uint32 zgDefaultChannelList;
  229. extern uint8 zgDefaultStartingScanDuration;
  230. extern uint8 zgStackProfile;
  231. extern uint8 zgIndirectMsgTimeout;
  232. extern uint8 zgSecurityMode;
  233. extern uint8 zgSecurePermitJoin;
  234. extern uint8 zgCAPublicKey[];
  235. extern uint8 zgLocalCertificate[];
  236. extern uint8 zgStaticPrivateKey[];
  237. extern uint8 zgRemotePublicKey[];
  238. extern uint8 zgRouteExpiryTime;
  239. extern uint8 zgExtendedPANID[];
  240. extern uint8 zgMaxBcastRetires;
  241. extern uint8 zgPassiveAckTimeout;
  242. extern uint8 zgBcastDeliveryTime;
  243. extern uint8 zgNwkMode;
  244. extern uint8 zgConcentratorEnable;
  245. extern uint8 zgConcentratorDiscoveryTime;
  246. extern uint8 zgConcentratorRadius;
  247. extern uint8 zgMaxSourceRoute;
  248. extern uint8 zgConcentratorRC;
  249. /*********************************************************************
  250. * APS GLOBAL VARIABLES
  251. */
  252. extern uint8 zgApscMaxFrameRetries;
  253. extern uint16 zgApscAckWaitDurationPolled;
  254. extern uint8 zgApsAckWaitMultiplier;
  255. extern uint16 zgApsDefaultMaxBindingTime;
  256. extern uint8 zgApsUseExtendedPANID[Z_EXTADDR_LEN];
  257. extern uint8 zgApsUseInsecureJoin;
  258. extern uint8 zgApscMaxWindowSize;
  259. extern uint16 zgApsInterframeDelay;
  260. extern uint8 zgApsNonMemberRadius;
  261. /*********************************************************************
  262. * SECURITY GLOBAL VARIABLES
  263. */
  264. extern uint8 zgPreConfigKey[];
  265. extern uint8 zgPreConfigKeys;
  266. extern uint8 zgPreConfigTCLinkKey[];
  267. /*********************************************************************
  268. * ZDO GLOBAL VARIABLES
  269. */
  270. extern uint16 zgConfigPANID;
  271. extern uint8 zgDeviceLogicalType;
  272. /*********************************************************************
  273. * APPLICATION VARIABLES
  274. */
  275. extern uint8 zgNwkMgrMode;
  276. /*********************************************************************
  277. * FUNCTIONS
  278. */
  279. /*
  280. * Initialize the Z-Stack Globals.
  281. */
  282. extern uint8 zgInit( void );
  283. /*
  284. * Initialize the RAM Items table with NV values.
  285. * setDefault - if calling from outside ZGlobal use FALSE.
  286. */
  287. extern void zgInitItems( uint8 setDefault );
  288. /*
  289. * Get Startup Options (ZCD_NV_STARTUP_OPTION NV Item)
  290. */
  291. extern uint8 zgReadStartupOptions( void );
  292. /*
  293. * Write Startup Options (ZCD_NV_STARTUP_OPTION NV Item)
  294. *
  295. * action - ZG_STARTUP_SET set bit, ZG_STARTUP_CLEAR to clear bit.
  296. * The set bit is an OR operation, and the clear bit is an
  297. * AND ~(bitOptions) operation.
  298. * bitOptions - which bits to perform action on:
  299. * ZCD_STARTOPT_DEFAULT_CONFIG_STATE
  300. * ZDC_STARTOPT_DEFAULT_NETWORK_STATE
  301. *
  302. * Returns - ZSUCCESS if successful
  303. */
  304. extern uint8 zgWriteStartupOptions( uint8 action, uint8 bitOptions );
  305. /*
  306. * Set RAM variables from set-NV, if it exist in the zgItemTable
  307. */
  308. extern void zgSetItem( uint16 id, uint16 len, void *buf );
  309. /*********************************************************************
  310. *********************************************************************/
  311. #ifdef __cplusplus
  312. }
  313. #endif
  314. #endif /* ZGLOBALS_H */