nwk_globals.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583
  1. /**************************************************************************************************
  2. Filename: nwk_globals.c
  3. Revised: $Date: 2012-03-07 01:04:58 -0800 (Wed, 07 Mar 2012) $
  4. Revision: $Revision: 29656 $
  5. Description: User definable Network Parameters.
  6. Copyright 2004-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. /*********************************************************************
  34. * INCLUDES
  35. */
  36. #include "ZComdef.h"
  37. #include "OSAL.h"
  38. #include "OSAL_Nv.h"
  39. #include "AddrMgr.h"
  40. #include "AssocList.h"
  41. #include "BindingTable.h"
  42. #include "nwk_util.h"
  43. #include "nwk_globals.h"
  44. #include "APS.h"
  45. #include "ssp.h"
  46. #include "rtg.h"
  47. #include "ZDConfig.h"
  48. #include "ZGlobals.h"
  49. #if defined ( LCD_SUPPORTED )
  50. #include "OnBoard.h"
  51. #endif
  52. /* HAL */
  53. #include "hal_lcd.h"
  54. /*********************************************************************
  55. * MACROS
  56. */
  57. /*********************************************************************
  58. * CONSTANTS
  59. */
  60. // Maximums for the data buffer queue
  61. #define NWK_MAX_DATABUFS_WAITING 8 // Waiting to be sent to MAC
  62. #define NWK_MAX_DATABUFS_SCHEDULED 5 // Timed messages to be sent
  63. #define NWK_MAX_DATABUFS_CONFIRMED 5 // Held after MAC confirms
  64. #define NWK_MAX_DATABUFS_TOTAL 12 // Total number of buffers
  65. // 1-255 (0 -> 256) X RTG_TIMER_INTERVAL
  66. // A known shortcoming is that when a message is enqueued as "hold" for a
  67. // sleeping device, the timer tick may have counted down to 1, so that msg
  68. // will not be held as long as expected. If NWK_INDIRECT_MSG_TIMEOUT is set to 1
  69. // the hold time will vary randomly from 0 - CNT_RTG_TIMER ticks.
  70. // So the hold time will vary within this interval:
  71. // { (NWK_INDIRECT_MSG_TIMEOUT-1)*CNT_RTG_TIMER,
  72. // NWK_INDIRECT_MSG_TIMEOUT*CNT_RTG_TIMER }
  73. #define NWK_INDIRECT_CNT_RTG_TMR 1
  74. // To hold msg for sleeping end devices for 30 secs:
  75. // #define CNT_RTG_TIMER 1
  76. // #define NWK_INDIRECT_MSG_TIMEOUT 30
  77. // To hold msg for sleeping end devices for 30 mins:
  78. // #define CNT_RTG_TIMER 60
  79. // #define NWK_INDIRECT_MSG_TIMEOUT 30
  80. // To hold msg for sleeping end devices for 30 days:
  81. // #define CNT_RTG_TIMER 60
  82. // #define NWK_INDIRECT_MSG_TIMEOUT (30 * 24 * 60)
  83. // Maximum msgs to hold per associated device.
  84. #define NWK_INDIRECT_MSG_MAX_PER 3
  85. // Maximum total msgs to hold for all associated devices.
  86. #define NWK_INDIRECT_MSG_MAX_ALL \
  87. (NWK_MAX_DATABUFS_TOTAL - NWK_INDIRECT_MSG_MAX_PER)
  88. /*********************************************************************
  89. * TYPEDEFS
  90. */
  91. /*********************************************************************
  92. * NWK GLOBAL VARIABLES
  93. */
  94. // Variables for MAX list size
  95. CONST uint16 gNWK_MAX_DEVICE_LIST = NWK_MAX_DEVICES;
  96. // Variables for MAX Sleeping End Devices
  97. CONST uint8 gNWK_MAX_SLEEPING_END_DEVICES = NWK_MAX_DEVICES - NWK_MAX_ROUTERS;
  98. // Variables for MAX data buffer levels
  99. CONST uint8 gNWK_MAX_DATABUFS_WAITING = NWK_MAX_DATABUFS_WAITING;
  100. CONST uint8 gNWK_MAX_DATABUFS_SCHEDULED = NWK_MAX_DATABUFS_SCHEDULED;
  101. CONST uint8 gNWK_MAX_DATABUFS_CONFIRMED = NWK_MAX_DATABUFS_CONFIRMED;
  102. CONST uint8 gNWK_MAX_DATABUFS_TOTAL = NWK_MAX_DATABUFS_TOTAL;
  103. CONST uint8 gNWK_INDIRECT_CNT_RTG_TMR = NWK_INDIRECT_CNT_RTG_TMR;
  104. CONST uint8 gNWK_INDIRECT_MSG_MAX_PER = NWK_INDIRECT_MSG_MAX_PER;
  105. CONST uint8 gNWK_INDIRECT_MSG_MAX_ALL = NWK_INDIRECT_MSG_MAX_ALL;
  106. // change this if using a different stack profile...
  107. // Cskip array
  108. uint16 *Cskip;
  109. #if ( STACK_PROFILE_ID == ZIGBEEPRO_PROFILE )
  110. uint8 CskipRtrs[1] = {0};
  111. uint8 CskipChldrn[1] = {0};
  112. #elif ( STACK_PROFILE_ID == HOME_CONTROLS )
  113. uint8 CskipRtrs[MAX_NODE_DEPTH+1] = {6,6,6,6,6,0};
  114. uint8 CskipChldrn[MAX_NODE_DEPTH+1] = {20,20,20,20,20,0};
  115. #elif ( STACK_PROFILE_ID == GENERIC_STAR )
  116. uint8 CskipRtrs[MAX_NODE_DEPTH+1] = {5,5,5,5,5,0};
  117. uint8 CskipChldrn[MAX_NODE_DEPTH+1] = {5,5,5,5,5,0};
  118. #elif ( STACK_PROFILE_ID == NETWORK_SPECIFIC )
  119. uint8 CskipRtrs[MAX_NODE_DEPTH+1] = {5,5,5,5,5,0};
  120. uint8 CskipChldrn[MAX_NODE_DEPTH+1] = {5,5,5,5,5,0};
  121. #endif // STACK_PROFILE_ID
  122. // Minimum lqi value that is required for association
  123. uint8 gMIN_TREE_LINK_COST = MIN_LQI_COST_3;
  124. // Statically defined Associated Device List
  125. associated_devices_t AssociatedDevList[NWK_MAX_DEVICES];
  126. #if defined ( ZIGBEE_STOCHASTIC_ADDRESSING )
  127. CONST uint16 gNWK_MIN_ROUTER_CHILDREN = NWK_MIN_ROUTER_CHILDREN;
  128. CONST uint16 gNWK_MIN_ENDDEVICE_CHILDREN = NWK_MIN_ENDDEVICE_CHILDREN;
  129. #else
  130. CONST uint16 gNWK_MIN_ROUTER_CHILDREN = 0;
  131. CONST uint16 gNWK_MIN_ENDDEVICE_CHILDREN = 0;
  132. #endif
  133. CONST uint16 gMAX_RTG_ENTRIES = MAX_RTG_ENTRIES;
  134. CONST uint16 gMAX_RTG_SRC_ENTRIES = MAX_RTG_SRC_ENTRIES;
  135. CONST uint8 gMAX_RREQ_ENTRIES = MAX_RREQ_ENTRIES;
  136. CONST uint8 gMAX_NEIGHBOR_ENTRIES = MAX_NEIGHBOR_ENTRIES;
  137. // Table of neighboring nodes (not including child nodes)
  138. neighborEntry_t neighborTable[MAX_NEIGHBOR_ENTRIES];
  139. CONST uint8 gMAX_SOURCE_ROUTE = MAX_SOURCE_ROUTE;
  140. CONST uint8 gMAX_BROADCAST_QUEUED = MAX_BROADCAST_QUEUED;
  141. CONST uint8 gLINK_DOWN_TRIGGER = LINK_DOWN_TRIGGER;
  142. CONST uint8 gMAX_PASSIVE_ACK_CNT = MAX_PASSIVE_ACK_CNT;
  143. // Routing table
  144. rtgEntry_t rtgTable[MAX_RTG_ENTRIES];
  145. #if defined ( ZIGBEE_SOURCE_ROUTING )
  146. rtgSrcEntry_t rtgSrcTable[MAX_RTG_SRC_ENTRIES];
  147. uint16 rtgSrcRelayList[MAX_SOURCE_ROUTE];
  148. #endif
  149. // Table of current RREQ packets in the network
  150. rtDiscEntry_t rtDiscTable[MAX_RREQ_ENTRIES];
  151. // Table of data broadcast packets currently in circulation.
  152. bcastEntry_t bcastTable[MAX_BCAST];
  153. // These 2 arrays are to be used as an array of struct { uint8, uint32 }.
  154. uint8 bcastHoldHandle[MAX_BCAST];
  155. uint32 bcastHoldAckMask[MAX_BCAST];
  156. CONST uint8 gMAX_BCAST = MAX_BCAST;
  157. // For tree addressing, this switch allows the allocation of a
  158. // router address to an end device when end device address are
  159. // all used up. If this option is enabled, address space
  160. // could be limited.
  161. CONST uint8 gNWK_TREE_ALLOCATE_ROUTERADDR_FOR_ENDDEVICE = FALSE;
  162. #if defined ( ZIGBEE_STOCHASTIC_ADDRESSING )
  163. // number of link status periods after the last received address conflict report
  164. // (network status command)
  165. CONST uint8 gNWK_CONFLICTED_ADDR_EXPIRY_TIME = NWK_CONFLICTED_ADDR_EXPIRY_TIME;
  166. #endif
  167. #if defined ( ZIGBEE_FREQ_AGILITY )
  168. CONST uint8 gNWK_FREQ_AGILITY_ALL_MAC_ERRS = NWK_FREQ_AGILITY_ALL_MAC_ERRS;
  169. #endif
  170. // The time limited to one MTO RReq (Concentrator Announce) in milliseconds.
  171. CONST uint16 gMTO_RREQ_LIMIT_TIME = MTO_RREQ_LIMIT_TIME;
  172. // The number of seconds a MTO routing entry will last.
  173. CONST uint8 gMTO_ROUTE_EXPIRY_TIME = MTO_ROUTE_EXPIRY_TIME;
  174. // Route Discovery Request Default Radius
  175. CONST uint8 gDEFAULT_ROUTE_REQUEST_RADIUS = DEFAULT_ROUTE_REQUEST_RADIUS;
  176. // Network message radius
  177. CONST uint8 gDEF_NWK_RADIUS = DEF_NWK_RADIUS;
  178. #if ( ZSTACK_ROUTER_BUILD )
  179. CONST uint16 gLINK_STATUS_JITTER_MASK = LINK_STATUS_JITTER_MASK;
  180. #endif
  181. /*********************************************************************
  182. * APS GLOBAL VARIABLES
  183. */
  184. // The Maximum number of binding records
  185. // This number is defined in f8wConfig.cfg - change it there.
  186. CONST uint16 gNWK_MAX_BINDING_ENTRIES = NWK_MAX_BINDING_ENTRIES;
  187. #if defined ( REFLECTOR )
  188. // The Maximum number of cluster IDs in a binding record
  189. // This number is defined in f8wConfig.cfg - change it there.
  190. CONST uint8 gMAX_BINDING_CLUSTER_IDS = MAX_BINDING_CLUSTER_IDS;
  191. CONST uint16 gBIND_REC_SIZE = sizeof( BindingEntry_t );
  192. // Binding Table
  193. BindingEntry_t BindingTable[NWK_MAX_BINDING_ENTRIES];
  194. #endif
  195. // Maximum number allowed in the groups table.
  196. CONST uint8 gAPS_MAX_GROUPS = APS_MAX_GROUPS;
  197. // APS End Device Broadcast Table
  198. #if ( ZG_BUILD_ENDDEVICE_TYPE )
  199. apsEndDeviceBroadcast_t apsEndDeviceBroadcastTable[APS_MAX_ENDDEVICE_BROADCAST_ENTRIES];
  200. uint8 gAPS_MAX_ENDDEVICE_BROADCAST_ENTRIES = APS_MAX_ENDDEVICE_BROADCAST_ENTRIES;
  201. #endif
  202. /*********************************************************************
  203. * SECURITY GLOBAL VARIABLES
  204. */
  205. // This is the default pre-configured key,
  206. // change this to make a unique key
  207. // SEC_KEY_LEN is defined in ssp.h.
  208. #if defined ( DEFAULT_KEY )
  209. CONST uint8 defaultKey[SEC_KEY_LEN] = DEFAULT_KEY;
  210. #else
  211. CONST uint8 defaultKey[SEC_KEY_LEN] =
  212. {
  213. #if defined ( APP_TP ) || defined ( APP_TP2 )
  214. // Key for ZigBee Conformance Testing
  215. 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb, 0xbb,
  216. 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa
  217. #else
  218. // Key for In-House Testing
  219. 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
  220. 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
  221. #endif
  222. };
  223. #endif
  224. // This is the default pre-configured Trust Center Link key,
  225. // change this to make a unique key, SEC_KEY_LEN is defined in ssp.h.
  226. CONST uint8 defaultTCLinkKey[SEC_KEY_LEN] = DEFAULT_TC_LINK_KEY;
  227. /*********************************************************************
  228. * GLOBAL VARIABLES - Statistics
  229. */
  230. #if defined ( PACKET_FILTER_STATS )
  231. uint32 apsInvalidPackets = 0;
  232. uint32 apsSecurityFailures = 0;
  233. uint32 nwkInvalidPackets = 0;
  234. uint32 nwkSecurityFailures = 0;
  235. #endif
  236. /*********************************************************************
  237. * STATUS STRINGS
  238. */
  239. #if defined ( LCD_SUPPORTED )
  240. const char PingStr[] = "Ping Rcvd from";
  241. const char AssocCnfStr[] = "Assoc Cnf";
  242. const char SuccessStr[] = "Success";
  243. const char EndDeviceStr[] = "EndDevice:";
  244. const char ParentStr[] = "Parent:";
  245. const char ZigbeeCoordStr[] = "ZigBee Coord";
  246. const char NetworkIDStr[] = "Network ID:";
  247. const char RouterStr[] = "Router:";
  248. const char OrphanRspStr[] = "Orphan Response";
  249. const char SentStr[] = "Sent";
  250. const char FailedStr[] = "Failed";
  251. const char AssocRspFailStr[] = "Assoc Rsp fail";
  252. const char AssocIndStr[] = "Assoc Ind";
  253. const char AssocCnfFailStr[] = "Assoc Cnf fail";
  254. const char EnergyLevelStr[] = "Energy Level";
  255. const char ScanFailedStr[] = "Scan Failed";
  256. #endif
  257. /*********************************************************************
  258. * @fn nwk_globals_init()
  259. *
  260. * @brief
  261. *
  262. * Initialize nwk layer globals. These are the system defaults and
  263. * should be changed by the user here. The default definitions are
  264. * defined in nwk.h or NLMEDE.h.
  265. *
  266. * @param none
  267. *
  268. * @return none
  269. */
  270. void nwk_globals_init( void )
  271. {
  272. AddrMgrInit( NWK_MAX_ADDRESSES );
  273. #if !defined ( ZIGBEE_STOCHASTIC_ADDRESSING )
  274. if ( ZSTACK_ROUTER_BUILD )
  275. {
  276. // Initialize the Cskip Table
  277. Cskip = osal_mem_alloc(sizeof(uint16) *(MAX_NODE_DEPTH+1));
  278. RTG_FillCSkipTable(CskipChldrn, CskipRtrs, MAX_NODE_DEPTH, Cskip);
  279. }
  280. #endif
  281. // To compile out the Link Status Feature, set NWK_LINK_STATUS_PERIOD
  282. // to 0 (compiler flag).
  283. if ( ZSTACK_ROUTER_BUILD && NWK_LINK_STATUS_PERIOD )
  284. {
  285. NLME_InitLinkStatus();
  286. }
  287. #if defined ( ZIGBEE_FREQ_AGILITY )
  288. NwkFreqAgilityInit();
  289. #endif
  290. }
  291. /*********************************************************************
  292. * @fn NIB_init()
  293. *
  294. * @brief
  295. *
  296. * Initialize attribute values in NIB
  297. *
  298. * @param none
  299. *
  300. * @return none
  301. */
  302. void NIB_init()
  303. {
  304. _NIB.SequenceNum = LO_UINT16(osal_rand());
  305. _NIB.nwkProtocolVersion = ZB_PROT_VERS;
  306. _NIB.MaxDepth = MAX_NODE_DEPTH;
  307. #if ( NWK_MODE == NWK_MODE_MESH )
  308. _NIB.beaconOrder = BEACON_ORDER_NO_BEACONS;
  309. _NIB.superFrameOrder = BEACON_ORDER_NO_BEACONS;
  310. #endif
  311. // BROADCAST SETTINGS:
  312. // *******************
  313. // Broadcast Delivery Time
  314. // - set to multiples of 100ms
  315. // - should be 500ms more than the retry time
  316. // - "retry time" = PassiveAckTimeout * (MaxBroadcastRetries + 1)
  317. // Passive Ack Timeout
  318. // - set to multiples of 100ms
  319. _NIB.BroadcastDeliveryTime = zgBcastDeliveryTime;
  320. _NIB.PassiveAckTimeout = zgPassiveAckTimeout;
  321. _NIB.MaxBroadcastRetries = zgMaxBcastRetires;
  322. _NIB.ReportConstantCost = 0;
  323. _NIB.RouteDiscRetries = 0;
  324. _NIB.SecureAllFrames = USE_NWK_SECURITY;
  325. _NIB.nwkAllFresh = NWK_ALL_FRESH;
  326. if ( ZG_SECURE_ENABLED )
  327. {
  328. _NIB.SecurityLevel = SECURITY_LEVEL;
  329. }
  330. else
  331. {
  332. _NIB.SecurityLevel = 0;
  333. }
  334. #if defined ( ZIGBEEPRO )
  335. _NIB.SymLink = FALSE;
  336. #else
  337. _NIB.SymLink = TRUE;
  338. #endif
  339. _NIB.CapabilityFlags = ZDO_Config_Node_Descriptor.CapabilityFlags;
  340. _NIB.TransactionPersistenceTime = zgIndirectMsgTimeout;
  341. _NIB.RouteDiscoveryTime = zgRouteDiscoveryTime;
  342. _NIB.RouteExpiryTime = zgRouteExpiryTime;
  343. _NIB.nwkDevAddress = INVALID_NODE_ADDR;
  344. _NIB.nwkLogicalChannel = 0;
  345. _NIB.nwkCoordAddress = INVALID_NODE_ADDR;
  346. osal_memset( _NIB.nwkCoordExtAddress, 0, Z_EXTADDR_LEN );
  347. _NIB.nwkPanId = INVALID_NODE_ADDR;
  348. osal_cpyExtAddr( _NIB.extendedPANID, zgExtendedPANID );
  349. _NIB.nwkKeyLoaded = FALSE;
  350. #if defined ( ZIGBEE_STOCHASTIC_ADDRESSING )
  351. _NIB.nwkAddrAlloc = NWK_ADDRESSING_STOCHASTIC;
  352. _NIB.nwkUniqueAddr = FALSE;
  353. #else
  354. _NIB.nwkAddrAlloc = NWK_ADDRESSING_DISTRIBUTED;
  355. _NIB.nwkUniqueAddr = TRUE;
  356. #endif
  357. _NIB.nwkLinkStatusPeriod = NWK_LINK_STATUS_PERIOD;
  358. _NIB.nwkRouterAgeLimit = NWK_ROUTE_AGE_LIMIT;
  359. //MTO and source routing
  360. _NIB.nwkConcentratorDiscoveryTime = zgConcentratorDiscoveryTime;
  361. _NIB.nwkIsConcentrator = zgConcentratorEnable;
  362. _NIB.nwkConcentratorRadius = zgConcentratorRadius;
  363. #if defined ( ZIGBEE_MULTICAST )
  364. _NIB.nwkUseMultiCast = TRUE;
  365. #else
  366. _NIB.nwkUseMultiCast = FALSE;
  367. #endif
  368. #if defined ( NV_RESTORE )
  369. if ( osal_nv_read( ZCD_NV_NWKMGR_ADDR, 0, sizeof( _NIB.nwkManagerAddr ),
  370. &_NIB.nwkManagerAddr ) != SUCCESS )
  371. #endif
  372. {
  373. _NIB.nwkManagerAddr = 0x0000;
  374. }
  375. _NIB.nwkUpdateId = 0;
  376. _NIB.nwkTotalTransmissions = 0;
  377. if ( ZSTACK_ROUTER_BUILD )
  378. {
  379. #if defined ( ZIGBEE_STOCHASTIC_ADDRESSING )
  380. NLME_InitStochasticAddressing();
  381. #else
  382. NLME_InitTreeAddressing();
  383. #endif
  384. }
  385. }
  386. /*********************************************************************
  387. * @fn nwk_Status()
  388. *
  389. * @brief
  390. *
  391. * Status report.
  392. *
  393. * @param statusCode
  394. * @param statusValue
  395. *
  396. * @return none
  397. */
  398. void nwk_Status( uint16 statusCode, uint16 statusValue )
  399. {
  400. #if defined ( LCD_SUPPORTED )
  401. switch ( statusCode )
  402. {
  403. case NWK_STATUS_COORD_ADDR:
  404. if ( ZSTACK_ROUTER_BUILD )
  405. {
  406. //HalLcdWriteString( (char*)ZigbeeCoordStr, HAL_LCD_LINE_1 );
  407. // HalLcdWriteStringValue( (char*)NetworkIDStr, statusValue, 16, HAL_LCD_LINE_2 );
  408. BuzzerControl( BUZZER_BLIP );
  409. }
  410. break;
  411. case NWK_STATUS_ROUTER_ADDR:
  412. if ( ZSTACK_ROUTER_BUILD )
  413. {
  414. // HalLcdWriteStringValue( (char*)RouterStr, statusValue, 16, HAL_LCD_LINE_1 );
  415. }
  416. break;
  417. case NWK_STATUS_ORPHAN_RSP:
  418. if ( ZSTACK_ROUTER_BUILD )
  419. {
  420. // if ( statusValue == ZSuccess )
  421. // HalLcdWriteScreen( (char*)OrphanRspStr, (char*)SentStr );
  422. // else
  423. // HalLcdWriteScreen( (char*)OrphanRspStr, (char*)FailedStr );
  424. }
  425. break;
  426. case NWK_ERROR_ASSOC_RSP:
  427. if ( ZSTACK_ROUTER_BUILD )
  428. {
  429. // HalLcdWriteString( (char*)AssocRspFailStr, HAL_LCD_LINE_1 );
  430. // HalLcdWriteValue( (uint32)(statusValue), 16, HAL_LCD_LINE_2 );
  431. }
  432. break;
  433. case NWK_STATUS_ED_ADDR:
  434. if ( ZSTACK_END_DEVICE_BUILD )
  435. {
  436. // HalLcdWriteStringValue( (char*)EndDeviceStr, statusValue, 16, HAL_LCD_LINE_1 );
  437. }
  438. break;
  439. case NWK_STATUS_PARENT_ADDR:
  440. // HalLcdWriteStringValue( (char*)ParentStr, statusValue, 16, HAL_LCD_LINE_2 );
  441. break;
  442. case NWK_STATUS_ASSOC_CNF:
  443. // HalLcdWriteScreen( (char*)AssocCnfStr, (char*)SuccessStr );
  444. break;
  445. case NWK_ERROR_ASSOC_CNF_DENIED:
  446. // HalLcdWriteString((char*)AssocCnfFailStr, HAL_LCD_LINE_1 );
  447. // HalLcdWriteValue( (uint32)(statusValue), 16, HAL_LCD_LINE_2 );
  448. break;
  449. case NWK_ERROR_ENERGY_SCAN_FAILED:
  450. // HalLcdWriteScreen( (char*)EnergyLevelStr, (char*)ScanFailedStr );
  451. break;
  452. }
  453. #endif
  454. }
  455. /*********************************************************************
  456. * @fn nwk_UpdateStatistics()
  457. *
  458. * @brief Update network layer statistic counters
  459. *
  460. * @param statisticCode
  461. *
  462. * @return none
  463. */
  464. void nwk_UpdateStatistics( uint8 statisticCode )
  465. {
  466. #if defined ( PACKET_FILTER_STATS )
  467. switch ( statisticCode )
  468. {
  469. case STAT_NWK_INVALID_PACKET:
  470. nwkInvalidPackets++;
  471. break;
  472. case STAT_NWK_SECURITY_FAILURE:
  473. nwkInvalidPackets++;
  474. nwkSecurityFailures++;
  475. break;
  476. case STAT_APS_INVALID_PACKET:
  477. apsInvalidPackets++;
  478. break;
  479. case STAT_APS_SECURITY_FAILURE:
  480. apsSecurityFailures++;
  481. break;
  482. }
  483. #endif
  484. }
  485. /*********************************************************************
  486. *********************************************************************/