void Mac::SendBeaconRequest(Frame &aFrame) { // initialize MAC header uint16_t fcf = Frame::kFcfFrameMacCmd | Frame::kFcfDstAddrShort | Frame::kFcfSrcAddrNone; aFrame.InitMacHeader(fcf, Frame::kSecNone); aFrame.SetDstPanId(kShortAddrBroadcast); aFrame.SetDstAddr(kShortAddrBroadcast); aFrame.SetCommandId(Frame::kMacCmdBeaconRequest); otLogInfoMac("Sent Beacon Request\n"); }
void Mac::SendBeacon(Frame &aFrame) { uint16_t fcf; // initialize MAC header fcf = Frame::kFcfFrameBeacon | Frame::kFcfDstAddrNone | Frame::kFcfSrcAddrExt; aFrame.InitMacHeader(fcf, Frame::kSecNone); aFrame.SetSrcPanId(mPanId); aFrame.SetSrcAddr(mExtAddress); // write payload memcpy(aFrame.GetPayload(), &mBeacon, sizeof(mBeacon)); aFrame.SetPayloadLength(sizeof(mBeacon)); otLogInfoMac("Sent Beacon\n"); }
void DataPollManager::HandlePollTimeout(void) { // A data poll timeout happened, i.e., the ack in response to // a data poll indicated that a frame was pending, but no frame // was received after timeout interval. VerifyOrExit(mEnabled); mPollTimeoutCounter++; otLogInfoMac("Data poll timeout, retry:%d/%d", mPollTimeoutCounter, kQuickPollsAfterTimeout); if (mPollTimeoutCounter < kQuickPollsAfterTimeout) { SendDataPoll(); } else { mPollTimeoutCounter = 0; } exit: return; }
void DataPollManager::HandlePollSent(otError aError) { bool shouldRecalculatePollPeriod = false; VerifyOrExit(mEnabled); switch (aError) { case OT_ERROR_NONE: if (mRemainingFastPolls != 0) { mRemainingFastPolls--; if (mRemainingFastPolls == 0) { shouldRecalculatePollPeriod = true; mFastPollsUsers = 0; } } if (mRetxMode == true) { mRetxMode = false; mPollTxFailureCounter = 0; shouldRecalculatePollPeriod = true; } otLogInfoMac("Sent data poll"); break; case OT_ERROR_CHANNEL_ACCESS_FAILURE: case OT_ERROR_ABORT: mRetxMode = true; shouldRecalculatePollPeriod = true; break; default: mPollTxFailureCounter++; otLogInfoMac("Failed to send data poll, error:%s, retx:%d/%d", otThreadErrorToString(aError), mPollTxFailureCounter, kMaxPollRetxAttempts); if (mPollTxFailureCounter < kMaxPollRetxAttempts) { if (mRetxMode == false) { mRetxMode = true; shouldRecalculatePollPeriod = true; } } else { mRetxMode = false; mPollTxFailureCounter = 0; shouldRecalculatePollPeriod = true; } break; } if (shouldRecalculatePollPeriod) { ScheduleNextPoll(kRecalculatePollPeriod); } exit: return; }
void Mac::HandleReceiveTimer(void) { otLogInfoMac("data poll timeout!\n"); NextOperation(); }