⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 zbmac.h

📁 IEEE802.15.4标准下的基于ZIGBEE协议栈的物理及链路层的代码
💻 H
字号:
#ifndef __ZBMAC_H__#define __ZBMAC_H__#include "ZBTYPES.h"#define POS_MAC_FRAME_TYPE 			0x0#define POS_MAC_SECURITY				0x3#define POS_MAC_FRAME_PENDING			0x4#define POS_MAC_ACK_REQUEST			0x5#define POS_MAC_INTRA_PAN			0x6#define POS_MAC_DEST_ADDR_MODE		0xA#define POS_MAC_SOURCE_ADDR_MODE		0xE	#define MASK_MAC_FRAME_TYPE 			0x7#define MASK_MAC_SECURITY			0x8#define MASK_MAC_FRAME_PENDING		0x10#define MASK_MAC_ACK_REQUEST			0x20#define MASK_MAC_INTRA_PAN			0x40#define MASK_MAC_DEST_ADDR_MODE		0xC00#define MASK_MAC_SOURCE_ADDR_MODE		0xC000#define MAC_FRAME_TYPE_BEACON			0x0#define MAC_FRAME_TYPE_DATA			0x1#define MAC_FRAME_TYPE_ACK			0x2#define MAC_FRAME_TYPE_CMD			0x3#define MAC_ADDR_MODE_NONE			0x0		//both pan id field and address filed absent#define MAC_ADDR_MODE_SHORT			0x2#define MAC_ADDR_MODE_LONG			0x3#define MAC_CMD_TYPE_ASSOC_REQ			0x1#define MAC_CMD_TYPE_ASSOC_RESPON			0x2#define MAC_CMD_TYPE_BEACON_REQ			0x7#define MAC_CMD_TYPE_ORPHAN_NOTIFY			0x6	 #define MAC_CMD_TYPE_COORD_REALIGN			0x8	 #define MAC_CMD_TYPE_GTS_REQ				0x6	 #define MAC_CMD_TYPE_DISASSOC_NOTIFY		0x3     #define MAC_CMD_TYPE_DATA_REQ				0x4	 #define MAC_CMD_TYPE_PANID_CONFLICT		0x5	 /** * the mac beacon which has zigbee infomation,zigbee sheet page 407 * FCF(2)+DSN(1)+SOURCE_PANID(2)+SOURCE_SADDR(2)+BEACON_INFO(2)+{|PROTOCOL_ID(1)+NWK_INFO(2)+IEEEADDR(8)|+FCS(2)|} **//** * BEACON_INFO(2byte) **/#define MAC_POS_BEACON_INFO_COORD					0xE#define MAC_POS_BEACON_INFO_ASSOC_PERMIT			0xF#define MAC_MASK_BEACON_INFO_COORD					0x4000#define MAC_MASK_BEACON_INFO_ASSOC_PERMIT			0x8000/** * PROTOCOL_ID(1byte) * declare that is zigbee protocol **/#define PROTOCOL_ID 	0x0     /** * NWK_INFO(2byte) **/#define POS_NWK_INFO_STACK_PROFILE				0x0#define MASK_NWK_INFO_STACK_PROFILE			0xF#define NWK_INFO_STACK_PROFILE_ID				0#define POS_NWK_INFO_VERSION					0x4#define MASK_NWK_INFO_VERSION					0xF0#define NWK_INFO_VERSION_ID					0/** * This value is set to TRUE if this device is capable of accepting join requests from router-capable * devices and is set to FALSE otherwise. **/#define POS_NWK_INFO_ROUTER_CAP				0xA	#define MASK_NWK_INFO_ROUTER_CAP				0x400	#define POS_NWK_INFO_DEPTH					0xB#define MASK_NWK_INFO_DEPTH					0x7800/** * This value is set to TRUE if the device is capable of accepting join requests from end devices * seeking to join the network and is set to FALSE otherwise **/#define POS_NWK_INFO_END_DEVICE_CAP			0xF		#define MASK_NWK_INFO_END_DEVICE_CAP			0x8000/** * request beacon * FCF(2)+DSN(1)+DST_PANID(2)+DST_SADDR(2)+CMD_TYPE(1)+FCS(2) **/#define LEN_REQ_BEACON 10/** * assoc request  * FCF(2)+DSN(1)+DST_PANID(2)+DST_SADDR(2)+SOURCE_PANID(2,0xffff)+SOURCE_LADDR(8)+CMD_TYPE(1)+CAP_INFO(1)+|ZIGBEE_NUM(4)|+FCS(2) **/ #define POS_MAC_CAP_INFO_CANCOORD			0x0	//can be a coord or not#define POS_MAC_CAP_INFO_DEVICE_TYPE		0x1	//is FFD or not	#define POS_MAC_CAP_INFO_POWER			0x2	//is power resouce different or not#define POS_MAC_CAP_INFO_RECEIVE_ON		0x3	//is rxOn when idle or not#define POS_MAC_CAP_INFO_SECURITY			0x6	//if has security capability#define POS_MAC_CAP_INFO_ALLOC_ADDR		0x7	//is requet for short address or not#define MASK_MAC_CAP_INFO_CANCOORD			0x1	#define MASK_MAC_CAP_INFO_DEVICE_TYPE		0x2			#define MASK_MAC_CAP_INFO_POWER			0x4	#define MASK_MAC_CAP_INFO_RECEIVE_ON		0x8	#define MASK_MAC_CAP_INFO_SECURITY			0x40	#define MASK_MAC_CAP_INFO_ALLOC_ADDR		0x80	/** self define **/#define ZIGBEE_NUM_0				0xFF#define ZIGBEE_NUM_1				0xFF#define ZIGBEE_NUM_2				0xFF#define ZIGBEE_NUM_3				0xFF/** * the assoc request answer * FCF(2)+DSN(1)+DST_PANID(2)+DST_LADDR(8)+SOURCE_PANID(2)+SOURCE_LADDR(8)+CMD_TYPE(1)+SADDR(2)+ASSOC_STATUS(1) **/ #define MAC_ASSOC_STATUS_SUCCESS			0x0#define MAC_ASSOC_STATUS_OVERFLOW			0x1#define MAC_ASSOC_STATUS_DENEY			0x2typedef struct _mac_pib_t {	struct {		unsigned int macAssociationPermit : 1;		unsigned int ifReceiveAllFrame : 1;		unsigned int macRxOnWhenIdle : 1;	}bits;	uint8_t macDsn;	//data sequence number;	#ifndef IS_COORD	laddr_t macCoordExtendedAddress;	saddr_t macCoordShortAddress;	#endif//	uint8_t macMaxCSMABackoffs;	//range  0-6//	uint8_t macMinBE;		//range  0-3	nxle_uint16_t* pPanId;		//point to phyPib panId	saddr_t* pShortAddr;	//point to phyPib shortAddress	laddr_t* pLongAddr;		//point to phyPib longAddress	uint8_t* pBeaconPayload;	uint8_t beaconPayloadLen;} mac_pib_t;	/** * mac_error_t emun. **/enum {  MAC_SUCCESS = 0,		//  MAC_CHANNEL_ACCESS_FAILURE = 0xe1,  MAC_DISABLE_TRX_FAILURE = 0xe3,  MAC_FRAME_TOO_LONG = 0xe5,  MAC_INVALID_PARAMETER = 0xe8,  MAC_NO_ACK = 0xe9,  MAC_NO_BEACON = 0xea,  MAC_NO_SHORT_ADDRESS = 0xec,  MAC_PAN_ID_CONFLICT = 0xee,  MAC_REALIGNMENT = 0xef,  MAC_TX_ACTIVE = 0xf2,};typedef struct {	uint8_t type;		bool isAckSend;	uint8_t dsn;	mem_head_t* psdu;	} mac_send_cache_t;typedef struct {	uint8_t lqi;	uint8_t length;	mem_head_t* psdu;} mac_receive_cache_t;#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -