diff --git a/src/core/mac/mac.cpp b/src/core/mac/mac.cpp index 2637c5c164e4..197a3d710e0a 100644 --- a/src/core/mac/mac.cpp +++ b/src/core/mac/mac.cpp @@ -2519,11 +2519,9 @@ Error Mac::SetWedListenEnabled(bool aEnable) void Mac::UpdateWakeupListening(void) { - uint32_t interval = mWedListenEnabled ? mWedListenInterval : 0; - uint16_t duration = mWedListenEnabled ? mWedListenDuration : 0; - uint8_t channel = mWakeupChannel ? mWakeupChannel : mPanChannel; + uint8_t channel = mWakeupChannel ? mWakeupChannel : mPanChannel; - mLinks.UpdateWakeupListening(interval, duration, channel); + mLinks.UpdateWakeupListening(mWedListenEnabled, mWedListenInterval, mWedListenDuration, channel); } Error Mac::HandleWakeupFrame(const RxFrame &aFrame) diff --git a/src/core/mac/mac_links.hpp b/src/core/mac/mac_links.hpp index 7ca0d9ff8ee1..d61195c7a122 100644 --- a/src/core/mac/mac_links.hpp +++ b/src/core/mac/mac_links.hpp @@ -477,17 +477,19 @@ class Links : public InstanceLocator /** * Configures wake-up listening parameters in all radios. * + * @param[in] aEnable Whether to enable or disable wake-up listening. * @param[in] aInterval The WED listen interval in microseconds. * @param[in] aDuration The WED listen duration in microseconds. * @param[in] aChannel The wake-up channel. */ - void UpdateWakeupListening(uint32_t aInterval, uint16_t aDuration, uint8_t aChannel) + void UpdateWakeupListening(bool aEnable, uint32_t aInterval, uint16_t aDuration, uint8_t aChannel) { + OT_UNUSED_VARIABLE(aEnable); OT_UNUSED_VARIABLE(aInterval); OT_UNUSED_VARIABLE(aDuration); OT_UNUSED_VARIABLE(aChannel); #if OPENTHREAD_CONFIG_RADIO_LINK_IEEE_802_15_4_ENABLE - mSubMac.UpdateWakeupListening(aInterval, aDuration, aChannel); + mSubMac.UpdateWakeupListening(aEnable, aInterval, aDuration, aChannel); #endif } #endif diff --git a/src/core/mac/sub_mac.hpp b/src/core/mac/sub_mac.hpp index 586b4c1cb288..59214bb3fd14 100644 --- a/src/core/mac/sub_mac.hpp +++ b/src/core/mac/sub_mac.hpp @@ -484,11 +484,12 @@ class SubMac : public InstanceLocator, private NonCopyable /** * Configures wake-up listening parameters in all radios. * + * @param[in] aEnable Whether to enable or disable wake-up listening. * @param[in] aInterval The WED listen interval in microseconds. * @param[in] aDuration The WED listen duration in microseconds. * @param[in] aChannel The wake-up channel. */ - void UpdateWakeupListening(uint32_t aInterval, uint16_t aDuration, uint8_t aChannel); + void UpdateWakeupListening(bool aEnable, uint32_t aInterval, uint16_t aDuration, uint8_t aChannel); #endif private: diff --git a/src/core/mac/sub_mac_wed.cpp b/src/core/mac/sub_mac_wed.cpp index 3a6b2cf9fd8b..ad1c4b4e1d34 100644 --- a/src/core/mac/sub_mac_wed.cpp +++ b/src/core/mac/sub_mac_wed.cpp @@ -48,17 +48,16 @@ void SubMac::WedInit(void) mWedTimer.Stop(); } -void SubMac::UpdateWakeupListening(uint32_t aInterval, uint16_t aDuration, uint8_t aChannel) +void SubMac::UpdateWakeupListening(bool aEnable, uint32_t aInterval, uint16_t aDuration, uint8_t aChannel) { VerifyOrExit(RadioSupportsReceiveTiming()); - VerifyOrExit(aInterval != mWedListenInterval || aDuration != mWedListenDuration || aChannel != mWakeupChannel); mWedListenInterval = aInterval; mWedListenDuration = aDuration; mWakeupChannel = aChannel; mWedTimer.Stop(); - if (mWedListenInterval > 0) + if (aEnable) { mWedSampleTime = TimerMicro::GetNow() + kCslReceiveTimeAhead - mWedListenInterval; mWedSampleTimeRadio = otPlatRadioGetNow(&GetInstance()) + kCslReceiveTimeAhead - mWedListenInterval;