?? frame.h
字號:
/*******************************************************************************
UBEC (Uniband Electronic Corp.)
Project: U-NET01, Ubiquitous network platform
File: frame.h
Version: 0.1.1
Usage: Define MAC frame
Platform: U-NET01 DK with IAR 8051 C compiler
Reference:
Silicon Laboratories: C8051F124
UBEC: UZ2400
Note :
Copyright (C) 2007 Uniband Electronic Corporation, All rights reserved
********************************************************************************/
//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_ADDR_LIST_REQ 0x10
#define MT_ADDR_LIST_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;
}__attribute__ ((packed));
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
}__attribute__ ((packed));
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
}__attribute__ ((packed));
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
}__attribute__ ((packed));
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;
}__attribute__ ((packed));
typedef struct _mac_data_packet_ MAC_DATA_PKT;
struct _mac_command_packet_
{
MAC_HEADER MHR;
UINT8 COMM_ID;
//UINT8 *PAYLOAD;
//UINT16 FCS
}__attribute__ ((packed));
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;
}__attribute__ ((packed));
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
}__attribute__ ((packed));
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
}__attribute__ ((packed));
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;
}__attribute__ ((packed));
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
}__attribute__ ((packed));
typedef struct _disassociation_notification_ MCP_DISASSO_NTF;
//Self - Healing
struct _find_parent_of_parent_request_{
MAC_HEADER MHR;
UINT8 COMM_ID;
UINT16 Parent;
}__attribute__ ((packed));
typedef struct _find_parent_of_parent_request_ MCP_IPOP;
struct _parent_back_{
MAC_HEADER MHR;
UINT8 COMM_ID;
UINT16 Parent;
}__attribute__ ((packed));
typedef struct _parent_back_ MCP_PBACK;
struct _child_back_{
MAC_HEADER MHR;
UINT8 COMM_ID;
UINT8 MacAddr[8];
UINT8 Cap;
}__attribute__ ((packed));
typedef struct _child_back_ MCP_CBACK;
struct _addr_list_request_
{
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
}__attribute__ ((packed));
typedef struct _addr_list_request_ MCP_ADDR_LIST_REQ; // 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
}__attribute__ ((packed));
typedef struct _addr_list_rsp_ MCP_ADDR_LIST_RSP; // MAC Command Packet
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -