📄 nlmede.h
字号:
#ifndef NLMEDE_H
#define NLMEDE_H
/*********************************************************************
Filename: NLMEDE.h
Revised: $Date: 2007-02-23 11:29:38 -0800 (Fri, 23 Feb 2007) $
Revision: $Revision: 13588 $
Description:
Network layer interface NLME and NLDE.
Notes:
Copyright (c) 2006 by Texas Instruments, Inc.
All Rights Reserved. Permission to use, reproduce, copy, prepare
derivative works, modify, distribute, perform, display or sell this
software and/or its documentation for any purpose is prohibited
without the express written consent of Texas Instruments, Inc.
*********************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
/*********************************************************************
* INCLUDES
*/
#include "ZMAC.h"
#include "AssocList.h"
#include "nwk_bufs.h"
/*********************************************************************
* MACROS
*/
/*********************************************************************
* CONSTANTS
*/
// Tx Options (bitmap values)
#define TX_OPTIONS_GTS 0x01
#define TX_OPTIONS_SECURITY_ENABLE 0x02
// Beacon Order Values
#define BEACON_ORDER_NO_BEACONS 15
#define BEACON_ORDER_4_MINUTES 14 // 245760 milliseconds
#define BEACON_ORDER_2_MINUTES 13 // 122880 milliseconds
#define BEACON_ORDER_1_MINUTE 12 // 61440 milliseconds
#define BEACON_ORDER_31_SECONDS 11 // 30720 milliseconds
#define BEACON_ORDER_15_SECONDS 10 // 15360 MSecs
#define BEACON_ORDER_7_5_SECONDS 9 // 7680 MSecs
#define BEACON_ORDER_4_SECONDS 8 // 3840 MSecs
#define BEACON_ORDER_2_SECONDS 7 // 1920 MSecs
#define BEACON_ORDER_1_SECOND 6 // 960 MSecs
#define BEACON_ORDER_480_MSEC 5
#define BEACON_ORDER_240_MSEC 4
#define BEACON_ORDER_120_MSEC 3
#define BEACON_ORDER_60_MSEC 2
#define BEACON_ORDER_30_MSEC 1
#define BEACON_ORDER_15_MSEC 0
#define STARTING_SCAN_DURATION 5
#define MAX_SCAN_DURATION 15
#define ENERGY_SCAN_INCREMENT 16
// Capability Information Field Bitmap values
#define CAPINFO_ALTPANCOORD 0x01
#define CAPINFO_DEVICETYPE_FFD 0x02
#define CAPINFO_DEVICETYPE_RFD 0x00
#define CAPINFO_POWER_AC 0x04
#define CAPINFO_RCVR_ON_IDLE 0x08
#define CAPINFO_SECURITY_CAPABLE 0x40
#define CAPINFO_ALLOC_ADDR 0x80
// *********************** BROADCAST SUPPORT **********************************
// Broadcast address definitions
enum bcast_addr_e {
NWK_BROADCAST_SHORTADDR_RESRVD_F8 = 0xFFF8,
NWK_BROADCAST_SHORTADDR_RESRVD_F9,
NWK_BROADCAST_SHORTADDR_RESRVD_FA,
NWK_BROADCAST_SHORTADDR_RESRVD_FB,
NWK_BROADCAST_SHORTADDR_DEVZCZR, // 0xFFFC: Routers and Coordinators
NWK_BROADCAST_SHORTADDR_DEVRXON, // 0xFFFD: Everyone with RxOnWhenIdle == TRUE
// 0xFFFE: Reserved (legacy: used for 'invalid address')
NWK_BROADCAST_SHORTADDR_DEVALL = 0xFFFF
};
typedef enum bcast_addr_e bcast_addr_t;
#define NWK_BROADCAST_SHORTADDR NWK_BROADCAST_SHORTADDR_DEVALL
// Broadcast filter support
#define NWK_BROADCAST_FILTER_DEVALL ((uint8)0x01)
#define NWK_BROADCAST_FILTER_DEVRXON ((uint8)0x02)
#define NWK_BROADCAST_FILTER_DEVZCZR ((uint8)0x04)
#define NWK_BROADCAST_FILTER_RESRVD ((uint8)0x08)
#define NWK_BROADCAST_FILTER_ANY ( \
NWK_BROADCAST_FILTER_DEVALL | \
NWK_BROADCAST_FILTER_DEVRXON | \
NWK_BROADCAST_FILTER_DEVZCZR | \
NWK_BROADCAST_FILTER_RESRVD \
)
enum addr_filter_e {
ADDR_NOT_BCAST, // not a broadcast address
ADDR_BCAST_NOT_ME, // broadcast address but not for me based on capabilities
ADDR_BCAST_FOR_ME // broadcast for me based on capabilities
};
typedef enum addr_filter_e addr_filter_t;
// *********************** END BROADCAST SUPPORT **********************************
// NV Enables - for use when saving NV [NLME_UpdateNV()]
#define NWK_NV_NIB_ENABLE 0x01
#define NWK_NV_DEVICELIST_ENABLE 0x02
#define NWK_NV_BINDING_ENABLE 0x04
#define NWK_NV_ADDRMGR_ENABLE 0x08
/*********************************************************************
* TYPEDEFS
*/
typedef enum
{
nwkSequenceNum = 0x81,
nwkPassiveAckTimeout,
nwkMaxBroadcastRetries,
nwkMaxChildren,
nwkMaxDepth,
nwkMaxRouters,
nwkNeighborTable,
nwkBroadcastDeliveryTime,
nwkReportConstantCost,
nwkRouteDiscRetries, // 0x8a
nwkRoutingTable,
nwkSecureAllFrames,
nwkSecurityLevel,
nwkSymLink,
nwkCapabilityInfo, // 0x8f
// next 5 attributes are only needed for alternate addressing...
//nwkUseTreeAddrAlloc, // boolean
//nwkUseTreeRouting, // boolean
//nwkNextAddress, // 16 bit
//nwkAvailableAddresses, // 16 bit
//nwkAddressIncrement, // 16 bit
nwkTransactionPersistenceTime = 0x95, // 16 bit
//nwkShortAddress, // 16 bit
//nwkStackProfile,
nwkProtocolVersion = 0x98,
//nwkAllowAddressReuse, // Boolean
//nwkGroupIDTable,
// non-standard items
nwkRouteDiscoveryTime = 0x9B,
nwkNumNeighborTableEntries,
nwkNumRoutingTableEntries,
nwkNwkState,
nwkMAX_NIB_ITEMS // Must be the last entry
}ZNwkAttributes_t;
typedef struct
{
uint16 panId;
byte logicalChannel;
byte beaconOrder;
byte superFrameOrder;
byte routerCapacity;
byte deviceCapacity;
byte version;
byte stackProfile;
//byte securityLevel;
uint16 chosenRouter;
byte chosenRouterDepth;
uint8 extendedPANID[Z_EXTADDR_LEN];
void *nextDesc;
} networkDesc_t;
typedef struct
{
uint8 bufLength;
uint8 hdrLen;
uint8 frameType;
uint8 protocolVersion;
uint8 discoverRoute;
uint8 multicast;
uint8 secure;
//uint8 srcRouteSet;
uint8 dstExtAddrSet;
uint8 srcExtAddrSet;
uint16 dstAddr;
uint16 srcAddr;
uint8 radius;
uint8 broadcastId;
uint8* dstExtAddr;
uint8* srcExtAddr;
uint8 nsduLength;
uint8* nsdu;
} NLDE_FrameFormat_t;
#define NLME_SCAN_FIELDS_RES_SIZE 1
typedef struct
{
uint8 frameType;
uint8 hdrLen;
uint16 dstAddr;
uint16 srcAddr;
uint8* nsdu;
uint8 nsduLen;
uint8 nsduHandle;
uint16 nsduHandleOptions;
uint8 secure;
uint8 discoverRoute;
uint8 radius;
uint8 seqNum;
uint8 multicast;
//uint8 srcRouteSet;
uint8 dstExtAddrSet;
uint8 srcExtAddrSet;
uint8* dstExtAddr;
uint8* srcExtAddr;
void* fd;
} NLDE_FrameData_t;
typedef struct
{
//ZMacDataReq_t mfd;
NLDE_FrameData_t nfd;
} NLDE_DataReq_t;
typedef struct
{
uint8 overhead;
uint8 nsduLen;
uint8 secure;
} NLDE_DataReqAlloc_t;
typedef struct
{
uint32 channels;
uint8 duration;
} NLME_ScanFields_t;
typedef struct
{
nwkDB_t* db;
ZStatus_t status;
} NLDE_DataCnf_t;
typedef struct
{
uint8* extAddr;
uint8 removeChildren;
uint8 rejoin;
uint8 silent;
} NLME_LeaveReq_t;
typedef struct
{
uint8 removeChildren;
uint8 rejoin;
} NLME_LeaveRsp_t;
typedef struct
{
uint16 dstAddr;
uint8 extAddr[Z_EXTADDR_LEN];
uint8 removeChildren;
uint8 rejoin;
uint8 status;
} NLME_LeaveCnf_t;
typedef struct
{
uint16 srcAddr;
uint8 extAddr[Z_EXTADDR_LEN];
uint8 request;
uint8 removeChildren;
uint8 rejoin;
} NLME_LeaveInd_t;
/*********************************************************************
* GLOBAL VARIABLES
*/
extern byte NLME_PermitJoining;
extern byte NLME_AssocPermission;
extern uint16 savedResponseRate; // Backed response rate for rejoin request
// network discovery scan fields
extern NLME_ScanFields_t* NLME_ScanFields;
/*********************************************************************
* NWK Data Service
* NLDE-DATA
*/
/*
* This function requests the transfer of data using the NWK layer
* data service.
*
* @MT SPI_CMD_NLDE_DATA_REQ
*
*/
extern ZStatus_t NLDE_DataReq( NLDE_DataReq_t* req );
/*
* This function allocates a request buffer for use with the NWK layer
* data service.
*
*/
extern NLDE_DataReq_t* NLDE_DataReqAlloc( NLDE_DataReqAlloc_t* dra );
/*
* This function reports the results of a request to transfer a data
* PDU (NSDU) from a local APS sub-layer entity to a single peer APS
* sub-layer entity.
*
* @MT SPI_CB_NLDE_DATA_CNF
*
*/
extern void NLDE_DataCnf( NLDE_DataCnf_t* cnf );
/*
* This function indicates the transfer of a data PDU (NSDU) from the
* NWK layer to the local APS sub-layer entity.
*
* @MT SPI_CB_NLDE_DATA_IND
* (uint16 SrcAddress,
* byte NSDULength,
* byte *NSDU,
* byte LinkQuality)
*
*/
extern void NLDE_DataIndication( NLDE_FrameFormat_t *ff, byte LinkQuality, uint32 timestamp );
/*********************************************************************
* NWK Management Service
* NLME-NETWORK-FORMATION
* NLME-NETWORK-DISCOVERY
* NLME-PERMIT-JOINING
* NLME-JOIN
* NLME-DIRECT-JOIN
* NLME-ORPHAN-JOIN
* NLME-START-ROUTER
* NLME-SYNC
* NLME-LEAVE
* NLME-RESET
* NLME-GET
* NLME-SET
*/
/*
* This function allows the next higher layer to request that the device
* form a new network and become the ZigBee Coordinator for that network.
*
* @MT SPI_CMD_NLME_INIT_COORD_REQ
* (uint16 PanId,
* uint32 ScanChannels,
* byte BeaconOrder,
* byte ScanDuration,
* byte SuperFrameOrder,
* byte BatteryLifeExtension)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -