void Mac::HandleBeginTransmit(void) { ThreadError error = kThreadError_None; if (otPlatRadioIdle() != kThreadError_None) { mBeginTransmit.Post(); ExitNow(); } switch (mState) { case kStateActiveScan: mSendFrame.SetChannel(mScanChannel); SendBeaconRequest(mSendFrame); mSendFrame.SetSequence(0); break; case kStateTransmitBeacon: mSendFrame.SetChannel(mChannel); SendBeacon(mSendFrame); mSendFrame.SetSequence(mBeaconSequence++); break; case kStateTransmitData: mSendFrame.SetChannel(mChannel); SuccessOrExit(error = mSendHead->HandleFrameRequest(mSendFrame)); mSendFrame.SetSequence(mDataSequence); break; default: assert(false); break; } // Security Processing ProcessTransmitSecurity(); SuccessOrExit(error = otPlatRadioTransmit(&mSendFrame)); if (mSendFrame.GetAckRequest() && !(otPlatRadioGetCaps() & kRadioCapsAckTimeout)) { mAckTimer.Start(kAckTimeout); otLogDebgMac("ack timer start\n"); } exit: if (error != kThreadError_None) { assert(false); } }
otError LinkRaw::DoTransmit(otRadioFrame *aFrame) { otError error = otPlatRadioTransmit(&mInstance, aFrame); #if OPENTHREAD_CONFIG_ENABLE_SOFTWARE_ACK_TIMEOUT // If we are implementing the ACK timeout logic, start a timer here (if ACK request) // to fire if we don't get a transmit done callback in time. if (static_cast<Mac::Frame *>(aFrame)->GetAckRequest()) { otLogDebgPlat(aInstance, "LinkRaw Starting AckTimeout Timer"); mTimerReason = kTimerReasonAckTimeout; mTimer.Start(Mac::kAckTimeout); } #endif return error; }