📄 mac_api.h
字号:
uint16 panId; /* The PAN ID to use. This parameter is ignored if panCoordinator is FALSE */
uint8 logicalChannel; /* The logical channel to use. This parameter is ignored if panCoordinator is FALSE */
uint8 channelPage; /* The channel page to use. This parameter is ignored if panCoordinator is FALSE */
uint8 beaconOrder; /* The exponent used to calculate the beacon interval */
uint8 superframeOrder; /* The exponent used to calculate the superframe duration */
bool panCoordinator; /* Set to TRUE to start a network as PAN coordinator */
bool batteryLifeExt; /* If this value is TRUE, the receiver is disabled after MAC_BATT_LIFE_EXT_PERIODS
full backoff periods following the interframe spacing period of the beacon frame */
bool coordRealignment; /* Set to TRUE to transmit a coordinator realignment prior to changing
the superframe configuration */
macSec_t realignSec; /* Security parameters for the coordinator realignment frame */
macSec_t beaconSec; /* Security parameters for the beacon frame */
} macMlmeStartReq_t;
/* MAC_MlmeSyncReq type */
typedef struct
{
uint8 logicalChannel; /* The logical channel to use */
uint8 channelPage; /* The channel page to use */
bool trackBeacon; /* Set to TRUE to continue tracking beacons after synchronizing with the
first beacon. Set to FALSE to only synchronize with the first beacon */
} macMlmeSyncReq_t;
/* MAC_MLME_ASSOCIATE_IND type */
typedef struct
{
macEventHdr_t hdr; /* The event header */
sAddrExt_t deviceAddress; /* The address of the device requesting association */
uint8 capabilityInformation; /* The operational capabilities of the device requesting association */
macSec_t sec; /* The security parameters for this message */
} macMlmeAssociateInd_t;
/* MAC_MLME_ASSOCIATE_CNF type */
typedef struct
{
macEventHdr_t hdr; /* Event header contains the status of the associate attempt */
uint16 assocShortAddress; /* If successful, the short address allocated to this device */
macSec_t sec; /* The security parameters for this message */
} macMlmeAssociateCnf_t;
/* MAC_MLME_DISASSOCIATE_IND type */
typedef struct
{
macEventHdr_t hdr; /* The event header */
sAddrExt_t deviceAddress; /* The address of the device sending the disassociate command */
uint8 disassociateReason; /* The disassociate reason */
macSec_t sec; /* The security parameters for this message */
} macMlmeDisassociateInd_t;
/* MAC_MLME_DISASSOCIATE_CNF type */
typedef struct
{
macEventHdr_t hdr; /* Event header contains the status of the disassociate attempt */
sAddr_t deviceAddress; /* The address of the device that has either requested disassociation
or been instructed to disassociate by its coordinator */
uint16 panId; /* The pan ID of the device that has either requested disassociation
or been instructed to disassociate by its coordinator */
} macMlmeDisassociateCnf_t;
/* MAC_MLME_BEACON_NOTIFY_IND type */
typedef struct
{
macEventHdr_t hdr; /* The event header */
uint8 bsn; /* The beacon sequence number */
macPanDesc_t *pPanDesc; /* The PAN descriptor for the received beacon */
uint8 pendAddrSpec; /* The beacon pending address specification */
uint8 *pAddrList; /* The list of device addresses for which the sender of the beacon has data */
uint8 sduLength; /* The number of bytes in the beacon payload of the beacon frame */
uint8 *pSdu; /* The beacon payload */
} macMlmeBeaconNotifyInd_t;
/* MAC_MLME_ORPHAN_IND type */
typedef struct
{
macEventHdr_t hdr; /* The event header */
sAddrExt_t orphanAddress; /* The address of the orphaned device */
macSec_t sec; /* The security parameters for this message */
} macMlmeOrphanInd_t;
/* MAC_MLME_SCAN_CNF type */
typedef struct
{
macEventHdr_t hdr; /* Event header contains the status of the scan request */
uint8 scanType; /* The type of scan requested */
uint8 channelPage; /* The channel page of the scan */
uint32 unscannedChannels; /* Bit mask of channels that were not scanned */
uint8 resultListSize; /* The number of PAN descriptors returned in the results list */
union
{
uint8 *pEnergyDetect; /* The list of energy measurements, one for each channel scanned */
macPanDesc_t *pPanDescriptor; /* The list of PAN descriptors, one for each beacon found */
} result;
} macMlmeScanCnf_t;
/* MAC_MLME_START_CNF type */
typedef struct
{
macEventHdr_t hdr; /* Event header contains the status of the start request */
} macMlmeStartCnf_t;
/* MAC_MLME_SYNC_LOSS_IND type */
typedef struct
{
macEventHdr_t hdr; /* Event header contains the reason that synchronization was lost */
uint16 panId; /* The PAN ID of the realignment */
uint8 logicalChannel; /* The logical channel of the realignment */
uint8 channelPage; /* The channel page of the realignment */
macSec_t sec; /* The security parameters for this message */
} macMlmeSyncLossInd_t;
/* MAC_MLME_POLL_CNF type */
typedef struct
{
macEventHdr_t hdr; /* Event header contains the status of the poll request */
} macMlmePollCnf_t;
/* MAC_MLME_COMM_STATUS_IND type */
typedef struct
{
macEventHdr_t hdr; /* Event header contains the status for this event */
sAddr_t srcAddr; /* The source address associated with the event */
sAddr_t dstAddr; /* The destination address associated with the event */
uint16 panId; /* The PAN ID associated with the event */
uint8 reason; /* The reason the event was generated */
macSec_t sec; /* The security parameters for this message */
} macMlmeCommStatusInd_t;
/* MAC_MLME_POLL_IND type */
typedef struct
{
macEventHdr_t hdr;
uint16 srcShortAddr; /* Short address of the device sending the data request */
uint16 srcPanId; /* Pan ID of the device sending the data request */
} macMlmePollInd_t;
/* Union of callback structures */
typedef union
{
macEventHdr_t hdr;
macMlmeAssociateInd_t associateInd; /* MAC_MLME_ASSOCIATE_IND */
macMlmeAssociateCnf_t associateCnf; /* MAC_MLME_ASSOCIATE_CNF */
macMlmeDisassociateInd_t disassociateInd; /* MAC_MLME_DISASSOCIATE_IND */
macMlmeDisassociateCnf_t disassociateCnf; /* MAC_MLME_DISASSOCIATE_CNF */
macMlmeBeaconNotifyInd_t beaconNotifyInd; /* MAC_MLME_BEACON_NOTIFY_IND */
macMlmeOrphanInd_t orphanInd; /* MAC_MLME_ORPHAN_IND */
macMlmeScanCnf_t scanCnf; /* MAC_MLME_SCAN_CNF */
macMlmeStartCnf_t startCnf; /* MAC_MLME_START_CNF */
macMlmeSyncLossInd_t syncLossInd; /* MAC_MLME_SYNC_LOSS_IND */
macMlmePollCnf_t pollCnf; /* MAC_MLME_POLL_CNF */
macMlmeCommStatusInd_t commStatusInd; /* MAC_MLME_COMM_STATUS_IND */
macMlmePollInd_t pollInd; /* MAC_MLME_POLL_IND */
macMcpsDataCnf_t dataCnf; /* MAC_MCPS_DATA_CNF */
macMcpsDataInd_t dataInd; /* MAC_MCPS_DATA_IND */
macMcpsPurgeCnf_t purgeCnf; /* MAC_MCPS_PURGE_CNF */
} macCbackEvent_t;
/* Configurable parameters */
typedef struct
{
uint8 txDataMax; /* maximum number of data frames in transmit queue */
uint8 txMax; /* maximum number of frames of all types in transmit queue */
uint8 rxMax; /* maximum number of command and data frames in receive queue */
uint8 dataIndOffset; /* allocate additional bytes in the data indication for
application-defined headers */
bool appPendingQueue; /* determine whether MAC_MLME_POLL_IND will be sent to the application or not
when data request is received and no pending frame is found in the MAC */
} macCfg_t;
/* ------------------------------------------------------------------------------------------------
* Internal Functions
* ------------------------------------------------------------------------------------------------
*/
/* These functions are used when creating the OSAL MAC task. They must not be used for any
* other purpose.
*/
extern void macTaskInit(uint8 taskId);
extern uint16 macEventLoop(uint8 taskId, uint16 events);
/* ------------------------------------------------------------------------------------------------
* Functions
* ------------------------------------------------------------------------------------------------
*/
/**************************************************************************************************
* @fn MAC_Init
*
* @brief This function initializes the MAC subsystem. It must be called once when the
* software system is started and before any other function in the MAC API
* is called.
*
* input parameters
*
* None.
*
* output parameters
*
* None.
*
* @return None.
**************************************************************************************************
*/
extern void MAC_Init(void);
/**************************************************************************************************
* @fn MAC_InitDevice
*
* @brief This function initializes the MAC to associate with a non
* beacon-enabled network. This function would be used to
* initialize a device as an RFD. If this function is used it
* must be called during application initialization before any
* other function in the data or management API is called.
*
* input parameters
*
* None.
*
* output parameters
*
* None.
*
* @return None.
**************************************************************************************************
*/
extern void MAC_InitDevice(void);
/**************************************************************************************************
* @fn MAC_InitCoord
*
* @brief This function initializes the MAC for operation as a
* coordinator. A coordinator can start a network, accept
* associate requests from other devices, send beacons, send
* indirect data, and other operations. This function would
* be used to initialize a device as an FFD. If this function
* is used it must be called during application initialization
* before any other function in the data or management API
* is called.
*
* input parameters
*
* None.
*
* output parameters
*
* None.
*
* @return None.
**************************************************************************************************
*/
extern void MAC_InitCoord(void);
/**************************************************************************************************
* @fn MAC_InitSecurity
*
* @brief This function initializes the MAC to allow use of security.
* If this function is used it must be called during application
* initialization before any other function in the data or
* management API is called.
*
* input parameters
*
* None.
*
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -