802.15.4 Mac Api
802.15.4 Mac Api
4 MAC
Application Programming Interface
Version
Description
Date
1.0
Initial release.
07/25/2006
1.1
06/13/2007
1.2
06/11/2008
1.3
04/03/2009
1.4
06/12/2009
1.5
12/29/2009
TABLE OF CONTENTS
1.
INTRODUCTION ................................................................................................................................................1
1.1
1.2
1.3
2.
PURPOSE .........................................................................................................................................................1
REFERENCES ...................................................................................................................................................1
ACRONYMS AND DEFINITIONS ........................................................................................................................1
2.3.3
2.3.4
2.3.5
2.3.6
3.
ii
3.7.3
Parameter Details..................................................................................................................................8
3.7.4
Return ....................................................................................................................................................8
3.8
EXAMPLE CONFIGURATIONS...........................................................................................................................8
4.
DATA INTERFACE.............................................................................................................................................9
4.1
INTRODUCTION ...............................................................................................................................................9
4.2
COMMON CONSTANTS AND STRUCTURES .......................................................................................................9
4.2.1
Data header type ...................................................................................................................................9
4.2.2
Data Constants ......................................................................................................................................9
4.3
FUNCTION CALLS ...........................................................................................................................................9
4.3.1
MAC_McpsDataReq ( ) .........................................................................................................................9
4.3.1.1
4.3.1.2
4.3.1.3
4.3.1.4
4.3.2
4.3.2.1
4.3.2.2
4.3.2.3
4.3.2.4
4.3.3
4.3.3.1
4.3.3.2
4.3.3.3
4.3.3.4
Description......................................................................................................................................................... 9
Prototype.......................................................................................................................................................... 10
Parameter Details ............................................................................................................................................. 10
Return .............................................................................................................................................................. 11
MAC_McpsPurgeReq ( )......................................................................................................................12
Description....................................................................................................................................................... 12
Prototype.......................................................................................................................................................... 12
Parameter Details ............................................................................................................................................. 12
Return .............................................................................................................................................................. 12
MAC_McpsDataAlloc ( ) .....................................................................................................................12
Description....................................................................................................................................................... 12
Prototype.......................................................................................................................................................... 12
Parameter Details ............................................................................................................................................. 12
Return .............................................................................................................................................................. 12
4.4
CALLBACK FUNCTION EVENTS .....................................................................................................................13
4.4.1
MAC_MCPS_DATA_IND....................................................................................................................13
4.4.1.1
4.4.1.2
4.4.2
4.4.2.1
4.4.2.2
4.4.3
4.4.3.1
4.4.3.2
5.
Description....................................................................................................................................................... 13
Parameter Details ............................................................................................................................................. 13
MAC_MCPS_DATA_CNF...................................................................................................................14
Description....................................................................................................................................................... 14
Parameter Details ............................................................................................................................................. 14
MAC_MCPS_PURGE_CNF................................................................................................................15
Description....................................................................................................................................................... 15
Parameter Details ............................................................................................................................................. 15
MANAGEMENT INTERFACE.........................................................................................................................16
5.1
INTRODUCTION .............................................................................................................................................16
5.2
COMMON CONSTANTS AND STRUCTURES .....................................................................................................16
5.2.1
Channel Masks ....................................................................................................................................16
5.2.2
Channels ..............................................................................................................................................16
5.2.3
Channel Page ......................................................................................................................................16
5.2.4
Capability Information ........................................................................................................................17
5.2.5
Get and Set Attributes..........................................................................................................................17
5.2.5.1
5.2.5.2
5.2.6
Disassociate Reason ............................................................................................................................19
5.2.7
Scan Type.............................................................................................................................................19
5.2.8
Special Address Values........................................................................................................................19
5.2.9
Superframe Specification.....................................................................................................................21
5.2.10 PAN Descriptor ...................................................................................................................................21
5.2.11 Pending Address Specification ............................................................................................................22
5.3
FUNCTION CALLS .........................................................................................................................................23
5.3.1
MAC_MlmeAssociateReq ( )................................................................................................................23
5.3.1.1
5.3.1.2
5.3.1.3
iii
Description....................................................................................................................................................... 23
Prototype.......................................................................................................................................................... 23
Parameter Details ............................................................................................................................................. 23
5.3.2
5.3.2.1
5.3.2.2
5.3.2.3
5.3.2.4
5.3.3
5.3.3.1
5.3.3.2
5.3.3.3
5.3.3.4
5.3.4
5.3.4.1
5.3.4.2
5.3.4.3
5.3.4.4
5.3.5
5.3.5.1
5.3.5.2
5.3.5.3
5.3.5.4
5.3.6
5.3.6.1
5.3.6.2
5.3.6.3
5.3.6.4
5.3.7
5.3.7.1
5.3.7.2
5.3.7.3
5.3.7.4
5.3.8
5.3.8.1
5.3.8.2
5.3.8.3
5.3.8.4
5.3.9
5.3.9.1
5.3.9.2
5.3.9.3
5.3.9.4
5.3.10
5.3.10.1
5.3.10.2
5.3.10.3
5.3.10.4
5.3.11
5.3.11.1
5.3.11.2
5.3.11.3
5.3.11.4
Return .............................................................................................................................................................. 23
MAC_MlmeAssociateRsp ( )................................................................................................................23
Description....................................................................................................................................................... 23
Prototype.......................................................................................................................................................... 23
Parameter Details ............................................................................................................................................. 23
Return .............................................................................................................................................................. 24
MAC_MlmeDisassociateReq ( )...........................................................................................................24
Description....................................................................................................................................................... 24
Prototype.......................................................................................................................................................... 24
Parameter Details ............................................................................................................................................. 24
Return .............................................................................................................................................................. 24
MAC_MlmeGetReq ( ) .........................................................................................................................25
Description....................................................................................................................................................... 25
Prototype.......................................................................................................................................................... 25
Parameter Details ............................................................................................................................................. 25
Return .............................................................................................................................................................. 25
MAC_MlmeOrphanRsp ( )...................................................................................................................25
Description....................................................................................................................................................... 25
Prototype.......................................................................................................................................................... 25
Parameter Details ............................................................................................................................................. 25
Return .............................................................................................................................................................. 25
MAC_MlmePollReq ( ) ........................................................................................................................26
Description....................................................................................................................................................... 26
Prototype.......................................................................................................................................................... 26
Parameter Details ............................................................................................................................................. 26
Return .............................................................................................................................................................. 26
MAC_MlmeResetReq ( ) ......................................................................................................................26
Description....................................................................................................................................................... 26
Prototype.......................................................................................................................................................... 26
Parameter Details ............................................................................................................................................. 26
Return .............................................................................................................................................................. 26
MAC_MlmeScanReq ( ) .......................................................................................................................27
Description....................................................................................................................................................... 27
Prototype.......................................................................................................................................................... 27
Parameter Details ............................................................................................................................................. 27
Return .............................................................................................................................................................. 28
MAC_MlmeSetReq ( ) ..........................................................................................................................28
Description....................................................................................................................................................... 28
Prototype.......................................................................................................................................................... 28
Parameter Details ............................................................................................................................................. 28
Return .............................................................................................................................................................. 28
MAC_MlmeStartReq ( ) .......................................................................................................................29
Description .................................................................................................................................................. 29
Prototype ..................................................................................................................................................... 29
Parameter Details......................................................................................................................................... 29
Return .......................................................................................................................................................... 30
MAC_MlmeSyncReq ( ) .......................................................................................................................31
Description .................................................................................................................................................. 31
Prototype ..................................................................................................................................................... 31
Parameter Details......................................................................................................................................... 31
Return .......................................................................................................................................................... 31
5.4
CALLBACK FUNCTION EVENTS .....................................................................................................................32
5.4.1
MAC_MLME_ASSOCIATE_IND ........................................................................................................32
5.4.1.1
5.4.1.2
5.4.2
5.4.2.1
5.4.2.2
5.4.3
iv
Description....................................................................................................................................................... 32
Parameter Details ............................................................................................................................................. 32
MAC_MLME_ASSOCIATE_CNF .......................................................................................................32
Description....................................................................................................................................................... 32
Parameter Details ............................................................................................................................................. 32
MAC_MLME_DISASSOCIATE_IND ..................................................................................................33
5.4.4
5.4.4.1
5.4.4.2
5.4.5
5.4.5.1
5.4.5.2
5.4.6
5.4.6.1
5.4.6.2
5.4.7
5.4.7.1
5.4.7.2
5.4.8
5.4.8.1
5.4.8.2
5.4.9
5.4.9.1
5.4.9.2
5.4.10
5.4.10.1
5.4.10.2
5.4.11
5.4.11.1
5.4.11.2
5.4.12
5.4.12.1
5.4.12.2
6.
Description....................................................................................................................................................... 33
Parameter Details ............................................................................................................................................. 33
MAC_MLME_DISASSOCIATE_CNF .................................................................................................33
Description....................................................................................................................................................... 33
Parameter Details ............................................................................................................................................. 33
MAC_MLME_BEACON_NOTIFY_IND .............................................................................................34
Description....................................................................................................................................................... 34
Parameter Details ............................................................................................................................................. 34
MAC_MLME_ORPHAN_IND .............................................................................................................34
Description....................................................................................................................................................... 34
Parameter Details ............................................................................................................................................. 34
MAC_MLME_SCAN_CNF ..................................................................................................................35
Description....................................................................................................................................................... 35
Parameter Details ............................................................................................................................................. 35
MAC_MLME_START_CNF ................................................................................................................36
Description....................................................................................................................................................... 36
Parameter Details ............................................................................................................................................. 36
MAC_MLME_SYNC_LOSS_IND ........................................................................................................36
Description....................................................................................................................................................... 36
Parameter Details ............................................................................................................................................. 36
MAC_MLME_POLL_CNF ..................................................................................................................37
Description .................................................................................................................................................. 37
Parameter Details......................................................................................................................................... 37
MAC_MLME_COMM_STATUS_IND.................................................................................................37
Description .................................................................................................................................................. 37
Parameter Details......................................................................................................................................... 37
MAC_MLME_POLL_IND...................................................................................................................38
Description .................................................................................................................................................. 38
Parameter Details......................................................................................................................................... 38
EXTENSION INTERFACE...............................................................................................................................39
6.1
INTRODUCTION .............................................................................................................................................39
6.2
COMMON CONSTANTS AND STRUCTURES .....................................................................................................39
6.2.1
Power Mode.........................................................................................................................................39
6.3
FUNCTION CALLS .........................................................................................................................................39
6.3.1
MAC_PwrOffReq ( ) ............................................................................................................................39
6.3.1.1
6.3.1.2
6.3.1.3
6.3.1.4
6.3.2
6.3.2.1
6.3.2.2
6.3.2.3
6.3.2.4
6.3.3
6.3.3.1
6.3.3.2
6.3.3.3
6.3.3.4
6.3.4
6.3.4.1
6.3.4.2
6.3.4.3
6.3.4.4
6.3.5
6.3.5.1
6.3.5.2
6.3.5.3
Description....................................................................................................................................................... 39
Prototype.......................................................................................................................................................... 39
Parameter Details ............................................................................................................................................. 39
Return .............................................................................................................................................................. 39
MAC_PwrOnReq ( ) ............................................................................................................................40
Description....................................................................................................................................................... 40
Prototype.......................................................................................................................................................... 40
Parameter Details ............................................................................................................................................. 40
Return .............................................................................................................................................................. 40
MAC_PwrMode ( ) ..............................................................................................................................40
Description....................................................................................................................................................... 40
Prototype.......................................................................................................................................................... 40
Parameter Details ............................................................................................................................................. 40
Return .............................................................................................................................................................. 40
MAC_PwrNextTimeout ( ) ...................................................................................................................40
Description....................................................................................................................................................... 40
Prototype.......................................................................................................................................................... 40
Parameter Details ............................................................................................................................................. 40
Return .............................................................................................................................................................. 40
MAC_RandomByte ( )..........................................................................................................................41
Description....................................................................................................................................................... 41
Prototype.......................................................................................................................................................... 41
Parameter Details ............................................................................................................................................. 41
6.3.6
6.3.6.1
6.3.6.2
6.3.6.3
6.3.6.4
6.3.7
6.3.7.1
6.3.7.2
6.3.7.3
6.3.7.4
6.3.8
6.3.8.1
6.3.8.2
6.3.8.3
6.3.8.4
6.3.9
6.3.9.1
6.3.9.2
6.3.9.3
6.3.9.4
6.3.10
6.3.10.1
6.3.10.2
6.3.10.3
6.3.10.4
Return .............................................................................................................................................................. 41
MAC_SrcMatchEnable ........................................................................................................................41
Description....................................................................................................................................................... 41
Prototype.......................................................................................................................................................... 41
Parameter Details ............................................................................................................................................. 41
Return .............................................................................................................................................................. 41
MAC_SrcMatchAddEntry ....................................................................................................................41
Description....................................................................................................................................................... 41
Prototype.......................................................................................................................................................... 41
Parameter Details ............................................................................................................................................. 41
Return .............................................................................................................................................................. 41
MAC_SrcMatchDeleteEntry ................................................................................................................42
Description....................................................................................................................................................... 42
Prototype.......................................................................................................................................................... 42
Parameter Details ............................................................................................................................................. 42
Return .............................................................................................................................................................. 42
MAC_SrcMatchAckAllPending ...........................................................................................................42
Description....................................................................................................................................................... 42
Prototype.......................................................................................................................................................... 42
Parameter Details ............................................................................................................................................. 42
Return .............................................................................................................................................................. 42
MAC_SrcMatchCheckAllPending .......................................................................................................42
Description .................................................................................................................................................. 42
Prototype ..................................................................................................................................................... 42
Parameter Details......................................................................................................................................... 43
Return .......................................................................................................................................................... 43
6.4
CALLBACK FUNCTION EVENTS .....................................................................................................................43
6.4.1
MAC_PWR_ON_CNF .........................................................................................................................43
6.4.1.1
7.
CALLBACK INTERFACE.................................................................................................................................44
7.1.1
7.1.1.1
7.1.1.2
7.1.1.3
7.1.1.4
7.1.2
7.1.2.1
7.1.2.2
7.1.2.3
7.1.2.4
8.
Description....................................................................................................................................................... 44
Prototype.......................................................................................................................................................... 44
Parameter Details ............................................................................................................................................. 44
Return .............................................................................................................................................................. 45
MAC_CbackCheckPending ( ).............................................................................................................45
Description....................................................................................................................................................... 45
Prototype.......................................................................................................................................................... 45
Parameter Details ............................................................................................................................................. 45
Return .............................................................................................................................................................. 45
CONFIGURATION CONSTANTS.......................................................................................................................46
COMPILE-TIME CONFIGURATION ..................................................................................................................46
SCENARIOS.......................................................................................................................................................47
9.1
9.2
9.3
9.4
9.5
9.6
vi
MAC_CbackEvent ( )...........................................................................................................................44
CONFIGURATION............................................................................................................................................46
8.1
8.2
9.
Description....................................................................................................................................................... 43
1. Introduction
1.1 Purpose
This document describes the application programming interface for the 802.15.4 MAC software. The API provides
an interface to the management and data services of the 802.15.4 stack.
1.2 References
1.
IEEE Std 802.15.4-2006, Part 15.4: Wireless Medium Access Control (MAC) and Physical Layer (PHY)
Specifications for Low-Rate Wireless Personal Area Networks (WPANs), September 8, 2006.
2.
AES
API
CAP
CBC-MAC
CCM
Coordinator
CSMA-CA
CTR
DSN
FFD
LNA
LQI
MAC
MCPS
MIC
MLME
MSDU
OSAL
PA
Power Amplifier.
PAN
PAN Coordinator
PHY
Physical layer.
PIB
RFD
RSSI
SFD
2. API Overview
2.1 Interface Mechanisms
The following interface mechanisms are used in the MAC API.
2.1.1 Message Passing Function Calls
These API functions provide a message passing interface to the MAC by sending an OSAL message to the MAC
event handler. Unless otherwise noted, the API functions described in this document are message passing functions.
These functions do not contain critical sections and do not directly access MAC data.
2.1.2 Direct Execute Function Calls
These API functions directly execute code that performs a MAC operation. The function executes in the context of
the caller. These functions may have critical sections and may directly access MAC data.
2.1.3 Callback Functions
These functions must be implemented by the application and are used to pass events and data from the MAC to the
application. Data accessed through callback function parameters (such as a pointer to data) are only valid for the
execution of the function and should not be considered valid when the function returns. These functions execute in
the context of the MAC. The callback function implementation should avoid using critical sections and CPU
intensive operations.
2.2 Zero Copy Data Interfaces
The interfaces for sending and receiving data between the MAC and the application are designed to not require a
data copy, i.e. they are zero copy. This results in a more CPU-efficient implementation. However the application
must follow certain rules on when to allocate and deallocate data buffers, as described in Section 4.
2.3 Common Constants and Structures
2.3.1 Address Type
The following data types and values are used for the MAC address:
typedef uint8 sAddrExt_t[8];
typedef struct
{
union
{
uint16
sAddrExt_t
} addr;
uint8
} sAddr_t;
shortAddr;
extAddr;
addrMode;
NAME
SADDR_MODE_NONE
DESCRIPTION
Address not present.
SADDR_MODE_SHORT
SADDR_MODE_EXT
2.3.2 Status
The following status values are used in various API functions and callback function events.
2.3.2.1 Standard Status Values
NAME
MAC_SUCCESS
MAC_AUTOACK_PENDING_ALL_ON
MAC_AUTOACK_PENDING_ALL_OFF
MAC_BEACON_LOSS
MAC_CHANNEL_ACCESS_FAILURE
MAC_COUNTER_ERROR
DESCRIPTION
Operation successful.
The AUTOPEND pending all is turned on.
The AUTOPEND pending all is turned off.
The beacon was lost following a synchronization request.
The operation or data request failed because of activity on the channel.
The frame counter purportedly applied by the originator of the received
frame is invalid.
MAC_DENIED
MAC_DISABLE_TRX_FAILURE
MAC_FRAME_TOO_LONG
MAC_IMPROPER_KEY_TYPE
The key purportedly applied by the originator of the received frame is not
allowed.
Unused.
The received frame or frame resulting from an operation or data request is
too long to be processed by the MAC.
MAC_IMPROPER_SECURITY_LEVEL The security level purportedly applied by the originator of the received
frame does not meet the minimum security level.
MAC_INVALID_ADDRESS
The data request failed because neither the source address nor destination
address parameters were present.
MAC_INVALID_GTS
MAC_INVALID_HANDLE
MAC_INVALID_INDEX
MAC_INVALID_PARAMETER
MAC_LIMIT_REACHED
Unused.
MAC_NO_ACK
MAC_NO_BEACON
The scan request failed because no beacons were received or the orphan
scan failed because no coordinator realignment was received.
MAC_NO_DATA
MAC_NO_SHORT_ADDRESS
MAC_ON_TIME_TOO_LONG
MAC_OUT_OF_CAP
MAC_PAN_ID_CONFLICT
MAC_PAST_TIME
MAC_READ_ONLY
MAC_REALIGNMENT
MAC_SCAN_IN_PROGRESS
MAC_SECURITY_ERROR
MAC_SUPERFRAME_OVERLAP
MAC_TRACKING_OFF
Unused.
Unused.
Unused.
A PAN identifier conflict has been detected and communicated to the
PAN coordinator.
A set request was issued with a read-only identifier.
A coordinator realignment command has been received.
The scan request failed because a scan is already in progress.
Cryptographic processing of the received secure frame failed.
The beacon start time overlapped the coordinator transmission time.
The start request failed because the device is not tracking the beacon of its
coordinator.
MAC_TRANSACTION_EXPIRED
MAC_TRANSACTION_OVERFLOW
MAC_TX_ACTIVE
MAC_UNAVAILABLE_KEY
MAC_UNSUPPORTED_ATTRIBUTE
MAC_UNSUPPORTED_LEGACY
The set or get request failed because the attribute is not supported.
MAC_UNSUPPORTED_SECURITY
Unused.
The operation or data request failed because the security key is not
available.
The received frame was secured with legacy security which is not
supported.
DESCRIPTION
The operation is not supported in the current configuration.
MAC_BAD_STATE
MAC_NO_RESOURCES
DESCRIPTION
No security is used.
MAC_SEC_LEVEL_MIC_32
MAC_SEC_LEVEL_MIC_64
MAC_SEC_LEVEL_MIC_128
MAC_SEC_LEVEL_ENC
MAC_SEC_LEVEL_ENC_MIC_32
MAC_SEC_LEVEL_ENC_MIC_64
DESCRIPTION
MAC_KEY_ID_MODE_IMPLICIT
MAC_KEY_ID_MODE_1
MAC_KEY_ID_MODE_4
MAC_KEY_ID_MODE_8
/*
/*
/*
/*
Key source */
Security level */
Key identifier mode */
Key index */
keySource This array identifies the originator of a key, as described in [1]. This parameter is ignored if
keyIdMode is MAC_KEY_ID_MODE_IMPLICIT or securityLevel is MAC_SEC_LEVEL_NONE.
securityLevel The security level. See 2.3.3. When set to MAC_SEC_LEVEL_NONE security is not used and all
other parameters are ignored.
keyIdMode The key ID mode. See 0. This parameter is ignored if keyIdMode is
MAC_KEY_ID_MODE_IMPLICIT or securityLevel is MAC_SEC_LEVEL_NONE.
keyIndex The key index, as described in [1]. This parameter is ignored if keyIdMode is
MAC_KEY_ID_MODE_IMPLICIT or securityLevel is MAC_SEC_LEVEL_NONE.
2.3.6 MAC Timing Values
The 802.15.4 specification describes timing values based on the symbol period of the physical layer. This document
adopts these same values as they relate to the MAC API. These values are shown in italic text in this document.
These values are described below with their timing values converted to millisecond or microsecond units for the 2.4
GHz physical layer, which uses a 16 microsecond symbol period.
NAME
DESCRIPTION
SYMBOLS
aBaseSuperframeDuration
aUnitBackoffPeriod
960
2.4 GHz
TIMING
15.36 ms
320 us
3. Initialization Interface
3.1 Introduction
The initialization interface is used to configure the MAC for support of certain optional features. Additional
features are enabled by using the following API functions. All functions in the initialization interface are direct
execute functions.
3.2 MAC_Init ( )
3.2.1 Description
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.
3.2.2 Prototype
void MAC_Init(void)
3.4 MAC_InitCoord ( )
3.4.1 Description
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.
3.4.2 Prototype
void MAC_InitCoord(void)
3.7 MAC_InitBeaconDevice ( )
3.7.1 Description
This function initializes the MAC to allow it to associate with and track a beacon-enabled network. If this function
is used it must be called during application initialization before any other function in the data or management API is
called.
3.7.2 Prototype
void MAC_InitBeaconDevice(void)
4. Data Interface
4.1 Introduction
This API provides interfaces to send and receive data between the MAC and the application.
4.2 Common Constants and Structures
4.2.1 Data header type
The following data type is used by the data interface to facilitate the zero copy mechanism.
typedef struct
{
uint8
*p;
uint8
len;
} sData_t;
p Pointer to data.
len Length of data in bytes.
4.2.2 Data Constants
The following constants are used to set up data buffers for MAC_McpsDataReq().
NAME
MAC_MAX_FRAME_SIZE
VALUE
DESCRIPTION
102
MAC_DATA_OFFSET
24
MAC_ENC_OFFSET
MAC_MIC_32_LEN
MAC_MIC_64_LEN
MAC_MIC_128_LEN
16
p len
sData_t
data
macMcpsDataReq_t
Figure 1.
As shown in the figure, the application must allocate a certain number of bytes before msdu.p to contain the MAC
header. This number is MAC_DATA_OFFSET plus MAC_ENC_OFFSET if an encryption security suite is used.
Function MAC_McpsDataAlloc()can be used to simplify allocation and preparation of the data buffer. This
function allocates a buffer of the correct size to contain the parameters, MAC header, and application data and
prepares it as described in Figure 1.
The maximum data frame length is MAC_MAX_FRAME_SIZE bytes. This is reduced by MAC_ENC_OFFSET if
encryption is used. If authentication is used, the data frame length is additionally reduced by the length of the
authentication data, as shown in Section 4.2.2. For example, if AES-MIC-128 is used the maximum length is:
max = MAC_MAX_FRAME_SIZE - MAC_ENC_OFFSET MAC_MIC_128_LEN;
4.3.1.2 Prototype
void MAC_McpsDataReq(macMcpsDataReq_t *pData)
10
DESCRIPTION
Acknowledged transmission. The MAC will attempt to
retransmit the frame until it is acknowledged.
MAC_TXOPTION_GTS
MAC_TXOPTION_INDIRECT
Indirect transmission. The MAC will queue the data and wait
for the destination device to poll for it. This can only be used
by a coordinator.
MAC_TXOPTION_NO_RETRANS
MAC_TXOPTION_NO_CNF
MAC_TXOPTION_ALT_BE
MAC_TXOPTION_PWR_CHAN
mac.channel Transmit the data frame on this channel. This value is ignored if MAC_TXOPTION_PWR_CHAN is
not used.
mac.power Transmit the data frame at this power level. This value is ignored if MAC_TXOPTION_PWR_CHAN is
not used.
4.3.1.4 Return
None.
11
4.3.2 MAC_McpsPurgeReq ( )
4.3.2.1 Description
This function purges and discards a data request from the MAC data queue. When the operation is complete the
MAC sends a MAC_MCPS_PURGE_CNF.
4.3.2.2 Prototype
void MAC_McpsPurgeReq(uint8 msduHandle)
12
13
mac.mpduLinkQuality The link quality of the received data frame. The value is based on the energy detect
calculation, with values ranging linearly from 0x00 to 0xFF with the higher value indicating higher link quality.
mac.correlation The raw correlation value of the received data frame. This value depends on the radio. See the
chip data sheet for details.
mac.rssi The received RF power in units of dBm.
dsn The data sequence number of the received frame.
4.4.2 MAC_MCPS_DATA_CNF
4.4.2.1 Description
This event is sent to the application every time MAC_McpsDataReq()is called. The event returns the status of
the data request. The event also passes back a pointer to the data buffer. The application can use this pointer to
deallocate the buffer.
4.4.2.2 Parameter Details
Parameters are passed in the following structure:
typedef struct
{
macEventHdr_t
hdr;
uint8
msduHandle;
macMcpsDataReq_t
*pDataReq;
uint32
timestamp;
uint16
timestamp2;
} macMcpsDataCnf_t;
hdr.status The status of the data request operation, as follows:
NAME
DESCRIPTION
MAC_SUCCESS
Operation successful.
MAC_CHANNEL_ACCESS_FAILURE
MAC_FRAME_TOO_LONG
MAC_INVALID_PARAMETER
MAC_NO_ACK
MAC_TRANSACTION_EXPIRED
Indirect data transmission failed because the peer device did not
respond before the transaction expired or was purged.
MAC_TRANSACTION_OVERFLOW
14
4.4.3 MAC_MCPS_PURGE_CNF
4.4.3.1 Description
This event is sent to the application when MAC_McpsPurgeReq() is called. The event returns the status of the
purge request.
4.4.3.2 Parameter Details
Parameters are passed in the following structure.
typedef struct
{
macEventHdr_t
hdr;
uint8
msduHandle;
} macMcpsPurgeCnf_t;
hdr.status The status of the purge request, as follows:
NAME
MAC_SUCCESS
DESCRIPTION
Operation successful.
MAC_INVALID_HANDLE
pDataReq Pointer to the data request buffer for this purge confirm.
msduHandle Application-defined handle value associated with the data request.
15
5. Management Interface
5.1 Introduction
The following interfaces are used for 802.15.4 network management.
5.2 Common Constants and Structures
5.2.1 Channel Masks
The following mask values are used in combination to indicate a set of channels. For example, to use channels 11,
12, and 23 do:
uint32 chan = MAC_CHAN_11_MASK | MAC_CHAN_12_MASK | MAC_CHAN_23_MASK;
NAME
MAC_CHAN_11_MASK MAC_CHAN_28_MASK
DESCRIPTION
Channel 11 through 28 mask.
Channels 27 and 28 are not defined by [1]. These channels may be outside the 2.4 GHz ISM band in some
countries.
5.2.2 Channels
These values indicate a particular logical channel.
NAME
MAC_CHAN_11 MAC_CHAN_28
DESCRIPTION
Channel 11 through 28.
Channels 27 and 28 are not defined by [1]. These channels may be outside the 2.4 GHz ISM band in some
countries.
5.2.3 Channel Page
These values indicate the channel page.
Note: Only channel page 0 in the 2.4 GHz band is supported.
NAME
MAC_CHANNEL_PAGE_0
MAC_CHANNEL_PAGE_1
MAC_CHANNEL_PAGE_2
16
DESCRIPTION
2.4 GHz band using O-QPSK.
868 and 915 MHz bands using ASK.
868 and 915 MHz bands using O-QPSK.
DESCRIPTION
MAC_CAPABLE_FFD
Device is an FFD.
MAC_CAPABLE_MAINS_POWER
MAC_CAPABLE_RX_ON_IDLE
MAC_CAPABLE_SECURITY
MAC_CAPABLE_ALLOC_ADDR
TYPE
RANGE R
DESCRIPTION
MAC_ACK_WAIT_DURATION
uint8
54
MAC_ASSOCIATION_PERMIT
bool
TRUE,
FALSE
MAC_ASSOCIATED_PAN_COORD
bool
TRUE,
FALSE
MAC_AUTO_REQUEST
bool
TRUE,
FALSE
MAC_BATT_LIFE_EXT
bool
TRUE,
FALSE
MAC_BATT_LIFE_EXT_PERIODS
uint8
MAC_BEACON_PAYLOAD
uint8 *
pointer
MAC_BEACON_PAYLOAD_LENGTH
uint8
0-52
MAC_BEACON_ORDER
uint8
0-15
MAC_BEACON_TX_TIME
uint32
0x000000
0xffffff
MAC_BSN
uint8
0x00
0xff
MAC_COORD_EXTENDED_ADDRESS
sAddrExt_t
64-bit
address
MAC_COORD_SHORT_ADDRESS
uint16
0x0000
0xffff
17
associated. A value of
MAC_ADDR_USE_EXT indicates that
the coordinator is using its extended
address.
MAC_DSN
uint8
0x00
0xff
MAC_GTS_PERMIT
bool
TRUE,
FALSE
MAC_MAX_BE
uint8
3-8, 5
MAC_MAX_CSMA_BACKOFFS
uint8
0-5, 4
MAC_MAX_FRAME_TOTAL_WAIT_TIME
uint16
14325776,
1220
MAC_MAX_FRAME_RETRIES
uint8
0-7, 3
MAC_MIN_BE
uint8
0-8, 3
MAC_PAN_ID
uint16
0x0000
0xffff
MAC_PROMISCUOUS_MODE
bool
TRUE,
FALSE
MAC_RESPONSE_WAIT_TIME
uint8
2-64, 32
MAC_RX_ON_WHEN_IDLE
bool
TRUE,
FALSE
MAC_SECURITY_ENABLED
bool
TRUE,
FALSE
MAC_SHORT_ADDRESS
uint16
0x0000
0xffff
MAC_SUPERFRAME_ORDER
uint8
0-15
MAC_SYNC_SYMBOL_OFFSET
uint8
MAC_TIMESTAMP_SUPPORTED
bool
TRUE,
FALSE
MAC_TRANSACTION_PERSISTENCE
_TIME
uint16
0x0000
0xffff,
0x01f4
18
TYPE
uint8
MAC_PHY_TRANSMIT_POWER_SIGNED
RANGE
DESCRIPTION
0-25
0-11
(CC2590
PA/LNA)
0-19
(CC2591
PA/LNA)
int8
-25-0-19
0-11
(CC2590
PA/LNA)
0-19
(CC2591
PA/LNA)
MAC_LOGICAL_CHANNEL
uint8
11-26
MAC_EXTENDED_ADDRESS
sAddrExt_t
64-bit
address
MAC_ALT_BE
uint8
0-8, 1
MAC_DEVICE_BEACON_ORDER
uint8
0-15, 15
DESCRIPTION
MAC_DISASSOC_DEVICE
DESCRIPTION
Energy detect scan. The device will tune to each channel and perform
and energy measurement. The list of channels and their associated
measurements will be returned at the end of the scan.
MAC_SCAN_ACTIVE
Active scan. The device tunes to each channel, sends a beacon request
and listens for beacons. The PAN descriptors are returned at the end of
the scan.
MAC_SCAN_PASSIVE
Passive scan. The device tunes to each channel and listens for beacons.
The PAN descriptors are returned at the end of the scan.
MAC_SCAN_ORPHAN
Orphan scan. The device tunes to each channel and sends an orphan
notification to try and find its coordinator. The status is returned at the
end of the scan.
19
DESCRIPTION
Short address value indicating extended address is used.
20
4-7
Superframe
order
8-11
Final CAP
slot
12
Battery life
extension
13
Reserved
14
15
PAN
coordinator
Association
permit
The following macros are provided to help parse the superframe specification:
MAC_SFS_BEACON_ORDER(s) returns the beacon order.
MAC_SFS_SUPERFRAME_ORDER(s) returns the superframe order.
MAC_SFS_FINAL_CAP_SLOT(s) returns the final CAP slot.
MAC_SFS_BLE(s) returns the battery life extension bit.
MAC_SFS_PAN_COORDINATOR(s) returns the PAN coordinator bit.
MAC_SFS_ASSOCIATION_PERMIT(s) returns the association permit bit.
5.2.10 PAN Descriptor
The PAN descriptor contains information about a network as received in a beacon frame. The PAN descriptor uses
the following structure.
typedef struct
{
sAddr_t
uint16
uint16
uint8
uint8
bool
uint8
uint32
bool
macSec_t
} macPanDesc_t;
coordAddress;
coordPanId;
superframeSpec;
logicalChannel;
channelPage;
gtsPermit;
linkQuality;
timestamp;
securityFailure;
sec;
21
3
Reserved
4-6
Number of extended
addresses pending
7
Reserved
The following macros are provided the parse the pending address specification:
MAC_PEND_NUM_SHORT(pendAddrSpec) returns the number of short addresses.
MAC_PEND_NUM_EXT(pendAddrSpec) returns the number of extended addresses.
MAC_PEND_FIELDS_LEN(pendAddrSpec) returns the length in bytes of the pending address fields in the
beacon.
22
logicalChannel;
channelPage;
coordAddress;
coordPanId;
capabilityInformation;
sec;
} macMlmeAssociateReq_t;
logicalChannel The channel on which to attempt association. See Section 5.2.2.
channelPage The channel page on which to attempt association. See Section 5.2.3.
coordAddress Address of the coordinator with which to associate. See Section 2.3.1.
coordPanId The identifier of the PAN with which to associate.
capabilityInformation The operational capabilities of this device. See Section 5.2.3.
sec The security parameters for this message. See 2.3.5.
5.3.1.4 Return
None.
5.3.2 MAC_MlmeAssociateRsp ( )
5.3.2.1 Description
This function sends an associate response to a device requesting to associate. This function must be called after
receiving a MAC_MLME_ASSOCIATE_IND. When the associate response is complete the MAC sends a
MAC_MLME_COMM_STATUS_IND to the application to indicate the success or failure of the operation.
5.3.2.2 Prototype
uint8 MAC_MlmeAssociateRsp(macMlmeAssociateRsp_t *pData)
23
typedef struct
{
sAddrExt_t
deviceAddress;
uint16
assocShortAddress;
uint8
status;
macSec_t
sec;
} macMlmeAssociateRsp_t;
deviceAddress The address of the device requesting association.
assocShortAddress The short address allocated to the device. This value is only set if association is successful
and the device requested a short address.
status The status of the association attempt. See Section 2.3.2.
sec Security parameters. See 2.3.5.
5.3.2.4 Return
The status of the request, as follows:
NAME
MAC_SUCCESS
DESCRIPTION
Operation successful.
MAC_NO_RESOURCES
5.3.3 MAC_MlmeDisassociateReq ( )
5.3.3.1 Description
This function is used by an associated device to notify the coordinator of its intent to leave the PAN. It is also used
by the coordinator to instruct an associated device to leave the PAN. When the disassociate procedure is complete
the MAC sends a MAC_MLME_DISASSOCIATE_CNF to the application.
5.3.3.2 Prototype
void MAC_MlmeDisassociateReq(macMlmeDisassociateReq_t *pData)
24
5.3.4 MAC_MlmeGetReq ( )
5.3.4.1 Description
This direct execute function retrieves an attribute value from the MAC PIB.
5.3.4.2 Prototype
uint8 MAC_MlmeGetReq(uint8 pibAttribute, void *pValue)
DESCRIPTION
Operation successful.
MAC_UNSUPPORTED_ATTRIBUTE
5.3.5 MAC_MlmeOrphanRsp ( )
5.3.5.1 Description
This function is called in response to an orphan notification from a peer device. This function must be called after
receiving a MAC_MLME_ORPHAN_IND. When the orphan response is complete the MAC sends a
MAC_MLME_COMM_STATUS_IND to the application to indicate the success or failure of the operation.
5.3.5.2 Prototype
void MAC_MlmeOrphanRsp(macMlmeOrphanRsp_t *pData)
5.3.5.3 Parameter Details
Parameters are passed using the following structure:
typedef struct
{
sAddrExt_t
orphanAddress;
uint16
shortAddress;
bool
associatedMember;
macSec_t
sec;
} macMlmeOrphanRsp_t;
orphanAddress The extended address of the device sending the orphan notification.
shortAddress The short address of the orphaned device. This value is only used if associatedMember is
TRUE. The value MAC_ADDR_USE_EXT indicates the extended address is used instead of the short address.
associatedMember Set to TRUE if the orphaned device is associated with this coordinator.
sec The security parameters for this message. See 2.3.5.
5.3.5.4 Return
None.
25
5.3.6 MAC_MlmePollReq ( )
5.3.6.1 Description
This function is used to request pending data from the coordinator. When the poll request is complete the MAC
sends a MAC_MLME_POLL_CNF to the application. If a data frame of nonzero length is received from the
coordinator the MAC sends a MAC_MLME_POLL_CNF with status MAC_SUCCESS and then sends a
MAC_MCPS_DATA_IND with the data.
5.3.6.2 Prototype
void MAC_MlmePollReq(macMlmePollReq_t *pData)
26
5.3.8 MAC_MlmeScanReq ( )
5.3.8.1 Description
This function initiates an energy detect, active, passive, or orphan scan on one or more channels. An energy detect
scan measures the peak energy on each requested channel. An active scan sends a beacon request on each channel
and then listening for beacons. A passive scan is a receive-only operation that listens for beacons on each channel.
An orphan scan is used to locate the coordinator with which the scanning device had previously associated. When a
scan operation is complete the MAC sends a MAC_MLME_SCAN_CNF to the application.
For active or passive scans the application sets the maxResults parameter the maximum number of PAN
descriptors to return. If maxResults is greater than zero then the application must also set
result.panDescriptor to point to a buffer of size maxResults * sizeof(macPanDesc_t) to store
the results of the scan. The application must not access or deallocate this buffer until it receives a
MAC_MLME_SCAN_CNF. The MAC will store up to maxResults PAN descriptors and ignore duplicate beacons.
An alternative way to get results for an active or passive scan is to set maxResults to zero or set PIB attribute
MAC_AUTO_REQUEST to FALSE. Then the MAC will not store results but rather send a
MAC_MLME_BEACON_NOTIFY_IND for each beacon received. The application will not need to supply any
memory to store the scan results but the MAC will not filter out duplicate beacons.
For energy detect scans the application must set result.energyDetect to point to a buffer of size 18 bytes to
store the results of the scan. The application must not access or deallocate this buffer until is receives a
MAC_MLME_SCAN_CNF.
An energy detect, active or passive scan may be performed at any time if a scan is not already in progress. However
a device cannot perform any other MAC management operation or send or receive MAC data until the scan is
complete.
5.3.8.2 Prototype
void MAC_MlmeScanReq(macMlmeScanReq_t *pData)
27
channelPage The channel page on which to perform the scan. See Section 5.2.3.
maxResults The maximum number of PAN descriptor results to return for an active or passive scan. This
parameter is ignored for energy detect and orphan scans.
sec The security parameters for orphan scan. See 2.3.5.
result.pEnergyDetect Pointer to a buffer to store energy detect measurements. This value is only used for energy
detect scans.
result.pPanDescriptor Pointer to a buffer to store PAN descriptors. This value is only used for active and
passive scans.
5.3.8.4 Return
None.
5.3.9 MAC_MlmeSetReq ( )
This direct execute function sets an attribute value in the MAC PIB.
5.3.9.1 Description
5.3.9.2 Prototype
uint8 MAC_MlmeSetReq(uint8 pibAttribute, void *pValue)
28
NAME
MAC_SUCCESS
DESCRIPTION
Operation successful.
MAC_UNSUPPORTED_ATTRIBUTE
MAC_INVALID_PARAMETER
MAC_READ_ONLY
Attribute is read-only.
5.3.10 MAC_MlmeStartReq ( )
5.3.10.1 Description
This function is called by a coordinator or PAN coordinator to start or reconfigure a network. Before starting a
network the device must have set its short address. A PAN coordinator sets the short address by setting the attribute
MAC_SHORT_ADDRESS. A coordinator sets the short address through association.
When parameter panCoordinator is TRUE, the MAC automatically sets attributes MAC_PAN_ID and
MAC_LOGICAL_CHANNEL to the panId and logicalChannel parameters. If panCoordinator is FALSE,
these parameters are ignored (they would already be set through association).
The parameter beaconOrder controls whether the network is beacon-enabled or non beacon-enabled. For a
beacon-enabled network this parameter also controls the beacon transmission interval.
When the operation is complete the MAC sends a MAC_MLME_START_CNF to the application.
5.3.10.2 Prototype
void MAC_MlmeStartReq(macMlmeStartReq_t *pData)
29
beaconOrder. It can also be set to 15 to configure a network that sends a beacon but has no CAP. For a non
beacon-enabled network this value is ignored.
panCoordinator Set to TRUE to start a network as PAN coordinator.
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. This parameter is ignored for non
beacon-enabled networks.
coordRealignment Set to TRUE to transmit a coordinator realignment prior to changing the superframe
configuration.
realignSec Security parameters for the coordinator realignment frame. See 2.3.5. This parameter is ignored if
coordRealignment is FALSE.
beaconSec Security parameters for the beacon frame. See 2.3.5.
5.3.10.4 Return
None.
30
5.3.11 MAC_MlmeSyncReq ( )
5.3.11.1 Description
This function requests the MAC to synchronize with the coordinator by acquiring and optionally tracking its
beacons. Synchronizing with the coordinator is recommended before associating in a beacon-enabled network. If
the beacon could not be located on its initial search or during tracking, the MAC sends a
MAC_MLME_SYNC_LOSS_IND to the application with status MAC_BEACON_LOSS.
Before calling this function the application must set PIB attributes MAC_BEACON_ORDER, MAC_PAN_ID and
either MAC_COORD_SHORT_ADDRESS or MAC_COORD_EXTENDED_ADDRESS to the address of the coordinator
with which to synchronize.
The application may wish to set PIB attribute MAC_AUTO_REQUEST to FALSE before calling this function. Then
when the MAC successfully synchronizes with the coordinator it will send the application a
MAC_MLME_BEACON_NOTIFY_IND. After receiving the event the application may set MAC_AUTO_REQUEST to
TRUE to stop receiving beacon notifications.
This function is only applicable to beacon-enabled networks.
5.3.11.2 Prototype
void MAC_MlmeSyncReq(macMlmeSyncReq_t *pData)
31
32
NAME
MAC_CHANNEL_ACCESS_FAILURE
DESCRIPTION
Data transmission failed because of congestion on the channel.
MAC_INVALID_PARAMETER
MAC_NO_ACK
MAC_NO_DATA
DESCRIPTION
Operation successful.
MAC_CHANNEL_ACCESS_FAILURE
MAC_INVALID_PARAMETER
MAC_NO_ACK
MAC_TRANSACTION_EXPIRED
Transmission failed because the peer device did not respond before
the transaction expired.
MAC_TRANSACTION_OVERFLOW
deviceAddress The address of the device that has either requested disassociation or been instructed to
disassociate by its coordinator.
panId The PAN ID of the device that has either requested disassociation or been instructed to disassociate by its
coordinator.
33
5.4.5 MAC_MLME_BEACON_NOTIFY_IND
5.4.5.1 Description
This event is sent to the application when the MAC receives a beacon frame and the beacon contains payload data
or attribute MAC_AUTO_REQUEST is set to FALSE. The event also contains an LQI measurement and the time the
beacon was received in addition to the beacon information.
5.4.5.2 Parameter Details
Parameters are passed in the following structure:
typedef struct
{
macEventHdr_t hdr;
uint8
bsn;
macPanDesc_t
*pPanDesc;
uint8
pendAddrSpec;
uint8
*pAddrList;
uint8
sduLength;
uint8
*pSdu;
} macMlmeBeaconNotifyInd_t;
bsn The beacon sequence number.
pPanDesc The PAN descriptor for the received beacon. See Section 5.2.10.
pendAddrSpec The beacon pending address specification. See Section 5.2.11.
pAddrList The list of device addresses for which the sender of the beacon has data. The length of the list can be
determined with macro MAC_PEND_FIELDS_LEN(), see Section 5.2.11.
sduLength The number of bytes in the beacon payload of the beacon frame.
pSdu The beacon payload.
5.4.6 MAC_MLME_ORPHAN_IND
5.4.6.1 Description
This event is sent to the application when the MAC receives an orphan notification from another device. The
application must call MAC_MlmeOrphanRsp() after receiving this event. This event will only be sent to FFD
applications.
5.4.6.2 Parameter Details
Parameters are passed using the following structure:
typedef struct
{
macEventHdr_t
hdr;
sAddrExt_t
orphanAddress;
macSec_t
sec;
} macMlmeOrphanInd_t;
orphanAddress The address of the orphaned device.
sec Security parameters for this message. See 2.3.5.
34
5.4.7 MAC_MLME_SCAN_CNF
5.4.7.1 Description
This event is sent to the application in response to a MAC_MlmeScanReq() when the scan operation is complete.
The event indicates the status of the scan. For an energy detect scan a list of energy measurements is returned. For
an active or passive scan a list of PAN descriptors is returned.
5.4.7.2 Parameter Details
Parameters are passed using the following structure:
typedef struct
{
macEventHdr_t
hdr;
uint8
scanType;
uint8
channelPage;
uint32
unscannedChannels;
uint8
resultListSize;
union
{
uint8
*pEnergyDetect;
macPanDesc_t *pPanDescriptor;
} result;
} macMlmeScanCnf_t;
hdr.status The status of the scan request, as follows:
NAME
MAC_SUCCESS
DESCRIPTION
Operation successful.
MAC_INVALID_PARAMETER
MAC_NO_BEACON
35
5.4.8 MAC_MLME_START_CNF
5.4.8.1 Description
This event is sent to the application in response to a MAC_MlmeStartReq(). The event indicates the status of
the start request.
5.4.8.2 Parameter Details
Parameters are passed using the following structure:
typedef struct
{
macEventHdr_t
hdr;
} macMlmeStartCnf_t;
hdr.status The status of start request, as follows:
NAME
DESCRIPTION
MAC_SUCCESS
Operation successful.
MAC_INVALID_PARAMETER
MAC_NO_SHORT_ADDRESS
MAC_SUPERFRAME_OVERLAP
5.4.9 MAC_MLME_SYNC_LOSS_IND
5.4.9.1 Description
This event is sent to the application when the MAC loses synchronization with the coordinator or has a PAN ID
conflict. The status indicates the reason for the event.
5.4.9.2 Parameter Details
Parameters are passed using the following structure:
typedef struct
{
macEventHdr_t
hdr;
uint16
panId;
uint8
logicalChannel;
uint8
channelPage;
macSec_t
sec;
} macMlmeSyncLossInd_t;
hdr.status The reason that synchronization was lost, as follows:
NAME
MAC_BEACON_LOSS
MAC_PAN_ID_CONFLICT
MAC_REALIGNMENT
DESCRIPTION
The beacon was lost following a synchronization request.
A PAN identifier conflict has been detected.
A coordinator realignment command has been received.
36
5.4.10 MAC_MLME_POLL_CNF
5.4.10.1 Description
This event is sent to the application in response to a MAC_MlmePollReq(). If the poll request was successful
and data was received the status is set to MAC_SUCESS. If the poll request was successful and no data was received
the status is set to MAC_NO_DATA. Other status values indicate failure as described below.
5.4.10.2 Parameter Details
Parameters are passed using the following structure:
typedef struct
{
macEventHdr_t
hdr;
} macMlmePollCnf_t;
hdr.status The status of the poll request, as follows:
NAME
MAC_SUCCESS
DESCRIPTION
Operation successful.
MAC_CHANNEL_ACCESS_FAILURE
MAC_INVALID_PARAMETER
MAC_NO_ACK
MAC_NO_DATA
5.4.11 MAC_MLME_COMM_STATUS_IND
5.4.11.1 Description
This event is sent to the application for various reasons. It indicates the status of a MAC_MlmeAssociateRsp()
or MAC_MlmeOrphanRsp(). It also indicates the MAC has received a secure frame that generated an error
during security processing.
5.4.11.2 Parameter Details
Parameters are passed using the following structure:
typedef struct
{
macEventHdr_t
hdr;
sAddr_t
srcAddr;
sAddr_t
dstAddr;
uint16
panId;
uint8
reason;
macSec_t
sec;
} macMlmeCommStatusInd_t;
hdr.status The status for this event, as follows:
NAME
MAC_CHANNEL_ACCESS_FAILURE
37
DESCRIPTION
The response frame failed because of activity on the channel.
MAC_FRAME_TOO_LONG
MAC_INVALID_PARAMETER
MAC_NO_ACK
MAC_TRANSACTION_EXPIRED
The response frame failed because the peer device did not respond
before the transaction expired or was purged.
MAC_TRANSACTION_OVERFLOW
The response frame failed because MAC data buffers are full.
DESCRIPTION
Event sent in response to MAC_AssociateRsp().
MAC_COMM_ORPHAN_RSP
MAC_COMM_RX_SECURE
38
6. Extension Interface
6.1 Introduction
The extension interface provides an API for additional software features that are not defined by the 802.15.4
specification, such as power management.
6.2 Common Constants and Structures
6.2.1 Power Mode
The following values indicate the power mode of the MAC. The difference between lite and deep sleep modes
is dependent on the hardware being used. In general, the wakeup time for deep sleep is longer than lite sleep. See
the chip data sheet for details.
NAME
DESCRIPTION
MAC_PWR_ON
MAC_PWR_SLEEP_LITE
MAC_PWR_SLEEP_DEEP
39
NAME
MAC_SUCCESS
DESCRIPTION
Operation successful; the MAC is powered off.
MAC_DENIED
6.3.2 MAC_PwrOnReq ( )
6.3.2.1 Description
This function requests the MAC to power on the radio hardware and wake up. The function powers on the radio
hardware, blocking until completion.
6.3.2.2 Prototype
void MAC_PwrOnReq(void)
6.3.2.3 Parameter Details
None.
6.3.2.4 Return
None.
6.3.3 MAC_PwrMode ( )
6.3.3.1 Description
This function returns the current power mode of the MAC.
6.3.3.2 Prototype
uint8 MAC_PwrMode(void)
6.3.3.3 Parameter Details
None.
6.3.3.4 Return
NAME
DESCRIPTION
MAC_PWR_ON
MAC_PWR_SLEEP_LITE
MAC_PWR_SLEEP_DEEP
6.3.4 MAC_PwrNextTimeout ( )
6.3.4.1 Description
This function returns the next MAC timer expiration in aUnitBackoffPeriod units. If no timer is running it returns
zero.
6.3.4.2 Prototype
uint32 MAC_PwrNextTimeout(void)
6.3.4.3 Parameter Details
None.
6.3.4.4 Return
The next MAC timer expiration in aUnitBackoffPeriod units or zero if no timer is running.
40
6.3.5 MAC_RandomByte ( )
6.3.5.1 Description
This function returns a random byte from the MAC random number generator.
6.3.5.2 Prototype
uint8 MAC_RandomByte(void)
6.3.5.3 Parameter Details
None.
6.3.5.4 Return
A random byte.
6.3.6 MAC_SrcMatchEnable
6.3.6.1 Description
This function enables/disables Autopend and source address matching.
6.3.6.2 Prototype
uint8 MAC_SrcMatchEnable ( uint8 addrType, uint8 num
DESCRIPTION
Operation successful
MAC_INVALID_PARAMETER
Invalid parameter
6.3.7 MAC_SrcMatchAddEntry
6.3.7.1 Description
This function adds a short or extended address to source address table which can be used to configure the frame
pending subfield of the acknowledgment frame.
6.3.7.2 Prototype
uint8 MAC_SrcMatchAddEntry ( sAddr_t *addr, uint16 panID )
6.3.7.3 Parameter Details
addr A pointer to sAddr_t which contains addrMode and a union of a short 16-bit MAC address or an extended
64-bit MAC address to be added to the source address table.
panID Device PAN ID. It is only used when the addr is using short address.
6.3.7.4 Return
NAME
MAC_SUCCESS
41
DESCRIPTION
Operation successful
MAC_NO_RESOURCES
MAC_DUPLICATED_ENTRY
MAC_INVALID_PARAMETER
Invalid parameter
6.3.8 MAC_SrcMatchDeleteEntry
6.3.8.1 Description
This function deletes a short or extended address from source address table which can be used to configure the
frame pending subfield of the acknowledgment frame.
6.3.8.2 Prototype
uint8 MAC_SrcMatchDeleteEntry ( sAddr_t *addr, uint16 panID )
6.3.8.3 Parameter Details
addr A pointer to sAddr_t which contains addrMode and a union of a short 16-bit MAC address or an extended
64-bit MAC address to be added to the source address table.
panID Device PAN ID. It is only used when the addr is using short address.
6.3.8.4 Return
NAME
MAC_SUCCESS
MAC_INVALID_PARAMETER
DESCRIPTION
Operation successful.
Address to be deleted cannot be found in the source address
table
6.3.9 MAC_SrcMatchAckAllPending
6.3.9.1 Description
This function enables/disables acknowledging all packets with pending bit set. The application normally enables it
when adding new entries to the source address table fails due to the table is full, or disables it when more entries are
deleted and the table has empty slots.
6.3.9.2 Prototype
void MAC_SrcMatchAckAllPending ( uint8 option
6.3.10 MAC_SrcMatchCheckAllPending
6.3.10.1 Description
This function checks if acknowledging all packets with pending bit set is enabled.
6.3.10.2 Prototype
uint8 MAC_SrcMatchCheckAllPending ( void )
42
DESCRIPTION
Pending all is enabled
43
7. Callback Interface
7.1.1 MAC_CbackEvent ( )
7.1.1.1 Description
This callback function sends MAC events to the application.
The application must implement this function. A typical implementation of this function would allocate an OSAL
message, copy the event parameters to the message, and send the message to the applications OSAL event handler.
This function may be executed from task or interrupt context and therefore must be reentrant.
7.1.1.2 Prototype
void MAC_CbackEvent(macCbackEvent_t *pData)
44
hdr;
associateInd;
associateCnf;
disassociateInd;
disassociateCnf;
beaconNotifyInd;
orphanInd;
scanCnf;
startCnf;
syncLossInd;
pollCnf;
commStatusInd;
pollInd;
dataCnf;
dataInd;
purgeCnf;
DESCRIPTION
Associate indication.
MAC_MLME_ASSOCIATE_CNF
Associate confirm.
MAC_MLME_DISASSOCIATE_IND
Disassociate indication.
MAC_MLME_DISASSOCIATE_CNF
Disassociate confirm.
MAC_MLME_BEACON_NOTIFY_IND
MAC_MLME_ORPHAN_IND
Orphan indication.
MAC_MLME_SCAN_CNF
Scan confirm.
MAC_MLME_START_CNF
Start confirm.
MAC_MLME_SYNC_LOSS_IND
MAC_MLME_POLL_CNF
Poll confirm.
MAC_MLME_COMM_STATUS_IND
MAC_MLME_POLL_IND
Poll indication.
MAC_MCPS_DATA_CNF
Data confirm.
MAC_MCPS_DATA_IND
Data indication.
MAC_MCPS_PURGE_CNF
Purge confirm.
MAC_PWR_ON_CNF
Power on confirm.
7.1.1.4 Return
None.
7.1.2 MAC_CbackCheckPending ( )
7.1.2.1 Description
This callback function returns the number of pending indirect messages queued in the application. Most
applications do not queue indirect data and can simply always return zero. The number of pending indirect
messages only needs to be returned if macCfg.appPendingQueue to TRUE.
The application must implement this function if it chooses not to use the Autopend feature. When Autopend is
enabled, the return value of this function is ignored in low level TIMAC. Otherwise, it is critical that the
application implement this function to be as fast as possible; for example, just returning the value of a global
variable.
7.1.2.2 Prototype
uint8 MAC_CbackCheckPending(void)
45
8. Configuration
8.1 Configuration Constants
The MAC uses a structure containing various user-configurable parameters. This structure is called macCfg and is
in file mac_cfg.c. The structure is defined as follows.
typedef struct
{
uint8
txDataMax;
uint8
txMax;
uint8
rxMax;
uint8
dataIndOffset;
bool
appPendingQueue;
} macCfg_t;
NAME
DESCRIPTION
RANGE
DEFAUL
T
txDataMax
1-255
txMax
1-255
rxMax
1-255
dataIndOffset
0-127
appPendingQueue
TRUEFALSE
FALSE
46
DESCRIPTION
RANGE
DEFAUL
T
MAC_NO_PARAM_CHECK
TRUE,
FALSE
FALSE
MACNODEBUG
N/A
undefined
MAC_RX_ONOFF_DEBUG_LED
TRUE,
FALSE
FALSE
9. Scenarios
This section contains scenarios that provide additional information about the operation of the API. Each scenario
had a ladder diagram that illustrates how API functions and callback events operate.
9.1 Non beacon-enabled network Start
This scenario shows a PAN coordinator device starting a non beacon-enabled network. It first resets the MAC on
device startup. Then it performs an energy detect scan to find an unused channel. Then it performs an active scan
to find the channel with the lowest number of active networks. After the scan it sets the MAC attributes it needs to
start a network: the short address, beacon payload, and associate permit flag. Then it starts a non beacon-enabled
network.
47
MAC
MAC
MAC_MlmeScanReq()
[active scan]
Coordinator
MAC_MLME_SCAN_CNF
Select
coordinator
MAC_MlmeAssociateReq()
associate request
MAC_MLME_ASSOCIATE_IND
MAC_MlmeAssociateRsp()
MAC_MLME_COMM_STATUS_IND
48
49
MAC
Coordinator
Application
MAC
MAC_MlmeScanReq()
[orphan scan]
coordinator realignment
MAC_MLME_SCAN_CNF
MAC_MLME_COMM_STATUS_IND
[MAC_SUCCESS]
50
MAC
MAC
Coordinator
MAC_McpsDataReq(mdsuHandle=0)
data transmitted and acknowledged
MAC_MCPS_DATA_CNF
[MAC_SUCCESS]
[mdsuHandle=0]
MAC_MCPS_DATA_IND
MAC_McpsDataReq(msduHandle=1)
MAC_McpsDataReq(mdsuHandle=2)
MAC_McpsDataReq(mdsuHandle=3)
MAC_MCPS_DATA_CNF
[MAC_TRANSACTION_OVERFLOW]
[mdsuHandle=3]
data transmitted and acknowledged
MAC_MCPS_DATA_CNF
[MAC_SUCCESS]
[mdsuHandle=1]
MAC_MCPS_DATA_IND
MAC_McpsDataReq(mdsuHandle=3)
MAC_MCPS_DATA_IND
51
MAC
MAC
Device
MAC_McpsDataReq(mdsuHandle=0)
data queued
MAC_McpsPollReq()
data request and transmission
MAC_MCPS_DATA_CNF
[MAC_SUCCESS]
MAC_MCPS_POLL_CNF
[MAC_SUCCESS]
MAC_MCPS_DATA_IND
MAC_McpsDataReq(msduHandle=1)
data queued
MAC_McpsPurgeReq
(msduHandle=1)
data purged
MAC_MCPS_PURGE_CNF
[MAC_SUCCESS]
MAC_McpsPollReq()
data request, no data
MAC_MCPS_POLL_CNF
[MAC_NO_DATA]
52