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

📄 frame.h

📁 运用ZIGBEE和凌阳16位语音单片机实现无线QQ通信功能
💻 H
字号:
//====================================================================================
// 文 件 名: frame.h
// 功能描述: 帧格式定义
// 维护记录: 2007年9月5日
//====================================================================================

//IEEE 802.15.4 frame type
#define FRM_TYPE_BCN 0
#define FRM_TYPE_DATA 1 
#define FRM_TYPE_ACK 2
#define FRM_TYPE_COMM 3

//IEEE 802.15.4 command type
#define MT_ASSO_REQ 0x01
#define MT_ASSO_RSP 0x02
#define MT_DISASSO_NTF 0x03
//#define MT_DATA_REQ 0x04
//#define MT_PANID_CONFLICT 0x05
//#define MT_ORPHAN_NTF 0x06
#define MT_BEACON_REQ 0x07
//#define MT_COOR_REALIGNMENT 0x08
//#define MT_GTS_REQ 0x09

#define MT_DATA_IND 0x0a
#define MT_BCN_IND 0x0b


#define MT_IPOP 0x0c
#define MT_PBACK 0x0d
#define MT_CBACK 0x0e
#define MT_REBPAN 0xff

#define MT_KEEPLINK_REQ 0x10
#define MT_KEEPLINK_RSP 0x11

/********************************************************************************

	MAC Packet Format
					
********************************************************************************/

// Frame Control of IEEE 802.15.4
union _mac_frame_control_{
	UINT16 val;

	struct{
		UINT16 FrmType:3;
		UINT16 Security:1;
		UINT16 FrmPend:1;
		UINT16 AckReq:1;
		UINT16 IntraPAN:1;
		UINT16 Rvd0:3;
		UINT16 DstMod:2;
		UINT16 Rvd1:2;
		UINT16 SrcMod:2;
	}bit;
};
typedef union _mac_frame_control_	MAC_FC;

struct _mac_header_{
	MAC_FC Header;
	UINT8 Seqnum; //Sequence number
	UINT16 DstPID; // Destination pan id
	UINT16 DstAddr; // Destination address
	UINT16 SrcPID;// Source pan id
	UINT16 SrcAddr; // Source address
};
typedef struct _mac_header_		MAC_HEADER;

struct _mac_beacon_payload_{
	UINT8 ProtID; // Protocol ID
	UINT8 StackPro:4; // Stack profile
	UINT8 ProtVer:4; // Protocol version
	UINT8 Rvd0:2;
	UINT8 RouterCap:1; // Router capacity
	UINT8 DevDep:4; // Device depth
	UINT8 EndevCap:1; //End device capacity
};
typedef struct _mac_beacon_payload_		MAC_BP;

struct _mac_beacon_packet_{
	MAC_FC Header;
	UINT8 Seqnum; //Sequence number
	UINT16 SrcPID;// Source pan id
	UINT16 SrcAddr; // Source address
	UINT16 SFS; // Superframe specification
	UINT8 GTSF; // GTS Filed
	UINT8 PASF; // Pending address specification filed
	MAC_BP PAYLOAD; // Beacon payload	
	//UINT16 FCS
};
typedef struct _mac_beacon_packet_	MAC_BCN_PKT;

struct _mac_data_packet_{
	MAC_HEADER MHR;
	UINT8 Radius;
	UINT16 NwkSrcAddr; // Unet spec
	UINT16 NwkDstAddr; // Unet spec
	//UINT8 *PAYLOAD;
};
typedef struct _mac_data_packet_	MAC_DATA_PKT;

struct _mac_command_packet_
{
	MAC_HEADER MHR;
	UINT8 COMM_ID;
	//UINT8 *PAYLOAD;
	//UINT16 FCS
};
typedef struct _mac_command_packet_  MAC_CMD_PKT;


/********************************************************************************

	MAC Sub Command Packet Format
					
********************************************************************************/

// Association request
union _capability_information_field_{
	UINT8 val;
	
	struct{
		UINT8 AltCoord:1; // Alternate PAN coordinator
		UINT8 DevType:1; // Device type
		UINT8 PowSrc:1; // Power source
		UINT8 ROWI:1; // Receiver on when idle
		UINT8 Rvd0:2;
		UINT8 SecCap:1; // Security capability
		UINT8 AllocAddr:1; // Allocate address		 
	}bit;
};

struct _association_request_{
	MAC_FC Header;
	UINT8 Seqnum; //Sequence number
	UINT16 DstPID; // Destination pan id
	UINT16 DstAddr; // Destination address
	UINT16 SrcPID;// Source pan id
	UINT8 SrcAddr[8]; // Source address
	UINT8 COMM_ID;
	//union _capability_information_field_ Cap;
	UINT8 Cap;
	//UINT16 FCS
};
typedef struct _association_request_	MCP_ASSO_REQ; // MAC Command Packet


//Association Status
#define ASSOCIATION_SUCCESS	0x00
#define PAN_AT_CAPACITY		0x01
#define PAN_ACCESS_DENIED		0x02
#define OTHER_STATUS			0x04

struct _association_reponse_{
	//MAC_CMD_PKT CmdFrm;
	MAC_FC Header;
	UINT8 Seqnum; //Sequence number
	UINT16 DstPID; // Destination pan id
	UINT8 DstAddr[8]; // Destination address
	UINT16 SrcPID;// Source pan id
	UINT16 SrcAddr; // Source address
	UINT8 COMM_ID; // Command identifiter
	UINT16 ShortAddr; // Short address
	UINT8 AssoStatus; // Association status
	//UINT16 FCS
};
typedef struct _association_reponse_	MCP_ASSO_RSP;

struct _bacon_request_{
	MAC_FC Header;
	UINT8 Seqnum; //Sequence number
	UINT16 DstPID; // Destination pan id
	UINT16 DstAddr; // Destination address
	UINT8 COMM_ID;
};
typedef struct _bacon_request_	MCP_BCN_REQ;


struct _disassociation_notification_{
	MAC_FC Header;
	UINT8 Seqnum; //Sequence number
	UINT16 DstPID; // Destination pan id
	UINT8 DstAddr[8]; // Destination address
	UINT16 SrcPID;// Source pan id
	UINT16 SrcAddr; // Source address
	UINT8 COMM_ID; // Command identifiter
	UINT8 DisassoReason; // Short address
};
typedef struct _disassociation_notification_	MCP_DISASSO_NTF;

//Self - Healing  
struct _find_parent_of_parent_request_{
	MAC_HEADER MHR;
	UINT8 COMM_ID;
	UINT16 Parent;
};
typedef struct _find_parent_of_parent_request_	MCP_IPOP;

struct _parent_back_{
	MAC_HEADER MHR;
	UINT8 COMM_ID;
	UINT16 Parent;
};
typedef struct _parent_back_	MCP_PBACK;

struct _child_back_{
	MAC_HEADER MHR;
	UINT8 COMM_ID;
	UINT8 MacAddr[8];
	UINT8 Cap;	
};
typedef struct _child_back_		MCP_CBACK;

struct _Link_Keep_
{
	MAC_FC Header;
	UINT8 Seqnum; //Sequence number
	UINT16 DstPID; // Destination pan id
	UINT16 DstAddr; // Destination address
	UINT16 SrcPID;// Source pan id
	UINT16 SrcAddr; // Source address
	UINT8 COMM_ID;
	//union _capability_information_field_ Cap;
//	UINT8 Cap;
	//UINT16 FCS
};
typedef struct _Link_Keep_	LINK_KEEP; // MAC Command Packet

struct _addr_list_rsp_
{
	MAC_FC Header;
	UINT8 Seqnum; //Sequence number
	UINT16 DstPID; // Destination pan id
	UINT16 DstAddr; // Destination address
	UINT16 SrcPID;// Source pan id
	UINT16 SrcAddr; // Source address
	UINT8 COMM_ID;
	
	UINT8 AddrCont;
	//UINT16 FCS
};
typedef struct _addr_list_rsp_	MCP_ADDR_LIST_RSP; // MAC Command Packet

⌨️ 快捷键说明

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