///////////////////////////////////////////////////////////////////////////////
//                                                                            /
// IAR 8051 C/C++ Compiler V7.30B/W32                   19/May/2010  09:38:58 /
// Copyright 2004-2007 IAR Systems. All rights reserved.                      /
//                                                                            /
//    Core               =  plain                                             /
//    Code model         =  banked                                            /
//    Data model         =  large                                             /
//    Calling convention =  xdata reentrant                                   /
//    Constant location  =  data                                              /
//    Dptr setup         =  1,16                                              /
//    Source file        =  C:\Texas Instruments\ZStack-1.4.3-1.2.1\Component /
//                          s\stack\nwk\nwk_globals.c                         /
//    Command line       =  -f "C:\Texas Instruments\ZStack-1.4.3-1.2.1\Proje /
//                          cts\zstack\Samples\Location\CC2430DB\..\..\..\Too /
//                          ls\CC2430DB\f8wCoord.cfg" (-DCPU32MHZ             /
//                          -DFORCE_MAC_NEAR -DROOT=__near_func               /
//                          -DMAC_CFG_APP_PENDING_QUEUE=TRUE                  /
//                          -DZDO_COORDINATOR -DRTR_NWK -DBLINK_LEDS          /
//                          "-DCONST=const __code" -DGENERIC=__generic) -f    /
//                          "C:\Texas Instruments\ZStack-1.4.3-1.2.1\Projects /
//                          \zstack\Samples\Location\CC2430DB\..\..\..\Tools\ /
//                          CC2430DB\f8wConfig.cfg" (-DSECURE=1               /
//                          -DDEFAULT_CHANLIST=0x04000000                     /
//                          -DZDAPP_CONFIG_PAN_ID=0x00FF                      /
//                          -DNWK_START_DELAY=100 -DEXTENDED_JOINING_RANDOM_M /
//                          ASK=0x007F -DBEACON_REQUEST_DELAY=100             /
//                          -DBEACON_REQ_DELAY_MASK=0x00FF                    /
//                          -DROUTE_EXPIRY_TIME=30 -DAPSC_ACK_WAIT_DURATION_P /
//                          OLLED=3000 -DNWK_INDIRECT_MSG_TIMEOUT=7           /
//                          -DMAX_RREQ_ENTRIES=10 -DAPSC_MAX_FRAME_RETRIES=3  /
//                          -DNWK_MAX_DATA_RETRIES=2                          /
//                          -DMAX_POLL_FAILURE_RETRIES=2 -DMAX_BCAST=9        /
//                          -DAPS_MAX_GROUPS=16 -DMAX_RTG_ENTRIES=20          /
//                          -DNWK_MAX_BINDING_ENTRIES=10                      /
//                          -DMAX_BINDING_CLUSTER_IDS=5                       /
//                          "-DDEFAULT_KEY={0x02, 0x03, 0x05, 0x07, 0x09,     /
//                          0x0B, 0x0D, 0x0F, 0x00, 0x02, 0x04, 0x06, 0x08,   /
//                          0x0A, 0x0C, 0x0D}" -DRFD_RCVC_ALWAYS_ON=FALSE     /
//                          -DPOLL_RATE=1000 -DQUEUED_POLL_RATE=100           /
//                          -DRESPONSE_POLL_RATE=100) -DREJOIN_POLL_RATE=440  /
//                          "C:\Texas Instruments\ZStack-1.4.3-1.2.1\Componen /
//                          ts\stack\nwk\nwk_globals.c" -D CC2430EB -D        /
//                          ZTOOL_P1 -D LOCATION_DONGLE -D MT_TASK -D         /
//                          xNV_RESTORE -D INT_HEAP_LEN=4608 -D               /
//                          HAL_UART_BIG_TX_BUF=1 -D                          /
//                          SPI_MGR_DEFAULT_MAX_TX_BUFF=1024 -D               /
//                          SPI_MGR_DEFAULT_OVERFLOW=1 -lC "C:\Texas          /
//                          Instruments\ZStack-1.4.3-1.2.1\Projects\zstack\Sa /
//                          mples\Location\CC2430DB\LocDongle\List\" -lA      /
//                          "C:\Texas Instruments\ZStack-1.4.3-1.2.1\Projects /
//                          \zstack\Samples\Location\CC2430DB\LocDongle\List\ /
//                          " --diag_suppress Pe001,Pa010 --diag_remark       /
//                          pe550 -o "C:\Texas Instruments\ZStack-1.4.3-1.2.1 /
//                          \Projects\zstack\Samples\Location\CC2430DB\LocDon /
//                          gle\Obj\" -e --require_prototypes -z9             /
//                          --no_code_motion --debug --core=plain             /
//                          --dptr=16,1 --data_model=large                    /
//                          --code_model=banked --calling_convention=xdata_re /
//                          entrant --place_constants=data --nr_virtual_regs  /
//                          8 -I "C:\Texas Instruments\ZStack-1.4.3-1.2.1\Pro /
//                          jects\zstack\Samples\Location\CC2430DB\" -I       /
//                          "C:\Texas Instruments\ZStack-1.4.3-1.2.1\Projects /
//                          \zstack\Samples\Location\CC2430DB\..\SOURCE\" -I  /
//                          "C:\Texas Instruments\ZStack-1.4.3-1.2.1\Projects /
//                          \zstack\Samples\Location\CC2430DB\..\..\..\ZMAIN\ /
//                          TI2430DB\" -I "C:\Texas                           /
//                          Instruments\ZStack-1.4.3-1.2.1\Projects\zstack\Sa /
//                          mples\Location\CC2430DB\..\..\..\..\WXL\INCLUDE\" /
//                           -I "C:\Texas Instruments\ZStack-1.4.3-1.2.1\Proj /
//                          ects\zstack\Samples\Location\CC2430DB\..\..\..\.. /
//                          \..\COMPONENTS\MT\" -I "C:\Texas                  /
//                          Instruments\ZStack-1.4.3-1.2.1\Projects\zstack\Sa /
//                          mples\Location\CC2430DB\..\..\..\..\..\COMPONENTS /
//                          \HAL\INCLUDE\" -I "C:\Texas                       /
//                          Instruments\ZStack-1.4.3-1.2.1\Projects\zstack\Sa /
//                          mples\Location\CC2430DB\..\..\..\..\..\COMPONENTS /
//                          \HAL\TARGET\CC2430EB\" -I "C:\Texas               /
//                          Instruments\ZStack-1.4.3-1.2.1\Projects\zstack\Sa /
//                          mples\Location\CC2430DB\..\..\..\..\..\COMPONENTS /
//                          \OSAL\MCU\CCSOC\" -I "C:\Texas                    /
//                          Instruments\ZStack-1.4.3-1.2.1\Projects\zstack\Sa /
//                          mples\Location\CC2430DB\..\..\..\..\..\COMPONENTS /
//                          \OSAL\INCLUDE\" -I "C:\Texas                      /
//                          Instruments\ZStack-1.4.3-1.2.1\Projects\zstack\Sa /
//                          mples\Location\CC2430DB\..\..\..\..\..\COMPONENTS /
//                          \STACK\AF\" -I "C:\Texas                          /
//                          Instruments\ZStack-1.4.3-1.2.1\Projects\zstack\Sa /
//                          mples\Location\CC2430DB\..\..\..\..\..\COMPONENTS /
//                          \STACK\NWK\" -I "C:\Texas                         /
//                          Instruments\ZStack-1.4.3-1.2.1\Projects\zstack\Sa /
//                          mples\Location\CC2430DB\..\..\..\..\..\COMPONENTS /
//                          \STACK\SEC\" -I "C:\Texas                         /
//                          Instruments\ZStack-1.4.3-1.2.1\Projects\zstack\Sa /
//                          mples\Location\CC2430DB\..\..\..\..\..\COMPONENTS /
//                          \STACK\SYS\" -I "C:\Texas                         /
//                          Instruments\ZStack-1.4.3-1.2.1\Projects\zstack\Sa /
//                          mples\Location\CC2430DB\..\..\..\..\..\COMPONENTS /
//                          \STACK\ZDO\" -I "C:\Texas                         /
//                          Instruments\ZStack-1.4.3-1.2.1\Projects\zstack\Sa /
//                          mples\Location\CC2430DB\..\..\..\..\..\COMPONENTS /
//                          \ZMAC\F8W\" -I "C:\Texas                          /
//                          Instruments\ZStack-1.4.3-1.2.1\Projects\zstack\Sa /
//                          mples\Location\CC2430DB\..\..\..\..\..\COMPONENTS /
//                          \ZMAC\" -I "C:\Texas Instruments\ZStack-1.4.3-1.2 /
//                          .1\Projects\zstack\Samples\Location\CC2430DB\..\. /
//                          .\..\..\..\COMPONENTS\SERVICES\SADDR\" -I         /
//                          "C:\Texas Instruments\ZStack-1.4.3-1.2.1\Projects /
//                          \zstack\Samples\Location\CC2430DB\..\..\..\..\..\ /
//                          COMPONENTS\SERVICES\SDATA\" -I "C:\Texas          /
//                          Instruments\ZStack-1.4.3-1.2.1\Projects\zstack\Sa /
//                          mples\Location\CC2430DB\..\..\..\..\..\COMPONENTS /
//                          \MAC\INCLUDE\" -I "C:\Texas                       /
//                          Instruments\ZStack-1.4.3-1.2.1\Projects\zstack\Sa /
//                          mples\Location\CC2430DB\..\..\..\..\..\COMPONENTS /
//                          \MAC\HIGH_LEVEL\" -I "C:\Texas                    /
//                          Instruments\ZStack-1.4.3-1.2.1\Projects\zstack\Sa /
//                          mples\Location\CC2430DB\..\..\..\..\..\COMPONENTS /
//                          \MAC\LOW_LEVEL\SRF03\" -I "C:\Texas               /
//                          Instruments\ZStack-1.4.3-1.2.1\Projects\zstack\Sa /
//                          mples\Location\CC2430DB\..\..\..\..\..\COMPONENTS /
//                          \MAC\LOW_LEVEL\SRF03\SINGLE_CHIP\" -I             /
//                          "C:\Program Files\IAR Systems\Embedded Workbench  /
//                          4.0 Evaluation version\8051\INC\" -I "C:\Program  /
//                          Files\IAR Systems\Embedded Workbench 4.0          /
//                          Evaluation version\8051\INC\CLIB\"                /
//    List file          =  C:\Texas Instruments\ZStack-1.4.3-1.2.1\Projects\ /
//                          zstack\Samples\Location\CC2430DB\LocDongle\List\n /
//                          wk_globals.s51                                    /
//                                                                            /
//                                                                            /
///////////////////////////////////////////////////////////////////////////////

        NAME nwk_globals

        RTMODEL "__calling_convention", "xdata_reentrant"
        RTMODEL "__code_model", "banked"
        RTMODEL "__core", "plain"
        RTMODEL "__data_model", "large"
        RTMODEL "__dptr_size", "16"
        RTMODEL "__extended_stack", "disabled"
        RTMODEL "__location_for_constants", "data"
        RTMODEL "__number_of_dptrs", "1"
        RTMODEL "__rt_version", "1"

        RSEG DOVERLAY:DATA:NOROOT(0)
        RSEG IOVERLAY:IDATA:NOROOT(0)
        RSEG ISTACK:IDATA:NOROOT(0)
        RSEG PSTACK:XDATA:NOROOT(0)
        RSEG XSTACK:XDATA:NOROOT(0)

        EXTERN ?BDISPATCH
        EXTERN ?BRET
        EXTERN ?DEALLOC_XSTACK8
        EXTERN ?PUSH_XSTACK8_X_TWO
        EXTERN __INIT_XDATA_I
        EXTERN __INIT_XDATA_Z

        PUBLIC ??NIB_init?relay
        FUNCTION ??NIB_init?relay,0203H
        PUBLIC ??nwk_Status?relay
        FUNCTION ??nwk_Status?relay,0203H
        PUBLIC ??nwk_globals_init?relay
        FUNCTION ??nwk_globals_init?relay,0203H
        PUBLIC AssociatedDevList
        PUBLIC Cskip
        PUBLIC CskipChldrn
        PUBLIC CskipRtrs
        PUBLIC NIB_init
        FUNCTION NIB_init,021203H
        ARGFRAME XSTACK, 0, STACK
        LOCFRAME ISTACK, 2, STACK
        PUBLIC apscMaxWindowSize
        PUBLIC bcastHoldAckMask
        PUBLIC bcastHoldHandle
        PUBLIC bcastTable
        PUBLIC defaultKey
        PUBLIC gAPS_INTERFRAME_DELAY
        PUBLIC gAPS_MAX_GROUPS
        PUBLIC gMAX_BCAST
        PUBLIC gMAX_NEIGHBOR_ENTRIES
        PUBLIC gMAX_RREQ_ENTRIES
        PUBLIC gMAX_RTG_ENTRIES
        PUBLIC gMAX_UNRESERVED_RTG_ENTRIES
        PUBLIC gMIN_TREE_LINK_COST
        PUBLIC gNWK_INDIRECT_CNT_RTG_TMR
        PUBLIC gNWK_INDIRECT_MSG_MAX_ALL
        PUBLIC gNWK_INDIRECT_MSG_MAX_PER
        PUBLIC gNWK_MAX_BINDING_ENTRIES
        PUBLIC gNWK_MAX_DATABUFS_CONFIRMED
        PUBLIC gNWK_MAX_DATABUFS_SCHEDULED
        PUBLIC gNWK_MAX_DATABUFS_TOTAL
        PUBLIC gNWK_MAX_DATABUFS_WAITING
        PUBLIC gNWK_MAX_DEVICE_LIST
        PUBLIC neighborTable
        PUBLIC nwk_Status
        FUNCTION nwk_Status,0203H
        ARGFRAME XSTACK, 0, STACK
        PUBLIC nwk_globals_init
        FUNCTION nwk_globals_init,021203H
        ARGFRAME XSTACK, 0, STACK
        LOCFRAME ISTACK, 2, STACK
        LOCFRAME XSTACK, 2, STACK
        PUBLIC rtDiscTable
        PUBLIC rtgTable
        
        CFI Names cfiNames0
        CFI StackFrame CFA_SP SP DATA
        CFI StackFrame CFA_PSP16 PSP16 XDATA
        CFI StackFrame CFA_XSP16 XSP16 XDATA
        CFI StaticOverlayFrame CFA_IOVERLAY IOVERLAY
        CFI StaticOverlayFrame CFA_DOVERLAY DOVERLAY
        CFI Resource `PSW.CY`:1, `B.BR0`:1, `B.BR1`:1, `B.BR2`:1, `B.BR3`:1
        CFI Resource `B.BR4`:1, `B.BR5`:1, `B.BR6`:1, `B.BR7`:1, `VB.BR8`:1
        CFI Resource `VB.BR9`:1, `VB.BR10`:1, `VB.BR11`:1, `VB.BR12`:1
        CFI Resource `VB.BR13`:1, `VB.BR14`:1, `VB.BR15`:1, VB:8, B:8, A:8
        CFI Resource PSW:8, DPL0:8, DPH0:8, R0:8, R1:8, R2:8, R3:8, R4:8, R5:8
        CFI Resource R6:8, R7:8, V0:8, V1:8, V2:8, V3:8, V4:8, V5:8, V6:8, V7:8
        CFI Resource SP:8, PSPH:8, PSPL:8, PSP16:16, XSPH:8, XSPL:8, XSP16:16
        CFI VirtualResource ?RET:24
        CFI Resource ?BRET_EXT:8
        CFI VirtualResource ?RET_HIGH:8, ?RET_LOW:8
        CFI ResourceParts PSP16 PSPH, PSPL
        CFI ResourceParts XSP16 XSPH, XSPL
        CFI ResourceParts ?RET ?BRET_EXT, ?RET_HIGH, ?RET_LOW
        CFI EndNames cfiNames0
        
        CFI Common cfiCommon0 Using cfiNames0
        CFI CodeAlign 1
        CFI DataAlign -1
        CFI ReturnAddress ?RET CODE
        CFI CFA_DOVERLAY Used
        CFI CFA_IOVERLAY Used
        CFI CFA_SP SP+-3
        CFI CFA_PSP16 PSP16+0
        CFI CFA_XSP16 XSP16+0
        CFI `PSW.CY` SameValue
        CFI `B.BR0` SameValue
        CFI `B.BR1` SameValue
        CFI `B.BR2` SameValue
        CFI `B.BR3` SameValue
        CFI `B.BR4` SameValue
        CFI `B.BR5` SameValue
        CFI `B.BR6` SameValue
        CFI `B.BR7` SameValue
        CFI `VB.BR8` SameValue
        CFI `VB.BR9` SameValue
        CFI `VB.BR10` SameValue
        CFI `VB.BR11` SameValue
        CFI `VB.BR12` SameValue
        CFI `VB.BR13` SameValue
        CFI `VB.BR14` SameValue
        CFI `VB.BR15` SameValue
        CFI VB SameValue
        CFI B Undefined
        CFI A Undefined
        CFI PSW SameValue
        CFI DPL0 SameValue
        CFI DPH0 SameValue
        CFI R0 Undefined
        CFI R1 Undefined
        CFI R2 Undefined
        CFI R3 Undefined
        CFI R4 Undefined
        CFI R5 Undefined
        CFI R6 SameValue
        CFI R7 SameValue
        CFI V0 SameValue
        CFI V1 SameValue
        CFI V2 SameValue
        CFI V3 SameValue
        CFI V4 SameValue
        CFI V5 SameValue
        CFI V6 SameValue
        CFI V7 SameValue
        CFI PSPH Undefined
        CFI PSPL Undefined
        CFI XSPH Undefined
        CFI XSPL Undefined
        CFI ?RET Concat
        CFI ?BRET_EXT Frame(CFA_SP, 3)
        CFI ?RET_HIGH Frame(CFA_SP, 2)
        CFI ?RET_LOW Frame(CFA_SP, 1)
        CFI EndCommon cfiCommon0
        
AddrMgrInit         SYMBOL "AddrMgrInit"
osal_mem_alloc      SYMBOL "osal_mem_alloc"
RTG_FillCSkipTable  SYMBOL "RTG_FillCSkipTable"
osal_memset         SYMBOL "osal_memset"
osal_cpyExtAddr     SYMBOL "osal_cpyExtAddr"
??AddrMgrInit?relay SYMBOL "?relay", AddrMgrInit
??RTG_FillCSkipTable?relay SYMBOL "?relay", RTG_FillCSkipTable
??osal_cpyExtAddr?relay SYMBOL "?relay", osal_cpyExtAddr
??osal_mem_alloc?relay SYMBOL "?relay", osal_mem_alloc
??osal_memset?relay SYMBOL "?relay", osal_memset
NIB_init            SYMBOL "NIB_init"
??NIB_init?relay    SYMBOL "?relay", NIB_init
nwk_Status          SYMBOL "nwk_Status"
??nwk_Status?relay  SYMBOL "?relay", nwk_Status
nwk_globals_init    SYMBOL "nwk_globals_init"
??nwk_globals_init?relay SYMBOL "?relay", nwk_globals_init

        EXTERN AddrMgrInit
        FUNCTION AddrMgrInit,0202H
        ARGFRAME ISTACK, 2, STACK
        ARGFRAME PSTACK, 0, STACK
        ARGFRAME XSTACK, 0, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        EXTERN osal_mem_alloc
        FUNCTION osal_mem_alloc,0202H
        ARGFRAME ISTACK, 2, STACK
        ARGFRAME PSTACK, 0, STACK
        ARGFRAME XSTACK, 0, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        EXTERN RTG_FillCSkipTable
        FUNCTION RTG_FillCSkipTable,0202H
        ARGFRAME ISTACK, 2, STACK
        ARGFRAME PSTACK, 0, STACK
        ARGFRAME XSTACK, 2, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        EXTERN osal_memset
        FUNCTION osal_memset,0202H
        ARGFRAME ISTACK, 2, STACK
        ARGFRAME PSTACK, 0, STACK
        ARGFRAME XSTACK, 0, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        EXTERN osal_cpyExtAddr
        FUNCTION osal_cpyExtAddr,0202H
        ARGFRAME ISTACK, 2, STACK
        ARGFRAME PSTACK, 0, STACK
        ARGFRAME XSTACK, 0, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        EXTERN ??AddrMgrInit?relay
        FUNCTION ??AddrMgrInit?relay,00H
        EXTERN ??RTG_FillCSkipTable?relay
        FUNCTION ??RTG_FillCSkipTable?relay,00H
        EXTERN ??osal_cpyExtAddr?relay
        FUNCTION ??osal_cpyExtAddr?relay,00H
        EXTERN ??osal_mem_alloc?relay
        FUNCTION ??osal_mem_alloc?relay,00H
        EXTERN ??osal_memset?relay
        FUNCTION ??osal_memset?relay,00H
        EXTERN ZDO_Config_Node_Descriptor
        EXTERN _NIB
        EXTERN zgBcastDeliveryTime
        EXTERN zgExtendedPANID
        EXTERN zgIndirectMsgTimeout
        EXTERN zgMaxBcastRetires
        EXTERN zgPassiveAckTimeout
        EXTERN zgRouteExpiryTime
        EXTERN zgSecurityLevel

// C:\Texas Instruments\ZStack-1.4.3-1.2.1\Components\stack\nwk\nwk_globals.c
//    1 /**************************************************************************************************
//    2   Filename:       nwk_globals.c
//    3   Revised:        $Date: 2008-03-03 17:57:18 -0800 (Mon, 03 Mar 2008) $
//    4   Revision:       $Revision: 16530 $
//    5 
//    6   Description:    User definable Network Parameters.
//    7 
//    8 
//    9   Copyright 2004-2007 Texas Instruments Incorporated. All rights reserved.
//   10 
//   11   IMPORTANT: Your use of this Software is limited to those specific rights
//   12   granted under the terms of a software license agreement between the user
//   13   who downloaded the software, his/her employer (which must be your employer)
//   14   and Texas Instruments Incorporated (the "License").  You may not use this
//   15   Software unless you agree to abide by the terms of the License. The License
//   16   limits your use, and you acknowledge, that the Software may not be modified,
//   17   copied or distributed unless embedded on a Texas Instruments microcontroller
//   18   or used solely and exclusively in conjunction with a Texas Instruments radio
//   19   frequency transceiver, which is integrated into your product.  Other than for
//   20   the foregoing purpose, you may not use, reproduce, copy, prepare derivative
//   21   works of, modify, distribute, perform, display or sell this Software and/or
//   22   its documentation for any purpose.
//   23 
//   24   YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
//   25   PROVIDED “AS IS?WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
//   26   INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
//   27   NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
//   28   TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
//   29   NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
//   30   LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
//   31   INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
//   32   OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
//   33   OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
//   34   (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
//   35 
//   36   Should you have any questions regarding your right to use this Software,
//   37   contact Texas Instruments Incorporated at www.TI.com.
//   38 **************************************************************************************************/
//   39 
//   40 /*********************************************************************
//   41  * INCLUDES
//   42  */
//   43 #include "ZComdef.h"
//   44 #include "OSAL.h"
//   45 #include "AddrMgr.h"
//   46 #include "AssocList.h"
//   47 #include "BindingTable.h"
//   48 #include "nwk_globals.h"
//   49 #include "ssp.h"
//   50 #include "rtg.h"
//   51 #include "ZDConfig.h"
//   52 #include "ZGlobals.h"
//   53 
//   54 #if defined ( LCD_SUPPORTED )
//   55   #include "OnBoard.h"
//   56   #include "lcd128_64.h"
//   57 #endif
//   58 
//   59 /* HAL */
//   60 //#include "hal_lcd.h"
//   61 
//   62 
//   63 
//   64 /*********************************************************************
//   65  * MACROS
//   66  */
//   67 
//   68 /*********************************************************************
//   69  * CONSTANTS
//   70  */
//   71 
//   72 // Maximums for the data buffer queue
//   73 #define NWK_MAX_DATABUFS_WAITING    8     // Waiting to be sent to MAC
//   74 #define NWK_MAX_DATABUFS_SCHEDULED  5     // Timed messages to be sent
//   75 #define NWK_MAX_DATABUFS_CONFIRMED  5     // Held after MAC confirms
//   76 #define NWK_MAX_DATABUFS_TOTAL      12    // Total number of buffers
//   77 
//   78 // 1-255 (0 -> 256) X RTG_TIMER_INTERVAL
//   79 // A known shortcoming is that when a message is enqueued as "hold" for a
//   80 // sleeping device, the timer tick may have counted down to 1, so that msg
//   81 // will not be held as long as expected. If NWK_INDIRECT_MSG_TIMEOUT is set to 1
//   82 // the hold time will vary randomly from 0 - CNT_RTG_TIMER ticks.
//   83 // So the hold time will vary within this interval:
//   84 // { (NWK_INDIRECT_MSG_TIMEOUT-1)*CNT_RTG_TIMER,
//   85 //                                    NWK_INDIRECT_MSG_TIMEOUT*CNT_RTG_TIMER }
//   86 #define NWK_INDIRECT_CNT_RTG_TMR    1  //ggg - need hours or days?
//   87 // To hold msg for sleeping end devices for 30 secs:
//   88 // #define CNT_RTG_TIMER            1
//   89 // #define NWK_INDIRECT_MSG_TIMEOUT 30
//   90 // To hold msg for sleeping end devices for 30 mins:
//   91 // #define CNT_RTG_TIMER            60
//   92 // #define NWK_INDIRECT_MSG_TIMEOUT 30
//   93 // To hold msg for sleeping end devices for 30 days:
//   94 // #define CNT_RTG_TIMER            60
//   95 // #define NWK_INDIRECT_MSG_TIMEOUT (30 * 24 * 60)
//   96 // Maximum msgs to hold per associated device.
//   97 #define NWK_INDIRECT_MSG_MAX_PER    3
//   98 // Maximum total msgs to hold for all associated devices.
//   99 #define NWK_INDIRECT_MSG_MAX_ALL    \ 
//  100                             (NWK_MAX_DATABUFS_TOTAL - NWK_INDIRECT_MSG_MAX_PER)
//  101 
//  102 
//  103 /*********************************************************************
//  104  * TYPEDEFS
//  105  */
//  106 
//  107 /*********************************************************************
//  108  * NWK GLOBAL VARIABLES
//  109  */
//  110 
//  111 // Variables for MAX list size

        RSEG CODE_C:CODE:REORDER:NOROOT(0)
        DATA
//  112 CONST uint16 gNWK_MAX_DEVICE_LIST = NWK_MAX_DEVICES;
gNWK_MAX_DEVICE_LIST:
        DW 21
//  113 
//  114 // Variables for MAX data buffer levels

        RSEG CODE_C:CODE:REORDER:NOROOT(0)
        DATA
//  115 CONST byte gNWK_MAX_DATABUFS_WAITING = NWK_MAX_DATABUFS_WAITING;
gNWK_MAX_DATABUFS_WAITING:
        DB 8

        RSEG CODE_C:CODE:REORDER:NOROOT(0)
        DATA
//  116 CONST byte gNWK_MAX_DATABUFS_SCHEDULED = NWK_MAX_DATABUFS_SCHEDULED;
gNWK_MAX_DATABUFS_SCHEDULED:
        DB 5

        RSEG CODE_C:CODE:REORDER:NOROOT(0)
        DATA
//  117 CONST byte gNWK_MAX_DATABUFS_CONFIRMED = NWK_MAX_DATABUFS_CONFIRMED;
gNWK_MAX_DATABUFS_CONFIRMED:
        DB 5

        RSEG CODE_C:CODE:REORDER:NOROOT(0)
        DATA
//  118 CONST byte gNWK_MAX_DATABUFS_TOTAL = NWK_MAX_DATABUFS_TOTAL;
gNWK_MAX_DATABUFS_TOTAL:
        DB 12
//  119 

        RSEG CODE_C:CODE:REORDER:NOROOT(0)
        DATA
//  120 CONST byte gNWK_INDIRECT_CNT_RTG_TMR = NWK_INDIRECT_CNT_RTG_TMR;
gNWK_INDIRECT_CNT_RTG_TMR:
        DB 1

        RSEG CODE_C:CODE:REORDER:NOROOT(0)
        DATA
//  121 CONST byte gNWK_INDIRECT_MSG_MAX_PER = NWK_INDIRECT_MSG_MAX_PER;
gNWK_INDIRECT_MSG_MAX_PER:
        DB 3

        RSEG CODE_C:CODE:REORDER:NOROOT(0)
        DATA
//  122 CONST byte gNWK_INDIRECT_MSG_MAX_ALL = NWK_INDIRECT_MSG_MAX_ALL;
gNWK_INDIRECT_MSG_MAX_ALL:
        DB 9
//  123 
//  124 #if defined ( RTR_NWK )
//  125   // change this if using a different stack profile...
//  126   // Cskip array

        RSEG XDATA_Z:XDATA:NOROOT(0)
//  127   uint16 *Cskip;
Cskip:
        DS 2
        REQUIRE __INIT_XDATA_Z
//  128 
//  129   #if ( STACK_PROFILE_ID == HOME_CONTROLS )
//  130     byte CskipRtrs[MAX_NODE_DEPTH+1] = {6,6,6,6,6,0};
//  131     byte CskipChldrn[MAX_NODE_DEPTH+1] = {20,20,20,20,20,0};
//  132   #elif ( STACK_PROFILE_ID == GENERIC_STAR )

        RSEG XDATA_I:XDATA:NOROOT(0)
        DATA
//  133     byte CskipRtrs[MAX_NODE_DEPTH+1] = {5,5,5,5,5,0};
CskipRtrs:
        DS 6
        REQUIRE `?<Initializer for CskipRtrs>`
        REQUIRE __INIT_XDATA_I

        RSEG XDATA_I:XDATA:NOROOT(0)
        DATA
//  134     byte CskipChldrn[MAX_NODE_DEPTH+1] = {5,5,5,5,5,0};
CskipChldrn:
        DS 6
        REQUIRE `?<Initializer for CskipChldrn>`
        REQUIRE __INIT_XDATA_I
//  135   #elif ( STACK_PROFILE_ID == NETWORK_SPECIFIC )
//  136     byte CskipRtrs[MAX_NODE_DEPTH+1] = {5,5,5,5,5,0};
//  137     byte CskipChldrn[MAX_NODE_DEPTH+1] = {5,5,5,5,5,0};
//  138   #endif // STACK_PROFILE_ID
//  139 #endif  // RTR_NWK
//  140 
//  141 
//  142 // Minimum lqi value that is required for association

        RSEG XDATA_I:XDATA:NOROOT(0)
        DATA
//  143 byte gMIN_TREE_LINK_COST = MIN_LQI_COST_3;
gMIN_TREE_LINK_COST:
        DS 1
        REQUIRE `?<Initializer for gMIN_TREE_LINK_COST>`
        REQUIRE __INIT_XDATA_I
//  144 
//  145 #if defined(RTR_NWK)
//  146   // Statically defined Associated Device List

        RSEG XDATA_Z:XDATA:NOROOT(0)
//  147   associated_devices_t AssociatedDevList[NWK_MAX_DEVICES];
AssociatedDevList:
        DS 294
        REQUIRE __INIT_XDATA_Z
//  148 #endif
//  149 

        RSEG CODE_C:CODE:REORDER:NOROOT(0)
        DATA
//  150 CONST byte gMAX_RTG_ENTRIES = MAX_RTG_ENTRIES;
gMAX_RTG_ENTRIES:
        DB 20

        RSEG CODE_C:CODE:REORDER:NOROOT(0)
        DATA
//  151 CONST byte gMAX_UNRESERVED_RTG_ENTRIES = MAX_UNRESERVED_RTG_ENTRIES;
gMAX_UNRESERVED_RTG_ENTRIES:
        DB 16

        RSEG CODE_C:CODE:REORDER:NOROOT(0)
        DATA
//  152 CONST byte gMAX_RREQ_ENTRIES = MAX_RREQ_ENTRIES;
gMAX_RREQ_ENTRIES:
        DB 10
//  153 

        RSEG CODE_C:CODE:REORDER:NOROOT(0)
        DATA
//  154 CONST byte gMAX_NEIGHBOR_ENTRIES = MAX_NEIGHBOR_ENTRIES;
gMAX_NEIGHBOR_ENTRIES:
        DB 8
//  155 
//  156  // Table of neighboring nodes (not including child nodes)

        RSEG XDATA_Z:XDATA:NOROOT(0)
//  157 neighborEntry_t neighborTable[MAX_NEIGHBOR_ENTRIES];
neighborTable:
        DS 88
        REQUIRE __INIT_XDATA_Z
//  158 
//  159 #if defined ( RTR_NWK )
//  160   // Routing table

        RSEG XDATA_Z:XDATA:NOROOT(0)
//  161   rtgEntry_t rtgTable[MAX_RTG_ENTRIES];
rtgTable:
        DS 120
        REQUIRE __INIT_XDATA_Z
//  162 
//  163   // Table of current RREQ packets in the network

        RSEG XDATA_Z:XDATA:NOROOT(0)
//  164   rtDiscEntry_t rtDiscTable[MAX_RREQ_ENTRIES];
rtDiscTable:
        DS 80
        REQUIRE __INIT_XDATA_Z
//  165 
//  166   // Table of data broadcast packets currently in circulation.

        RSEG XDATA_Z:XDATA:NOROOT(0)
//  167   bcastEntry_t bcastTable[MAX_BCAST];
bcastTable:
        DS 72
        REQUIRE __INIT_XDATA_Z
//  168 
//  169   // These 2 arrays are to be used as an array of struct { uint8, uint32 }.

        RSEG XDATA_Z:XDATA:NOROOT(0)
//  170   uint8 bcastHoldHandle[MAX_BCAST];
bcastHoldHandle:
        DS 9
        REQUIRE __INIT_XDATA_Z

        RSEG XDATA_Z:XDATA:NOROOT(0)
//  171   uint32 bcastHoldAckMask[MAX_BCAST];
bcastHoldAckMask:
        DS 36
        REQUIRE __INIT_XDATA_Z
//  172 

        RSEG CODE_C:CODE:REORDER:NOROOT(0)
        DATA
//  173   CONST byte gMAX_BCAST = MAX_BCAST;
gMAX_BCAST:
        DB 9
//  174 #endif
//  175 
//  176 /*********************************************************************
//  177  * APS GLOBAL VARIABLES
//  178  */
//  179 
//  180 //#if defined ( REFLECTOR )
//  181   // The Maximum number of binding records
//  182   // This number is defined in BindingTable.h - change it there.

        RSEG CODE_C:CODE:REORDER:NOROOT(0)
        DATA
//  183   CONST uint16 gNWK_MAX_BINDING_ENTRIES = NWK_MAX_BINDING_ENTRIES;
gNWK_MAX_BINDING_ENTRIES:
        DW 10
//  184 #if defined ( REFLECTOR )
//  185   // The Maximum number of cluster IDs in a binding record
//  186   // This number is defined in BindingTable.h - change it there.
//  187   CONST byte gMAX_BINDING_CLUSTER_IDS = MAX_BINDING_CLUSTER_IDS;
//  188 
//  189   CONST uint16 gBIND_REC_SIZE = sizeof( BindingEntry_t );
//  190 
//  191   // Binding Table
//  192   BindingEntry_t BindingTable[NWK_MAX_BINDING_ENTRIES];
//  193 #endif
//  194 
//  195 // Maximum number allowed in the groups table.

        RSEG CODE_C:CODE:REORDER:NOROOT(0)
        DATA
//  196 CONST uint8 gAPS_MAX_GROUPS = APS_MAX_GROUPS;
gAPS_MAX_GROUPS:
        DB 16
//  197 
//  198 // The size of a tx window when using fragmentation

        RSEG CODE_C:CODE:REORDER:NOROOT(0)
        DATA
//  199 CONST uint8 apscMaxWindowSize = APS_DEFAULT_WINDOW_SIZE;
apscMaxWindowSize:
        DB 5
//  200 
//  201 // The delay between tx packets when using fragmentaition

        RSEG CODE_C:CODE:REORDER:NOROOT(0)
        DATA
//  202 CONST uint16 gAPS_INTERFRAME_DELAY = APS_DEFAULT_INTERFRAME_DELAY;
gAPS_INTERFRAME_DELAY:
        DW 50
//  203 
//  204 
//  205 /*********************************************************************
//  206  * SECURITY GLOBAL VARIABLES
//  207  */
//  208 
//  209 // This is the default pre-configured key,
//  210 // change this to make a unique key
//  211 // SEC_KEY_LEN is defined in ssp.h.

        RSEG CODE_C:CODE:REORDER:NOROOT(0)
        DATA
//  212 CONST byte defaultKey[SEC_KEY_LEN] =
defaultKey:
        DB 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
//  213 {
//  214 #if defined ( APP_TP ) || defined ( APP_TP2 )
//  215   // Key for ZigBee Conformance Testing
//  216   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
//  217   0x89, 0x67, 0x45, 0x23, 0x01, 0xEF, 0xCD, 0xAB
//  218 #else
//  219   // Key for In-House Testing
//  220   0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
//  221   0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
//  222 #endif
//  223 };
//  224 
//  225 
//  226 /*********************************************************************
//  227  * STATUS STRINGS
//  228  */
//  229 #if defined ( LCD_SUPPORTED )
//  230   const char PingStr[]         = "Ping Rcvd from";
//  231   const char AssocCnfStr[]     = "Assoc Cnf";
//  232   const char SuccessStr[]      = "Success";
//  233   const char EndDeviceStr[]    = "EndDevice:";
//  234   const char ParentStr[]       = "Parent:";
//  235   const char ZigbeeCoordStr[]  = "ZigBee Coord";
//  236   const char NetworkIDStr[]    = "Network ID:";
//  237   const char RouterStr[]       = "Router:";
//  238   const char OrphanRspStr[]    = "Orphan Response";
//  239   const char SentStr[]         = "Sent";
//  240   const char FailedStr[]       = "Failed";
//  241   const char AssocRspFailStr[] = "Assoc Rsp fail";
//  242   const char AssocIndStr[]     = "Assoc Ind";
//  243   const char AssocCnfFailStr[] = "Assoc Cnf fail";
//  244   const char EnergyLevelStr[]  = "Energy Level";
//  245   const char ScanFailedStr[]   = "Scan Failed";
//  246 #endif
//  247 
//  248 /*********************************************************************
//  249  * @fn       nwk_globals_init()
//  250  *
//  251  * @brief
//  252  *
//  253  *   Initialize nwk layer globals.  These are the system defaults and
//  254  *   should be changed by the user here.  The default definitions are
//  255  *   defined in nwk.h or NLMEDE.h.
//  256  *
//  257  * @param   none
//  258  *
//  259  * @return  none
//  260  */

        RSEG BANKED_CODE:CODE:NOROOT(0)
//  261 void nwk_globals_init( void )
nwk_globals_init:
        CFI Block cfiBlock0 Using cfiCommon0
        CFI Function nwk_globals_init
//  262 {
        FUNCALL nwk_globals_init, AddrMgrInit
        LOCFRAME ISTACK, 2, STACK
        LOCFRAME PSTACK, 0, STACK
        LOCFRAME XSTACK, 0, STACK
        LOCFRAME IOVERLAY, 0, STATIC
        LOCFRAME DOVERLAY, 0, STATIC
        ARGFRAME ISTACK, 2, STACK
        ARGFRAME PSTACK, 0, STACK
        ARGFRAME XSTACK, 0, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        FUNCALL nwk_globals_init, osal_mem_alloc
        LOCFRAME ISTACK, 2, STACK
        LOCFRAME PSTACK, 0, STACK
        LOCFRAME XSTACK, 0, STACK
        LOCFRAME IOVERLAY, 0, STATIC
        LOCFRAME DOVERLAY, 0, STATIC
        ARGFRAME ISTACK, 2, STACK
        ARGFRAME PSTACK, 0, STACK
        ARGFRAME XSTACK, 0, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        FUNCALL nwk_globals_init, RTG_FillCSkipTable
        LOCFRAME ISTACK, 2, STACK
        LOCFRAME PSTACK, 0, STACK
        LOCFRAME XSTACK, 2, STACK
        LOCFRAME IOVERLAY, 0, STATIC
        LOCFRAME DOVERLAY, 0, STATIC
        ARGFRAME ISTACK, 2, STACK
        ARGFRAME PSTACK, 0, STACK
        ARGFRAME XSTACK, 2, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        PUSH    DPL
        CFI DPL0 Frame(CFA_SP, 4)
        CFI CFA_SP SP+-4
        PUSH    DPH
        CFI DPH0 Frame(CFA_SP, 5)
        CFI CFA_SP SP+-5
        ; Saved register size: 2
        ; Auto size: 0
//  263   AddrMgrInit( NWK_MAX_ADDRESSES );
        ; Setup parameters for call to function AddrMgrInit
        MOV     R2,#0x16
        MOV     R3,#0x0
        LCALL   ??AddrMgrInit?relay
//  264 
//  265 #if defined ( RTR_NWK )
//  266   // Initialize the Cskip Table
//  267   Cskip = osal_mem_alloc(sizeof(uint16) *(MAX_NODE_DEPTH+1));
        ; Setup parameters for call to function osal_mem_alloc
        MOV     R2,#0xc
        MOV     R3,#0x0
        LCALL   ??osal_mem_alloc?relay
        MOV     DPTR,#Cskip
        MOV     A,R2
        MOVX    @DPTR,A
        INC     DPTR
        MOV     A,R3
        MOVX    @DPTR,A
//  268   RTG_FillCSkipTable(CskipChldrn, CskipRtrs, MAX_NODE_DEPTH, Cskip);
        ; Setup parameters for call to function RTG_FillCSkipTable
        MOV     DPTR,#Cskip
        LCALL   ?PUSH_XSTACK8_X_TWO
        CFI CFA_XSP16 add(XSP16, 2)
        MOV     R1,#0x5
        MOV     R4,#(CskipRtrs & 0xff)
        MOV     R5,#((CskipRtrs >> 8) & 0xff)
        MOV     R2,#(CskipChldrn & 0xff)
        MOV     R3,#((CskipChldrn >> 8) & 0xff)
        LCALL   ??RTG_FillCSkipTable?relay
        MOV     A,#0x2
        LCALL   ?DEALLOC_XSTACK8
        CFI EndBlock cfiBlock0
//  269 #endif
//  270 }
        REQUIRE ?Subroutine0
        ; // Fall through to label ?Subroutine0

        RSEG BANKED_CODE:CODE:NOROOT(0)
?Subroutine0:
        CFI Block cfiBlock1 Using cfiCommon0
        CFI NoFunction
        CFI CFA_SP SP+-5
        CFI DPL0 Frame(CFA_SP, 4)
        CFI DPH0 Frame(CFA_SP, 5)
        POP     DPH
        CFI CFA_SP SP+-4
        CFI DPH0 SameValue
        POP     DPL
        CFI CFA_SP SP+-3
        CFI DPL0 SameValue
        LJMP    ?BRET
        CFI EndBlock cfiBlock1
//  271 
//  272 /*********************************************************************
//  273  * @fn       NIB_init()
//  274  *
//  275  * @brief
//  276  *
//  277  *   Initialize attribute values in NIB
//  278  *
//  279  * @param   none
//  280  *
//  281  * @return  none
//  282  */

        RSEG BANKED_CODE:CODE:NOROOT(0)
//  283 void NIB_init()
NIB_init:
        CFI Block cfiBlock2 Using cfiCommon0
        CFI Function NIB_init
//  284 {
        FUNCALL NIB_init, osal_memset
        LOCFRAME ISTACK, 2, STACK
        LOCFRAME PSTACK, 0, STACK
        LOCFRAME XSTACK, 0, STACK
        LOCFRAME IOVERLAY, 0, STATIC
        LOCFRAME DOVERLAY, 0, STATIC
        ARGFRAME ISTACK, 2, STACK
        ARGFRAME PSTACK, 0, STACK
        ARGFRAME XSTACK, 0, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        FUNCALL NIB_init, osal_cpyExtAddr
        LOCFRAME ISTACK, 2, STACK
        LOCFRAME PSTACK, 0, STACK
        LOCFRAME XSTACK, 0, STACK
        LOCFRAME IOVERLAY, 0, STATIC
        LOCFRAME DOVERLAY, 0, STATIC
        ARGFRAME ISTACK, 2, STACK
        ARGFRAME PSTACK, 0, STACK
        ARGFRAME XSTACK, 0, STACK
        ARGFRAME IOVERLAY, 0, STATIC
        ARGFRAME DOVERLAY, 0, STATIC
        PUSH    DPL
        CFI DPL0 Frame(CFA_SP, 4)
        CFI CFA_SP SP+-4
        PUSH    DPH
        CFI DPH0 Frame(CFA_SP, 5)
        CFI CFA_SP SP+-5
        ; Saved register size: 2
        ; Auto size: 0
//  285 #if defined ( AUTO_SOFT_START )
//  286   byte extAddr[Z_EXTADDR_LEN];
//  287   ZMacGetReq( ZMacExtAddr, extAddr );
//  288   _NIB.SequenceNum = extAddr[0];
//  289 #else
//  290   _NIB.SequenceNum = 1;
        MOV     A,#0x1
        MOV     DPTR,#_NIB
        MOVX    @DPTR,A
//  291 #endif
//  292 
//  293   _NIB.nwkProtocolVersion = ZB_PROT_VERS;
        MOV     A,#0x2
        MOV     DPTR,#(_NIB + 17)
        MOVX    @DPTR,A
//  294   _NIB.MaxDepth = MAX_NODE_DEPTH;
        MOV     A,#0x5
        MOV     DPTR,#(_NIB + 4)
        MOVX    @DPTR,A
//  295 
//  296 #if ( NWK_MODE == NWK_MODE_MESH )
//  297   _NIB.beaconOrder = BEACON_ORDER_NO_BEACONS;
//  298   _NIB.superFrameOrder = BEACON_ORDER_NO_BEACONS;
//  299 #endif
//  300 
//  301    // BROADCAST SETTINGS:
//  302    // *******************
//  303    //   Broadcast Delivery Time
//  304    //     - set to multiples of 100ms
//  305    //     - should be 500ms more than the retry time
//  306    //       -  "retry time" = PassiveAckTimeout * (MaxBroadcastRetries + 1)
//  307    //   Passive Ack Timeout
//  308    //     - set to multiples of 100ms
//  309    _NIB.BroadcastDeliveryTime = zgBcastDeliveryTime;
        MOV     DPTR,#zgBcastDeliveryTime
        MOVX    A,@DPTR
        MOV     DPTR,#(_NIB + 7)
        MOVX    @DPTR,A
//  310    _NIB.PassiveAckTimeout     = zgPassiveAckTimeout;
        MOV     DPTR,#zgPassiveAckTimeout
        MOVX    A,@DPTR
        MOV     DPTR,#(_NIB + 1)
        MOVX    @DPTR,A
//  311    _NIB.MaxBroadcastRetries   = zgMaxBcastRetires;
        MOV     DPTR,#zgMaxBcastRetires
        MOVX    A,@DPTR
        MOV     DPTR,#(_NIB + 2)
        MOVX    @DPTR,A
//  312 
//  313    _NIB.ReportConstantCost = 0;
        CLR     A
        MOV     DPTR,#(_NIB + 8)
        MOVX    @DPTR,A
//  314    _NIB.RouteDiscRetries = 0;
        MOV     DPTR,#(_NIB + 9)
        MOVX    @DPTR,A
//  315    _NIB.SecureAllFrames = USE_NWK_SECURITY;
        MOV     A,#0x1
        MOV     DPTR,#(_NIB + 11)
        MOVX    @DPTR,A
//  316    _NIB.SecurityLevel = zgSecurityLevel;
        MOV     DPTR,#zgSecurityLevel
        MOVX    A,@DPTR
        MOV     DPTR,#(_NIB + 12)
        MOVX    @DPTR,A
//  317    _NIB.SymLink = 0;
        CLR     A
        MOV     DPTR,#(_NIB + 13)
        MOVX    @DPTR,A
//  318    _NIB.CapabilityInfo = ZDO_Config_Node_Descriptor.CapabilityFlags;
        MOV     DPTR,#(ZDO_Config_Node_Descriptor + 2)
        MOVX    A,@DPTR
        MOV     DPTR,#(_NIB + 14)
        MOVX    @DPTR,A
//  319 
//  320    _NIB.TransactionPersistenceTime = zgIndirectMsgTimeout;
        MOV     DPTR,#zgIndirectMsgTimeout
        MOVX    A,@DPTR
        MOV     DPTR,#(_NIB + 15)
        MOVX    @DPTR,A
        INC     DPTR
        CLR     A
        MOVX    @DPTR,A
//  321 
//  322    _NIB.RouteDiscoveryTime = 5;
        MOV     A,#0x5
        MOV     DPTR,#(_NIB + 18)
        MOVX    @DPTR,A
//  323    _NIB.RouteExpiryTime = zgRouteExpiryTime;
        MOV     DPTR,#zgRouteExpiryTime
        MOVX    A,@DPTR
        MOV     DPTR,#(_NIB + 19)
        MOVX    @DPTR,A
//  324 
//  325    _NIB.nwkDevAddress = INVALID_NODE_ADDR;
        MOV     DPTR,#(_NIB + 20)
        MOV     A,#-0x2
        MOVX    @DPTR,A
        INC     DPTR
        MOV     A,#-0x1
        MOVX    @DPTR,A
//  326    _NIB.nwkLogicalChannel = 0;
        CLR     A
        MOV     DPTR,#(_NIB + 22)
        MOVX    @DPTR,A
//  327    _NIB.nwkCoordAddress = INVALID_NODE_ADDR;
        MOV     DPTR,#(_NIB + 23)
        MOV     A,#-0x2
        MOVX    @DPTR,A
        INC     DPTR
        MOV     A,#-0x1
        MOVX    @DPTR,A
//  328    osal_memset( _NIB.nwkCoordExtAddress, 0, Z_EXTADDR_LEN );
        ; Setup parameters for call to function osal_memset
        MOV     R4,#0x8
        MOV     R5,#0x0
        MOV     R1,#0x0
        MOV     R2,#((_NIB + 25) & 0xff)
        MOV     R3,#(((_NIB + 25) >> 8) & 0xff)
        LCALL   ??osal_memset?relay
//  329    _NIB.nwkPanId = INVALID_NODE_ADDR;
        MOV     DPTR,#(_NIB + 33)
        MOV     A,#-0x2
        MOVX    @DPTR,A
        INC     DPTR
        MOV     A,#-0x1
        MOVX    @DPTR,A
//  330 
//  331    osal_cpyExtAddr( _NIB.extendedPANID, zgExtendedPANID );
        ; Setup parameters for call to function osal_cpyExtAddr
        MOV     R4,#(zgExtendedPANID & 0xff)
        MOV     R5,#((zgExtendedPANID >> 8) & 0xff)
        MOV     R2,#((_NIB + 53) & 0xff)
        MOV     R3,#(((_NIB + 53) >> 8) & 0xff)
        LCALL   ??osal_cpyExtAddr?relay
//  332 
//  333    _NIB.nwkKeyLoaded = FALSE;
        CLR     A
        MOV     DPTR,#(_NIB + 61)
        MOVX    @DPTR,A
//  334 }
        LJMP    ?Subroutine0 & 0xFFFF
        CFI EndBlock cfiBlock2
//  335 
//  336 /*********************************************************************
//  337  * @fn       nwk_Status()
//  338  *
//  339  * @brief
//  340  *
//  341  *   Status report.
//  342  *
//  343  * @param   statusCode
//  344  * @param   statusValue
//  345  *
//  346  * @return  none
//  347  */

        RSEG BANKED_CODE:CODE:NOROOT(0)
//  348 void nwk_Status( uint16 statusCode, uint16 statusValue )
nwk_Status:
        CFI Block cfiBlock3 Using cfiCommon0
        CFI Function nwk_Status
//  349 {
        ; Saved register size: 0
        ; Auto size: 0
//  350 #if defined ( LCD_SUPPORTED )
//  351   switch ( statusCode )
//  352   {
//  353 
//  354 #if defined( RTR_NWK )
//  355     case NWK_STATUS_COORD_ADDR:
//  356       //HalLcdWriteString( (char*)ZigbeeCoordStr, HAL_LCD_LINE_1 );
//  357      // HalLcdWriteStringValue( (char*)NetworkIDStr, (uint32)statusValue, 16, HAL_LCD_LINE_2 );
//  358       ClearScreen();
//  359       Print8(HAL_LCD_LINE_1,10,(INT8U*)ZigbeeCoordStr,1);
//  360       Print8(HAL_LCD_LINE_2,10,(INT8U*)NetworkIDStr,1);
//  361       Printn8(HAL_LCD_LINE_3,10,statusValue,1,4);
//  362       BuzzerControl( BUZZER_BLIP );
//  363       break;
//  364 
//  365     case NWK_STATUS_ROUTER_ADDR:
//  366       //HalLcdWriteStringValue( (char*)RouterStr, (uint32)statusValue, 16, HAL_LCD_LINE_1 );
//  367       ClearScreen();
//  368       Print8(HAL_LCD_LINE_1,10,(INT8U*)RouterStr,1);
//  369       Printn8(HAL_LCD_LINE_1,40,statusValue,1,4);
//  370       break;
//  371 
//  372     case NWK_STATUS_ORPHAN_RSP:
//  373       if( statusValue == ZSuccess )
//  374       {
//  375         //HalLcdWriteScreen( (char*)OrphanRspStr, (char*)SentStr );
//  376          ClearScreen();
//  377         Print8(HAL_LCD_LINE_1,10,(INT8U*)OrphanRspStr,1);
//  378         Print8(HAL_LCD_LINE_2,10,(INT8U*)SentStr,1);
//  379       }
//  380       else{
//  381       //else
//  382         //HalLcdWriteScreen( (char*)OrphanRspStr, (char*)FailedStr );
//  383        ClearScreen();
//  384        Print8(HAL_LCD_LINE_1,10,(INT8U*)OrphanRspStr,1);
//  385        Print8(HAL_LCD_LINE_2,10,(INT8U*)FailedStr,1);
//  386       }
//  387       break;
//  388 
//  389     case NWK_ERROR_ASSOC_RSP:
//  390       //HalLcdWriteString( (char*)AssocRspFailStr, HAL_LCD_LINE_1 );
//  391      // HalLcdWriteValue( (uint32)(statusValue), 16, HAL_LCD_LINE_2 );
//  392        ClearScreen();
//  393        Print8(HAL_LCD_LINE_1,10,(INT8U*)AssocRspFailStr,1);
//  394        Printn8(HAL_LCD_LINE_2,10,statusValue,1,4);
//  395 
//  396       break;
//  397 #else
//  398     case NWK_STATUS_ED_ADDR:
//  399             //HalLcdWriteStringValue( (char*)EndDeviceStr, (uint32)statusValue, 16, HAL_LCD_LINE_1 );
//  400         //ClearScreen();
//  401         Print8(HAL_LCD_LINE_1,10,(INT8U*)EndDeviceStr,1);
//  402         Printn8(HAL_LCD_LINE_1,60,statusValue,1,4);
//  403       break;
//  404 #endif
//  405 
//  406     case NWK_STATUS_PARENT_ADDR:
//  407             //HalLcdWriteStringValue( (char*)ParentStr, (uint32)statusValue, 16, HAL_LCD_LINE_2 );
//  408 
//  409             Print8(HAL_LCD_LINE_2,10,(INT8U*)ParentStr,1);
//  410             Printn8(HAL_LCD_LINE_3,10,statusValue,1,4);
//  411       break;
//  412 
//  413     case NWK_STATUS_ASSOC_CNF:
//  414      // HalLcdWriteScreen( (char*)AssocCnfStr, (char*)SuccessStr );
//  415        ClearScreen();
//  416       Print8(HAL_LCD_LINE_1,10,(INT8U*)AssocCnfStr,1);
//  417       Print8(HAL_LCD_LINE_2,10,(INT8U*)SuccessStr,1);
//  418       break;
//  419 
//  420     case NWK_ERROR_ASSOC_CNF_DENIED:
//  421       //HalLcdWriteString((char*)AssocCnfFailStr, HAL_LCD_LINE_1 );
//  422       //HalLcdWriteValue( (uint32)(statusValue), 16, HAL_LCD_LINE_2 );
//  423        ClearScreen();
//  424       Print8(HAL_LCD_LINE_1,10,(INT8U*)AssocCnfFailStr,1);
//  425       Printn8(HAL_LCD_LINE_2,10,statusValue,1,4);
//  426       break;
//  427 
//  428     case NWK_ERROR_ENERGY_SCAN_FAILED:
//  429      // HalLcdWriteScreen( (char*)EnergyLevelStr, (char*)ScanFailedStr );
//  430        ClearScreen();
//  431        Print8(HAL_LCD_LINE_1,10,(INT8U*)EnergyLevelStr,1);
//  432        Print8(HAL_LCD_LINE_2,10,(INT8U*)ScanFailedStr ,1);
//  433       break;
//  434   }
//  435 #endif
//  436 }
        LJMP    ?BRET
        CFI EndBlock cfiBlock3

        RSEG XDATA_ID:CODE:NOROOT(0)
        DATA
`?<Initializer for CskipRtrs>`:
        DB 5, 5, 5, 5, 5, 0

        RSEG XDATA_ID:CODE:NOROOT(0)
        DATA
`?<Initializer for CskipChldrn>`:
        DB 5, 5, 5, 5, 5, 0

        RSEG XDATA_ID:CODE:NOROOT(0)
        DATA
`?<Initializer for gMIN_TREE_LINK_COST>`:
        DB 6

        RSEG BANK_RELAYS:CODE:REORDER:NOROOT(0)
??nwk_globals_init?relay:
        LCALL   ?BDISPATCH
        DATA
        DC24    nwk_globals_init

        RSEG BANK_RELAYS:CODE:REORDER:NOROOT(0)
??NIB_init?relay:
        LCALL   ?BDISPATCH
        DATA
        DC24    NIB_init

        RSEG BANK_RELAYS:CODE:REORDER:NOROOT(0)
??nwk_Status?relay:
        LCALL   ?BDISPATCH
        DATA
        DC24    nwk_Status

        END
//  437 
//  438 /*********************************************************************
//  439 *********************************************************************/
// 
// 234 bytes in segment BANKED_CODE
//  18 bytes in segment BANK_RELAYS
//  36 bytes in segment CODE_C
//  13 bytes in segment XDATA_I
//  13 bytes in segment XDATA_ID
// 701 bytes in segment XDATA_Z
// 
// 301 bytes of CODE  memory
// 714 bytes of XDATA memory
//
//Errors: none
//Warnings: none
