2.9.1 WPAN_MCPS_Datareq Function
C
bool WPAN_MCPS_Datareq(uint8_t SrcAddrMode, WPAN_AddrSpec_t *DstAddrSpec, uint8_t msduLength, uint8_t *msdu, uint8_t msduHandle, uint8_t TxOptions)
Summary
Initiate MCPS-DATA.request service and have it placed in the MCPS-SAP queue.
Description
This function is used to send the data packets from one node to another. It Initiate MCPS-DATA.request service and have it placed in the MCPS-SAP queue. The MCPS-DATA.request primitive requests the transfer of a data SPDU (i.e., MSDU) from a local entity to a single peer entity.
Precondition
WPAN_Init() should have been called before calling this function.
Parameters
Param | Description |
---|---|
SrcAddrMode | Address Mode of the source address |
DstAddrSpec | Pointer to WPAN_AddrSpec_t structure for destination |
msduLength | Length of the data to be transmitted |
msdu | Pointer to the data to be transmitted |
msduHandle | Handle (identification) of the MSDU |
TxOptions | Bitmap for transmission options. Valid values:- @ref WPAN_TXOPT_OFF, @ref WPAN_TXOPT_ACK, @ref WPAN_TXOPT_INDIRECT, @ref WPAN_TXOPT_INDIRECT_ACK |
SecurityLevel | Used security level; this parameter is only available if MAC security is enabled via MAC_SECURITY_ZIP |
KeyIdMode | Used mode to identify the key; this parameter is only available if MAC security is enabled via MAC_SECURITY_ZIP |
KeyIndex | Used index of the key; this parameter is only available if MAC security is enabled via MAC_SECURITY_ZIP |
Returns
true - success; false - buffer not available or queue full.
Example
uint8_t src_addr_mode; WPAN_AddrSpec_t dst_addr; uint8_t msduHandle = 0; uint8_t data = (uint8_t)rand(); src_addr_mode = WPAN_ADDRMODE_SHORT; dst_addr.AddrMode = WPAN_ADDRMODE_SHORT; dst_addr.PANId = DEFAULT_PAN_ID; bool retVal = false; retVal = WPAN_MCPS_Datareq(src_addr_mode, &dst_addr, 1, &data, msduHandle, WPAN_TXOPT_ACK); if (true != retVal) { printf("buffer not available or queue full"); }
Remarks
On the receipt of WPAN_MCPS_Datareq, MAC layer will perform respective operation and asynchronously invokes USR_MCPS_DataConf with proper status.