123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380 |
- #ifndef NWK_H
- #define NWK_H
- #ifdef __cplusplus
- extern "C" {
- #endif
- #include "ZComDef.h"
- #include "ZMAC.h"
- #include "nwk_bufs.h"
- #include "NLMEDE.h"
- #include "ssp.h"
- #define MAC_SCAN_REQ 0x01
- #define NWK_NETWORKSTART_REQ 0x02
- #define MAC_ASSOCIATE_REQ 0x03
- #define NWK_REMOTE_GET_REQ 0x04
- #define NWK_REMOTE_SET_REQ 0x05
- #define NWK_ASSOCIATE_RESP 0x06
- #define NWK_DISASSOCIATE_REQ 0x07
- #define NWK_AUTO_POLL_EVT 0x0001
- #define NWK_NOT_EXPECTING_EVT 0x0004
- #define RTG_TIMER_EVENT 0x0010
- #define NWK_DATABUF_SEND 0x0020
- #define NWK_BCAST_TIMER_EVT 0x0040
- #define NWK_PERMITJOIN_EVT 0x0080
- #define NWK_LINK_STATUS_EVT 0x0100
- #define NWK_PID_UPDATE_EVT 0x0200
- #define NWK_REJOIN_TIMEOUT_EVT 0x0400
- #define NWK_MTO_RTG_REQ_EVT 0x0800
- #define NWK_MTO_RTG_REQ_DELAY_EVT 0x1000
- #define NWK_BROADCAST_MSG_EVT 0x2000
- #define NWK_CMD_ID 0
- #define NWK_PARAMS_ID 1
- #define NWK_REQ_ATTR_ID 1
- #define NWK_REQ_ATTR 2
- #define NWK_CMD_PYLD_BEGIN NWK_HEADER_LEN
- #define NWK_DEVICE_LIST_LEN_FIELD NWK_HEADER_LEN + 1
- #define ED_SCAN_MAXCHANNELS 27
- #define MAX_DATA_PACKET_LEN MAC_MAX_FRAME_SIZE
- #define NWK_TASK_ID 0
- #define ASSOC_CAPABILITY_INFO 0
- #define ASSOC_SECURITY_EN 0
- #define DEF_DEST_EP 2
- #define DEVICE_APPLICATION 0
- #define MAC_ADDR_LEN 8
- #define NWK_TXOPTIONS_ACK 0x01
- #define NWK_TXOPTIONS_INDIRECT 0x04
- #define NWK_TXOPTIONS_COORD (NWK_TXOPTIONS_ACK | NWK_TXOPTIONS_INDIRECT)
- #define DEF_MAX_NUM_COORDINATORS 15
- #define DEF_CHANNEL_SCAN_BITMAP MAX_CHANNELS_24GHZ
- #define SOFT_SCAN_DURATION 1
- #define DEF_SCAN_DURATION 2
- #define NO_BEACONS 15
- #define DEF_BEACON_ORDER NO_BEACONS
- #define DEF_SUPERFRAMEORDER DEF_BEACON_ORDER
- #define NWK_SECURITY_ENABLE FALSE
- #define NWK_MAC_ASSOC_CNF_LEN 4
- #define FIXED_SIZ_MAC_DATA_CNF 4
- #define FIXED_SIZ_MAC_DATA_IND 26
- #define FIXED_SIZ_MAC_SCAN_CNF 7
- #define ALL_PAIRING_TABLE_ENTRIES 0
- #define SIZE_OF_PAIRING_TABLE_ENTRY 6
- #define SIZE_OF_DEVICE_LIST_ENTRY 2
- #define NWK_SEND_TIMER_INTERVAL 2
- #define NWK_BCAST_TIMER_INTERVAL 100
- #define INVALID_NODE_ADDR 0xFFFE
- #define INVALID_PAN_ID 0xFFFE
- #define DEF_LINK_COST 1
- #define MAX_LINK_COST 7
- #define LINK_DOWN_COST 0
- #define LINK_AGEOUT_COST 0
- #define DEF_LINK_COUNTER ((gLINK_DOWN_TRIGGER+1) / 2)
- #define LINK_ACTIVE_TRIGGER 2
-
- #define CB_ID_APP_ANNOUNCE_CNF 0x00
- #define CB_ID_APP_ASSOCIATE_CNF 0x01
- #define CB_ID_APP_ASSOCIATE_IND 0x02
- #define CB_ID_APP_DATA_CNF 0x03
- #define CB_ID_APP_DATA_IND 0x04
- #define CB_ID_APP_DISASSOCIATE_CNF 0x05
- #define CB_ID_APP_DISASSOCIATE_IND 0x06
- #define CB_ID_APP_NETWORK_DETECT_CNF 0x07
- #define CB_ID_APP_REMOTE_GET_CNF 0x08
- #define SPI_CB_APP_REMOTE_SET_CNF 0x09
- #define CB_ID_APP_SERVICE_CNF 0x0a
- #define CB_ID_APP_SERVICE_IND 0x0b
- #define CB_ID_APP_START_CNF 0x0c
- #define NUM_PING_ROUTE_ADDRS 12
- #define PING_ROUTE_ADDRS_INDEX 8
- #define NWK_GetNodeDepth() (_NIB.nodeDepth)
- #define NWK_GetTreeDepth() (0)
-
- #define BEACON_MAX_DEPTH 0x0F
-
- typedef enum
- {
- NWK_INIT,
- NWK_JOINING_ORPHAN,
- NWK_DISC,
- NWK_JOINING,
- NWK_ENDDEVICE,
- PAN_CHNL_SELECTION,
- PAN_CHNL_VERIFY,
- PAN_STARTING,
- NWK_ROUTER,
- NWK_REJOINING
- } nwk_states_t;
- typedef enum
- {
- MACCMDBUF_NONE,
- MACCMDBUF_ASSOC_REQ,
- MACCMDBUF_DISASSOC_REQ
- } nwkMacCmds_t;
- typedef struct
- {
- byte SequenceNum;
- byte PassiveAckTimeout;
- byte MaxBroadcastRetries;
- byte MaxChildren;
- byte MaxDepth;
- byte MaxRouters;
- byte dummyNeighborTable;
- byte BroadcastDeliveryTime;
- byte ReportConstantCost;
- byte RouteDiscRetries;
- byte dummyRoutingTable;
- byte SecureAllFrames;
- byte SecurityLevel;
- #if defined ( COMPATIBILITY_221 )
- byte nwkAllFresh;
- #endif
- byte SymLink;
- byte CapabilityFlags;
- uint16 TransactionPersistenceTime;
- byte nwkProtocolVersion;
-
- byte RouteDiscoveryTime;
- byte RouteExpiryTime;
-
- uint16 nwkDevAddress;
- byte nwkLogicalChannel;
- uint16 nwkCoordAddress;
- byte nwkCoordExtAddress[Z_EXTADDR_LEN];
- uint16 nwkPanId;
-
- nwk_states_t nwkState;
- uint32 channelList;
- byte beaconOrder;
- byte superFrameOrder;
- byte scanDuration;
- byte battLifeExt;
- uint32 allocatedRouterAddresses;
- uint32 allocatedEndDeviceAddresses;
- byte nodeDepth;
-
- uint8 extendedPANID[Z_EXTADDR_LEN];
-
-
- uint8 nwkKeyLoaded;
-
-
-
-
- nwkKeyDesc spare1;
- nwkKeyDesc spare2;
-
-
- uint8 nwkAddrAlloc;
- uint8 nwkUniqueAddr;
- uint8 nwkLinkStatusPeriod;
-
- uint8 nwkRouterAgeLimit;
-
-
- uint8 nwkUseMultiCast;
-
- uint8 nwkIsConcentrator;
- uint8 nwkConcentratorDiscoveryTime;
- uint8 nwkConcentratorRadius;
- #if defined ( COMPATIBILITY_221 )
- uint8 nwkMaxSourceRoute;
- uint8 nwkSrcRtgExpiryTime;
- #else
- uint8 nwkAllFresh;
- #endif
- uint16 nwkManagerAddr;
- uint16 nwkTotalTransmissions;
- uint8 nwkUpdateId;
- } nwkIB_t;
- typedef struct
- {
- uint16 panId;
- void *next;
- } nwkPanId_t;
- extern nwkIB_t _NIB;
- extern byte NWK_TaskID;
- extern networkDesc_t *NwkDescList;
- extern byte nwkExpectingMsgs;
- extern byte nwk_beaconPayload[ZMAC_MAX_BEACON_PAYLOAD_LEN];
- extern byte nwk_beaconPayloadSize;
- extern uint8 nwkSendMTOReq;
-
- extern void nwk_init( byte task_id );
-
- extern ZStatus_t nwk_data_req_send( nwkDB_t* db );
-
- extern UINT16 nwk_event_loop( byte task_id, UINT16 events );
-
- extern ZStatus_t nwk_start_coord( void );
- extern void nwk_desc_list_free( void );
- extern networkDesc_t *nwk_getNetworkDesc( uint8 *ExtendedPANID, uint16 PanId, byte Channel );
- extern networkDesc_t *nwk_getNwkDescList( void );
- extern void nwk_BeaconFromNative(byte* buff, byte size, beaconPayload_t* beacon);
- extern void nwk_BeaconToNative(beaconPayload_t* beacon, byte* buff, byte size);
- extern void nwk_setStateIdle( uint8 idle );
- extern uint8 nwk_stateIdle( void );
- extern void nwk_ScanJoiningOrphan( ZMacScanCnf_t *param );
- extern void nwk_ScanPANChanSelect( ZMacScanCnf_t *param );
- extern void nwk_ScanPANChanVerify( ZMacScanCnf_t *param );
- #ifdef __cplusplus
- }
- #endif
- #endif
|