nwk_globals.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  1. /**************************************************************************************************
  2. Filename: nwk_globals.h
  3. Revised: $Date: 2009-03-18 11:00:08 -0700 (Wed, 18 Mar 2009) $
  4. Revision: $Revision: 19446 $
  5. Description: User definable Network Parameters.
  6. Copyright 2004-2009 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 NWK_GLOBALS_H
  34. #define NWK_GLOBALS_H
  35. #ifdef __cplusplus
  36. extern "C" {
  37. #endif
  38. /*********************************************************************
  39. * INCLUDES
  40. */
  41. #include "ZComDef.h"
  42. #include "nwk_bufs.h"
  43. #include "AssocList.h"
  44. #include "BindingTable.h"
  45. #include "ZGlobals.h"
  46. /*********************************************************************
  47. * MACROS
  48. */
  49. /*********************************************************************
  50. * CONSTANTS
  51. */
  52. // If ZIGBEEPRO is defined - define all the features for Zigbee Pro
  53. //#define ZIGBEE_MULTICAST
  54. #if defined ( ZIGBEEPRO )
  55. #if !defined ( ZIGBEE_STOCHASTIC_ADDRESSING )
  56. #define ZIGBEE_STOCHASTIC_ADDRESSING
  57. #define ZIGBEE_NWK_UNIQUE_ADDR_CHECK
  58. #endif
  59. #if !defined ( NWK_LINK_STATUS_PERIOD )
  60. #define NWK_LINK_STATUS_PERIOD 15 // 15 seconds
  61. #endif
  62. #if !defined ( ZIGBEE_MULTICAST )
  63. #define ZIGBEE_MULTICAST
  64. #endif
  65. #if !defined ( ZIGBEE_MANY_TO_ONE )
  66. #define ZIGBEE_MANY_TO_ONE
  67. #endif
  68. #if !defined ( ZIGBEE_SOURCE_ROUTING )
  69. #define ZIGBEE_SOURCE_ROUTING
  70. #endif
  71. #if !defined ( ZIGBEE_COMMISSIONING )
  72. #define ZIGBEE_COMMISSIONING
  73. #endif
  74. #if !defined ( ZIGBEE_FREQ_AGILITY )
  75. #define ZIGBEE_FREQ_AGILITY
  76. #endif
  77. #if !defined ( NWK_MANAGER )
  78. //#define NWK_MANAGER // WARNING: this should be enabled only for one device per network
  79. #endif
  80. #if !defined ( ZIGBEE_FRAGMENTATION )
  81. #define ZIGBEE_FRAGMENTATION
  82. #endif
  83. #else
  84. #define NWK_LINK_STATUS_PERIOD 0
  85. #endif
  86. #if ( RFD_RCVC_ALWAYS_ON==TRUE ) || ( ZG_BUILD_RTR_TYPE )
  87. // The PANID Conflict feature is mandatory for both 2007 and 2007 PRO
  88. // So, it will be ON all the time (except sleeping end devices).
  89. #if !defined ( ZIGBEE_PANID_CONFLICT )
  90. #define ZIGBEE_PANID_CONFLICT
  91. #endif
  92. #endif
  93. // Controls the operational mode of network
  94. #define NWK_MODE_STAR 0
  95. #define NWK_MODE_TREE 1
  96. #define NWK_MODE_MESH 2
  97. // Controls various stack parameter settings
  98. #define NETWORK_SPECIFIC 0
  99. #define HOME_CONTROLS 1
  100. #define ZIGBEEPRO_PROFILE 2
  101. #define GENERIC_STAR 3
  102. #define GENERIC_TREE 4
  103. // Channel mask
  104. #define MAX_CHANNELS_868MHZ 0x00000001
  105. #define MAX_CHANNELS_915MHZ 0x000007FE
  106. #define MAX_CHANNELS_24GHZ 0x07FFF800
  107. #if defined ( ZIGBEEPRO )
  108. #define STACK_PROFILE_ID ZIGBEEPRO_PROFILE
  109. #else
  110. #define STACK_PROFILE_ID HOME_CONTROLS
  111. #endif
  112. #if ( STACK_PROFILE_ID == ZIGBEEPRO_PROFILE )
  113. #define MAX_NODE_DEPTH 20
  114. #define NWK_MODE NWK_MODE_MESH
  115. #define SECURITY_MODE SECURITY_COMMERCIAL
  116. #if ( SECURE != 0 )
  117. #define USE_NWK_SECURITY 1 // true or false
  118. #define SECURITY_LEVEL 5
  119. #else
  120. #define USE_NWK_SECURITY 0 // true or false
  121. #define SECURITY_LEVEL 0
  122. #endif
  123. #elif ( STACK_PROFILE_ID == HOME_CONTROLS )
  124. #define MAX_NODE_DEPTH 5
  125. #define NWK_MODE NWK_MODE_MESH
  126. #define SECURITY_MODE SECURITY_COMMERCIAL
  127. #if ( SECURE != 0 )
  128. #define USE_NWK_SECURITY 1 // true or false
  129. #define SECURITY_LEVEL 5
  130. #else
  131. #define USE_NWK_SECURITY 0 // true or false
  132. #define SECURITY_LEVEL 0
  133. #endif
  134. #elif ( STACK_PROFILE_ID == GENERIC_STAR )
  135. #define MAX_NODE_DEPTH 5
  136. #define NWK_MODE NWK_MODE_STAR
  137. #define SECURITY_MODE SECURITY_RESIDENTIAL
  138. #if ( SECURE != 0 )
  139. #define USE_NWK_SECURITY 1 // true or false
  140. #define SECURITY_LEVEL 5
  141. #else
  142. #define USE_NWK_SECURITY 0 // true or false
  143. #define SECURITY_LEVEL 0
  144. #endif
  145. #elif ( STACK_PROFILE_ID == NETWORK_SPECIFIC )
  146. // define your own stack profile settings
  147. #define MAX_NODE_DEPTH 5
  148. #define NWK_MODE NWK_MODE_MESH
  149. #define SECURITY_MODE SECURITY_RESIDENTIAL
  150. #if ( SECURE != 0 )
  151. #define USE_NWK_SECURITY 1 // true or false
  152. #define SECURITY_LEVEL 5
  153. #else
  154. #define USE_NWK_SECURITY 0 // true or false
  155. #define SECURITY_LEVEL 0
  156. #endif
  157. #endif
  158. // Zigbee protocol version
  159. #define ZB_PROT_V1_0 1
  160. #define ZB_PROT_V1_1 2
  161. #define ZB_PROT_VERS ZB_PROT_V1_1
  162. #define ZIGBEE_PROT_ID 0x00
  163. // Status and error codes for extra information
  164. #define NWK_STATUS_PING_RCVD 0x0001
  165. #define NWK_STATUS_ASSOC_CNF 0x0002
  166. #define NWK_STATUS_ED_ADDR 0x0003
  167. #define NWK_STATUS_PARENT_ADDR 0x0004
  168. #define NWK_STATUS_COORD_ADDR 0x0005
  169. #define NWK_STATUS_ROUTER_ADDR 0x0006
  170. #define NWK_STATUS_ORPHAN_RSP 0x0007
  171. #define NWK_ERROR_ASSOC_RSP 0x1001
  172. #define NWK_ERROR_ASSOC_RSP_MF 0x1002
  173. #define NWK_ERROR_ASSOC_CNF_DENIED 0x1003
  174. #define NWK_ERROR_ENERGY_SCAN_FAILED 0x1004
  175. // Maximum number in tables
  176. #if !defined( NWK_MAX_DEVICE_LIST )
  177. #define NWK_MAX_DEVICE_LIST 20 // Maximum number of devices in the
  178. // Assoc/Device list.
  179. #endif
  180. // Don't change this value to set the number of devices. Change
  181. // NWK_MAX_DEVICE_LIST above
  182. #define NWK_MAX_DEVICES NWK_MAX_DEVICE_LIST + 1 // One extra space for parent
  183. #define NWK_MAX_ROUTERS 6
  184. #if ( ZG_BUILD_RTR_TYPE )
  185. #define MAX_NEIGHBOR_ENTRIES 8
  186. #else
  187. #define MAX_NEIGHBOR_ENTRIES 4
  188. #endif
  189. #if !defined ( APS_MAX_GROUPS )
  190. #define APS_MAX_GROUPS 10
  191. #endif
  192. // Maxiumum number of REFLECTOR address entries
  193. #if defined ( REFLECTOR )
  194. #define NWK_MAX_REFLECTOR_ENTRIES ( NWK_MAX_BINDING_ENTRIES )
  195. #else
  196. #define NWK_MAX_REFLECTOR_ENTRIES 0
  197. #endif
  198. #if !defined( MAX_BCAST )
  199. #define MAX_BCAST 4
  200. #endif
  201. // Maxiumum number of secure partners(Commercial mode only).
  202. // Add 1 for the Trust Center(Coordinator) if it is not the parent.
  203. #define NWK_MAX_SECURE_PARTNERS 1
  204. // Maximum number of addresses managed by the Address Manager
  205. #define NWK_MAX_ADDRESSES (uint16) \
  206. ( ( NWK_MAX_DEVICES ) + \
  207. ( NWK_MAX_REFLECTOR_ENTRIES ) + \
  208. ( NWK_MAX_SECURE_PARTNERS ) )
  209. // Network PAN Coordinator Address
  210. #define NWK_PAN_COORD_ADDR 0x0000
  211. // Network Addressing modes
  212. #define NWK_ADDRESSING_DISTRIBUTED 0x00
  213. #define NWK_ADDRESSING_STOCHASTIC 0x02
  214. #if !defined ( NWK_LINK_STATUS_PERIOD )
  215. #define NWK_LINK_STATUS_PERIOD 15 // 15 seconds
  216. #endif
  217. #if !defined ( NWK_ROUTE_AGE_LIMIT )
  218. #define NWK_ROUTE_AGE_LIMIT 3 // 3 missed link satus frames
  219. #endif
  220. #if !defined ( MAX_RTG_SRC_ENTRIES )
  221. #define MAX_RTG_SRC_ENTRIES 12
  222. #endif
  223. #if ( ZG_BUILD_ENDDEVICE_TYPE )
  224. #define APS_MAX_ENDDEVICE_BROADCAST_ENTRIES 5
  225. #endif
  226. /*********************************************************************
  227. * TYPEDEFS
  228. */
  229. /*********************************************************************
  230. * NWK GLOBAL VARIABLES
  231. */
  232. // Variables for MAX data buffer levels
  233. extern CONST byte gNWK_MAX_DATABUFS_WAITING;
  234. extern CONST byte gNWK_MAX_DATABUFS_SCHEDULED;
  235. extern CONST byte gNWK_MAX_DATABUFS_CONFIRMED;
  236. extern CONST byte gNWK_MAX_DATABUFS_TOTAL;
  237. extern CONST byte gNWK_INDIRECT_CNT_RTG_TMR;
  238. extern CONST byte gNWK_INDIRECT_MSG_MAX_PER;
  239. extern CONST byte gNWK_INDIRECT_MSG_MAX_ALL;
  240. extern CONST byte gMAX_NEIGHBOR_ENTRIES;
  241. extern CONST byte gMAX_RTG_ENTRIES;
  242. extern CONST byte gMAX_RTG_SRC_ENTRIES;
  243. extern CONST byte gMAX_RREQ_ENTRIES;
  244. // Variables for MAX list size
  245. extern CONST uint16 gNWK_MAX_DEVICE_LIST;
  246. // Variables for MAX Sleeping End Devices
  247. extern CONST uint8 gNWK_MAX_SLEEPING_END_DEVICES;
  248. extern CONST uint8 gNWK_TREE_ALLOCATE_ROUTERADDR_FOR_ENDDEVICE;
  249. extern uint16 *Cskip;
  250. extern byte CskipRtrs[];
  251. extern byte CskipChldrn[];
  252. extern byte gMIN_TREE_LINK_COST;
  253. extern CONST byte defaultKey[];
  254. extern CONST byte defaultTCLinkKey[];
  255. extern CONST byte gMAX_BCAST;
  256. /*********************************************************************
  257. * APS GLOBAL VARIABLES
  258. */
  259. // Variables for Binding Table
  260. extern CONST uint16 gNWK_MAX_BINDING_ENTRIES;
  261. extern CONST byte gMAX_BINDING_CLUSTER_IDS;
  262. extern CONST uint16 gBIND_REC_SIZE;
  263. extern CONST uint8 gAPS_MAX_GROUPS;
  264. extern uint8 gAPS_MAX_ENDDEVICE_BROADCAST_ENTRIES;
  265. /*********************************************************************
  266. * FUNCTIONS
  267. */
  268. /*
  269. * Init Global Variables
  270. */
  271. extern void nwk_globals_init( void );
  272. extern void NIB_init( void );
  273. extern void nwk_Status( uint16 statusCode, uint16 statusValue );
  274. /*********************************************************************
  275. *********************************************************************/
  276. #ifdef __cplusplus
  277. }
  278. #endif
  279. #endif /* NWK_GLOBALS_H */