📄 mac_802_15_4.h
字号:
// Copyright (c) 2001-2008, Scalable Network Technologies, Inc. All Rights Reserved.// 6701 Center Drive West// Suite 520// Los Angeles, CA 90045// sales@scalable-networks.com//// This source code is licensed, not sold, and is subject to a written// license agreement. Among other things, no portion of this source// code may be copied, transmitted, disclosed, displayed, distributed,// translated, used as the basis for a derivative work, or used, in// whole or in part, for any program or purpose other than its intended// use in compliance with the license agreement as part of the QualNet// software. This source code and certain of the algorithms contained// within it are confidential trade secrets of Scalable Network// Technologies, Inc. and may not be used as the basis for any other// software, hardware, product or service.#ifndef MAC_802_15_4_H#define MAC_802_15_4_H#include "api.h"#include "mac_802_15_4_cmn.h"#include "csma_802_15_4.h"#include "sscs_802_15_4.h"#include "phy_802_15_4.h"#include "mac_802_15_4_transac.h"//--------------------------------------------------------------------------// #define's//--------------------------------------------------------------------------// /**// CONSTANT :: aNumSuperframeSlots : 16// DESCRIPTION :: # of slots contained in a superframe// **/const UInt8 aNumSuperframeSlots = 16;// /**// CONSTANT :: aBaseSlotDuration : 60// DESCRIPTION :: # of symbols comprising a superframe slot of order 0// **/const UInt8 aBaseSlotDuration = 60;// /**// CONSTANT :: aBaseSuperframeDuration :// aBaseSlotDuration*aNumSuperframeSlots// DESCRIPTION :: # of symbols comprising a superframe of order 0// **/const UInt16 aBaseSuperframeDuration = aBaseSlotDuration*aNumSuperframeSlots;// /**// CONSTANT :: aMaxBE : 5// DESCRIPTION :: max value of the backoff exponent in the CSMA-CA algorithm// **/const UInt8 aMaxBE = 6;// /**// CONSTANT :: aGTSDescPersistenceTime : 4// DESCRIPTION :: # of superframes that a GTS descriptor exists in the beacon// frame of a PAN coordinator// **/const UInt8 aGTSDescPersistenceTime = 4;// /**// CONSTANT :: aMaxFrameOverhead : 25// DESCRIPTION :: max # of octets added by the MAC sublayer to its payload// w/o security.// **/const UInt8 aMaxFrameOverhead = 25;// /**// CONSTANT :: aMaxFrameResponseTime : 10000// DESCRIPTION :: max # of symbols (or CAP symbols) to wait for a response// frame// **/const UInt16 aMaxFrameResponseTime = 10000;// /**// CONSTANT :: aMaxFrameRetries : 3// DESCRIPTION :: max # of retries allowed after a transmission failures// **/const UInt8 aMaxFrameRetries = 3;// /**// CONSTANT :: aMaxLostBeacons : 4// DESCRIPTION :: max # of consecutive beacons the MAC sublayer can miss w/o// declaring a loss of synchronization// **/const UInt8 aMaxLostBeacons = 4;// /**// CONSTANT :: aMaxMACFrameSize : aMaxPHYPacketSize - aMaxFrameOverhead// DESCRIPTION :: max # of octets that can be transmitted in the MAC frame// payload field// **/const UInt8 aMaxMACFrameSize = aMaxPHYPacketSize - aMaxFrameOverhead;// /**// CONSTANT :: aMaxSIFSFrameSize : 18// DESCRIPTION :: max size of a frame, in octets, that can be followed by a// SIFS period// **/const UInt8 aMaxSIFSFrameSize = 18;// /**// CONSTANT :: aMinCAPLength : 440// DESCRIPTION :: min # of symbols comprising the CAP// **/const UInt16 aMinCAPLength = 440;// /**// CONSTANT :: aMinLIFSPeriod : 40// DESCRIPTION :: min # of symbols comprising a LIFS period// **/const UInt8 aMinLIFSPeriod = 40;// /**// CONSTANT :: aMinSIFSPeriod : 12// DESCRIPTION :: min # of symbols comprising a SIFS period// **/const UInt8 aMinSIFSPeriod = 12;// /**// CONSTANT :: aResponseWaitTime : 32 * aBaseSuperframeDuration// DESCRIPTION :: max # of symbols a device shall wait for a response command// following a request command// **/const UInt16 aResponseWaitTime = 32 * aBaseSuperframeDuration;// /**// CONSTANT :: aUnitBackoffPeriod : 20// DESCRIPTION :: # of symbols comprising the basic time period used by the// CSMA-CA algorithm// **/const UInt8 aUnitBackoffPeriod = 20;//maximum propagation delayconst clocktype max_pDelay = (100 * SECOND/200000000);#define TxOp_Acked 0x01#define TxOp_GTS 0x02#define TxOp_Indirect 0x04#define TxOp_SecEnabled 0x08// /**// CONSTANT :: M802_15_4_ACKWAITDURATION : 200// DESCRIPTION :: The maximum number of symbols to wait for an acknowledgment// frame to arrive following a transmitted data frame.// **/#define M802_15_4_ACKWAITDURATION 650// /**// CONSTANT :: M802_15_4_ASSOCIATIONPERMIT : FALSE// DESCRIPTION :: Indicates whether a co-ordinator is allowing association.// **/#define M802_15_4_ASSOCIATIONPERMIT FALSE// /**// CONSTANT :: M802_15_4_AUTOREQUEST : TRUE// DESCRIPTION :: Indicates whether a device automatically sends data// request command if its address is listed in beacon frame.// **/#define M802_15_4_AUTOREQUEST TRUE// /**// CONSTANT :: M802_15_4_BATTLIFEEXT : FALSE// DESCRIPTION :: Indicates whether BLE is enabled.// **/#define M802_15_4_BATTLIFEEXT FALSE// /**// CONSTANT :: M802_15_4_BATTLIFEEXTPERIODS : 6// DESCRIPTION :: In BLE mode, the number of backoff periods during which// the receiver is enabled after the IFS following a beacon.// **/#define M802_15_4_BATTLIFEEXTPERIODS 6// /**// CONSTANT :: M802_15_4_BEACONPAYLOAD : ""// DESCRIPTION :: The contents of the beacon payload.// **/#define M802_15_4_BEACONPAYLOAD ""// /**// CONSTANT :: M802_15_4_BEACONPAYLOADLENGTH : 0// DESCRIPTION :: Beacon payload length in octets.// **/#define M802_15_4_BEACONPAYLOADLENGTH 0// /**// CONSTANT :: M802_15_4_BEACONORDER : 15// DESCRIPTION :: Specification of how often the coordinator transmits its// beacon.// **/#define M802_15_4_BEACONORDER 15// /**// CONSTANT :: M802_15_4_BEACONTXTIME : 0x000000// DESCRIPTION :: The time that the device transmitted its last beacon// frame, in symbol periods.// **/#define M802_15_4_BEACONTXTIME 0x000000// /**// CONSTANT :: M802_15_4_BSN : 0// DESCRIPTION :: Beacon sequence number// **/#define M802_15_4_BSN 0// /**// CONSTANT :: M802_15_4_COORDEXTENDEDADDRESS : 0xffff// DESCRIPTION :: The 64-bit address of the coordinator through which the// device is associated.// **/#define M802_15_4_COORDEXTENDEDADDRESS 0xffff// /**// CONSTANT :: M802_15_4_COORDSHORTADDRESS : 0xffff// DESCRIPTION :: The 16-bit address of the coordinator through which the// device is associated.// **/#define M802_15_4_COORDSHORTADDRESS 0xffff// /**// CONSTANT :: M802_15_4_DSN : 0// DESCRIPTION :: Beacon sequence number// **/#define M802_15_4_DSN 0// /**// CONSTANT :: M802_15_4_GTSPERMIT : TRUE// DESCRIPTION :: Indicates whether PAN co-ordinator accepts GTS requests.// **/#define M802_15_4_GTSPERMIT TRUE// /**// CONSTANT :: M802_15_4_MAXCSMABACKOFFS : 4// DESCRIPTION :: The maximum value of the backoff exponent, BE, in the// CSMA-CA algorithm.// **/#define M802_15_4_MAXCSMABACKOFFS 4// /**// CONSTANT :: M802_15_4_MINBE : 3// DESCRIPTION :: The minimum value of the backoff exponent, BE, in the// CSMA-CA algorithm.// **/#define M802_15_4_MINBE 3// /**// CONSTANT :: M802_15_4_PANID : 0xffff// DESCRIPTION :: The 16-bit identifier of the PAN on which the device is// operating.// **/#define M802_15_4_PANID 0xffff// /**// CONSTANT :: M802_15_4_PROMISCUOUSMODE : FALSE// DESCRIPTION :: Indicates whether MAC sublayer is in a promiscuous mode// **/#define M802_15_4_PROMISCUOUSMODE FALSE// /**// CONSTANT :: M802_15_4_RXONWHENIDLE : FALSE// DESCRIPTION :: Indicates whether MAC is to enable its receiver during idle// periods.// **/#define M802_15_4_RXONWHENIDLE FALSE// /**// CONSTANT :: M802_15_4_SHORTADDRESS : 0xffff// DESCRIPTION :: The 16-bit address that the device uses to communicate// in the PAN.// **/#define M802_15_4_SHORTADDRESS 0xffff// /**// CONSTANT :: M802_15_4_SUPERFRAMEORDER : 15// DESCRIPTION :: The length of the active portion of the outgoing// superframe, including the beacon frame.// **/#define M802_15_4_SUPERFRAMEORDER 15// /**// CONSTANT :: M802_15_4_TRANSACTIONPERSISTENCETIME : 0x01f4// DESCRIPTION :: The maximum time (in unit periods) that a transaction is// stored by a coordinator and indicated in its beacon.// **/#define M802_15_4_TRANSACTIONPERSISTENCETIME 0x01f4// /**// CONSTANT :: M802_15_4_ACLENTRYDESCRIPTORSET : NULL// DESCRIPTION ::// **/#define M802_15_4_ACLENTRYDESCRIPTORSET NULL// /**// CONSTANT :: M802_15_4_ACLENTRYDESCRIPTORSETSIZE : 0x00// DESCRIPTION ::// **/#define M802_15_4_ACLENTRYDESCRIPTORSETSIZE 0x00// /**// CONSTANT :: M802_15_4_DEFAULTSECURITY : FALSE// DESCRIPTION ::// **/#define M802_15_4_DEFAULTSECURITY FALSE// /**// CONSTANT :: M802_15_4_ACLDEFAULTSECURITYMATERIALLENGTH : 0x15// DESCRIPTION ::// **/#define M802_15_4_ACLDEFAULTSECURITYMATERIALLENGTH 0x15// /**// CONSTANT :: M802_15_4_DEFAULTSECURITYMATERIAL : NULL// DESCRIPTION ::// **/#define M802_15_4_DEFAULTSECURITYMATERIAL NULL// /**// CONSTANT :: M802_15_4_DEFAULTSECURITYSUITE : 0x00// DESCRIPTION ::// **/#define M802_15_4_DEFAULTSECURITYSUITE 0x00// /**// CONSTANT :: M802_15_4_SECURITYMODE : 0x00// DESCRIPTION ::// **/#define M802_15_4_SECURITYMODE 0x00// /**// CONSTANT :: M802_15_4_DEFAULTDEVCAP : 0xc1// DESCRIPTION :: Default device capabilities// alterPANCoor = true// FFD = true// mainsPower = false// recvOnWhenIdle = false// secuCapable = false// alloShortAddr = true// **/#define M802_15_4_DEFAULTDEVCAP 0xc1#define M802_15_4DEFFRMCTRL_TYPE_BEACON 0x00#define M802_15_4DEFFRMCTRL_TYPE_DATA 0x01#define M802_15_4DEFFRMCTRL_TYPE_ACK 0x02#define M802_15_4DEFFRMCTRL_TYPE_MACCMD 0x03#define M802_15_4DEFFRMCTRL_ADDRMODENONE 0x01#define M802_15_4DEFFRMCTRL_ADDRMODE16 0x02#define M802_15_4DEFFRMCTRL_ADDRMODE64 0x03//--------------------------------------------------------------------------// typedef's enums//--------------------------------------------------------------------------// /**// ENUM :: M802_15_4TimerType// DESCRIPTION :: Timers used by MAC// **/typedef enum{ M802_15_4TXOVERTIMER, M802_15_4TXTIMER, M802_15_4EXTRACTTIMER, M802_15_4ASSORSPWAITTIMER, M802_15_4DATAWAITTIMER, M802_15_4RXENABLETIMER, M802_15_4SCANTIMER, M802_15_4BEACONTXTIMER, M802_15_4BEACONRXTIMER, M802_15_4BEACONSEARCHTIMER, M802_15_4TXCMDDATATIMER, M802_15_4BACKOFFBOUNDTIMER, M802_15_4ORPHANRSPTIMER, M802_15_4IFSTIMER, M802_15_4CHECKOUTGOING}M802_15_4TimerType;//--------------------------------------------------------------------------// typedef's struct//--------------------------------------------------------------------------typedef struct mac_802_15_4_taskPending{ //---------------- BOOL mcps_data_request; UInt8 mcps_data_request_STEP; char mcps_data_request_frFunc[81]; UInt8 mcps_data_request_TxOptions; Message* mcps_data_request_pendPkt;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -