interface MCPS_DATA;
interface MCPS_PURGE;
} uses {
- interface GetNow<bool> as IsSendingBeacons;
interface FrameRx as CoordCapRx;
interface FrameTx as DeviceCapTx;
interface FrameTx as CoordCapTx;
message_t *frame,
uint8_t payloadLen,
uint8_t msduHandle,
- uint8_t txOptions
- )
+ uint8_t txOptions)
{
uint8_t srcAddrMode = call Frame.getSrcAddrMode(frame);
uint8_t dstAddrMode = call Frame.getDstAddrMode(frame);
ieee154_status_t txStatus;
ieee154_txframe_t *txFrame;
uint8_t sfType=0;
- uint8_t *mhr;
+ uint8_t *mhr, mhrLen = call Frame.getHeaderLength(frame);
- if (payloadLen > call Packet.maxPayloadLength())
+ if (payloadLen > call Packet.maxPayloadLength() ||
+ mhrLen + payloadLen + 2 > IEEE154_aMaxPHYPacketSize) // extra 2 for MAC footer (CRC)
txStatus = IEEE154_INVALID_PARAMETER;
else if ((!srcAddrMode && !dstAddrMode) ||
(srcAddrMode > ADDR_MODE_EXTENDED_ADDRESS || dstAddrMode > ADDR_MODE_EXTENDED_ADDRESS) ||
txFrame->metadata = &((message_metadata_t*) frame->metadata)->ieee154;
txFrame->payloadLen = payloadLen;
mhr = txFrame->header->mhr;
- txFrame->headerLen = call Frame.getHeaderLength(frame);
+ txFrame->headerLen = mhrLen;
mhr[MHR_INDEX_FC1] &= ~(FC1_FRAMETYPE_MASK | FC1_FRAME_PENDING | FC1_ACK_REQUEST);
mhr[MHR_INDEX_FC1] |= FC1_FRAMETYPE_DATA;
if (txOptions & TX_OPTIONS_ACK)
// coordinator address in the PIB, if they match the frame is
// sent in the incoming sf otherwise in the outgoing sf
call Frame.getDstAddr(frame, &dstAddr);
- if (dstAddrMode == ADDR_MODE_SHORT_ADDRESS){
+ if (dstAddrMode == ADDR_MODE_SHORT_ADDRESS) {
if (dstAddr.shortAddress == call MLME_GET.macCoordShortAddress())
sfType = INCOMING_SUPERFRAME;
else
sfType = OUTGOING_SUPERFRAME;
- } else if (dstAddrMode == ADDR_MODE_EXTENDED_ADDRESS){
+ } else if (dstAddrMode == ADDR_MODE_EXTENDED_ADDRESS) {
if (dstAddr.extendedAddress == call MLME_GET.macCoordExtendedAddress())
sfType = INCOMING_SUPERFRAME;
else
sfType = INCOMING_SUPERFRAME;
// GTS?
- if (txOptions & TX_OPTIONS_GTS){
+ if (txOptions & TX_OPTIONS_GTS) {
if (sfType == INCOMING_SUPERFRAME)
txStatus = call DeviceCfpTx.transmit(txFrame);
else
// indirect transmission?
} else if ((txOptions & TX_OPTIONS_INDIRECT) &&
- call IsSendingBeacons.getNow() &&
- (dstAddrMode >= ADDR_MODE_SHORT_ADDRESS)){
- if (dstAddrMode == ADDR_MODE_SHORT_ADDRESS && dstAddr.shortAddress == 0xFFFF){
+ (dstAddrMode >= ADDR_MODE_SHORT_ADDRESS)) {
+ if (dstAddrMode == ADDR_MODE_SHORT_ADDRESS && dstAddr.shortAddress == 0xFFFF) {
mhr[MHR_INDEX_FC1] &= ~FC1_ACK_REQUEST;
txStatus = call BroadcastTx.transmit(txFrame);
} else
else
txStatus = call CoordCapTx.transmit(txFrame);
- if (txStatus != IEEE154_SUCCESS){
+ if (txStatus != IEEE154_SUCCESS) {
call TxFramePool.put(txFrame);
}
}
}
command ieee154_status_t MCPS_PURGE.request (
- uint8_t msduHandle
- )
+ uint8_t msduHandle)
{
if (call PurgeDirect.purge(msduHandle) == IEEE154_SUCCESS ||
call PurgeIndirect.purge(msduHandle) == IEEE154_SUCCESS ||
message_t* dataReceived(message_t* frame)
{
- return signal MCPS_DATA.indication( frame );
+ return signal MCPS_DATA.indication(frame);
}
void finishTxTransaction(ieee154_txframe_t *txFrame, ieee154_status_t status)
uint8_t handle = txFrame->handle;
uint32_t txTime = txFrame->metadata->timestamp;
message_t *msg = (message_t*) ((uint8_t*) txFrame->header - offsetof(message_t, header));
+
call TxFramePool.put(txFrame);
signal MCPS_DATA.confirm(msg, handle, status, txTime);
}
message_t *msg,
uint8_t msduHandle,
ieee154_status_t status,
- uint32_t Timestamp
- ){}
+ uint32_t Timestamp) {}
- default event message_t* MCPS_DATA.indication ( message_t* frame ){ return frame; }
- default command ieee154_status_t DeviceCfpTx.transmit(ieee154_txframe_t *data){return IEEE154_INVALID_GTS;}
- default command ieee154_status_t CoordCfpTx.transmit(ieee154_txframe_t *data){return IEEE154_INVALID_GTS;}
+ default event message_t* MCPS_DATA.indication(message_t* frame) { return frame; }
+ default command ieee154_status_t DeviceCfpTx.transmit(ieee154_txframe_t *data) {return IEEE154_INVALID_GTS;}
+ default command ieee154_status_t BroadcastTx.transmit(ieee154_txframe_t *data) {return IEEE154_INVALID_PARAMETER;}
+ default command ieee154_status_t CoordCfpTx.transmit(ieee154_txframe_t *data) {return IEEE154_INVALID_GTS;}
}