mirror of
https://github.com/espressif/openthread.git
synced 2026-08-16 15:47:46 +00:00
[wake-up] fix time wrap for wake-up frames (#11028)
This commit fixes the potential issue that mTxDelay becomes 0 around the 32-bit time wrapping.
This commit is contained in:
@@ -413,7 +413,7 @@ void SubMac::StartCsmaBackoff(void)
|
||||
uint8_t backoffExponent = kCsmaMinBe + mCsmaBackoffs;
|
||||
|
||||
#if !OPENTHREAD_MTD && OPENTHREAD_CONFIG_MAC_CSL_TRANSMITTER_ENABLE
|
||||
if (mTransmitFrame.mInfo.mTxInfo.mTxDelay != 0)
|
||||
if (mTransmitFrame.mInfo.mTxInfo.mTxDelay != 0 || mTransmitFrame.mInfo.mTxInfo.mTxDelayBaseTime != 0)
|
||||
{
|
||||
SetState(kStateCslTransmit);
|
||||
|
||||
|
||||
@@ -80,15 +80,17 @@ Mac::TxFrame *WakeupTxScheduler::PrepareWakeupFrame(Mac::TxFrames &aTxFrames)
|
||||
Mac::TxFrame *frame = nullptr;
|
||||
Mac::Address target;
|
||||
Mac::Address source;
|
||||
uint32_t radioTxUs;
|
||||
uint32_t radioTxDelay;
|
||||
uint32_t rendezvousTimeUs;
|
||||
TimeMicro nowUs = TimerMicro::GetNow();
|
||||
Mac::ConnectionIe *connectionIe;
|
||||
|
||||
VerifyOrExit(mIsRunning);
|
||||
|
||||
target.SetExtended(mWedAddress);
|
||||
source.SetExtended(Get<Mac::Mac>().GetExtAddress());
|
||||
radioTxUs = static_cast<uint32_t>(Get<Radio>().GetNow()) + (mTxTimeUs - TimerMicro::GetNow());
|
||||
VerifyOrExit(mTxTimeUs >= nowUs);
|
||||
radioTxDelay = mTxTimeUs - nowUs;
|
||||
|
||||
#if OPENTHREAD_CONFIG_MULTI_RADIO
|
||||
frame = &aTxFrames.GetTxFrame(Mac::kRadioTypeIeee802154);
|
||||
@@ -97,8 +99,8 @@ Mac::TxFrame *WakeupTxScheduler::PrepareWakeupFrame(Mac::TxFrames &aTxFrames)
|
||||
#endif
|
||||
|
||||
VerifyOrExit(frame->GenerateWakeupFrame(Get<Mac::Mac>().GetPanId(), target, source) == kErrorNone, frame = nullptr);
|
||||
frame->SetTxDelayBaseTime(0);
|
||||
frame->SetTxDelay(radioTxUs);
|
||||
frame->SetTxDelayBaseTime(static_cast<uint32_t>(Get<Radio>().GetNow()));
|
||||
frame->SetTxDelay(radioTxDelay);
|
||||
frame->SetCsmaCaEnabled(false);
|
||||
frame->SetMaxCsmaBackoffs(0);
|
||||
frame->SetMaxFrameRetries(0);
|
||||
|
||||
Reference in New Issue
Block a user