Skip to content

Commit

Permalink
more reviews
Browse files Browse the repository at this point in the history
  • Loading branch information
edmont committed Oct 4, 2024
1 parent 82c817c commit e9bd1d2
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 11 deletions.
8 changes: 4 additions & 4 deletions src/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4418,7 +4418,7 @@ Done
### wakeup interval
Get the wake-up interval.
Get the wake-up listen interval.
Requires `OPENTHREAD_CONFIG_WAKEUP_END_DEVICE_ENABLE`.
Expand All @@ -4430,7 +4430,7 @@ Done
### wakeup interval \<interval\>
Set the wake-up interval.
Set the wake-up listen interval.
Requires `OPENTHREAD_CONFIG_WAKEUP_END_DEVICE_ENABLE`.
Expand All @@ -4441,7 +4441,7 @@ Done
### wakeup duration
Get the wake-up duration.
Get the wake-up listen duration.
Requires `OPENTHREAD_CONFIG_WAKEUP_END_DEVICE_ENABLE`.
Expand All @@ -4453,7 +4453,7 @@ Done
### wakeup duration \<duration\>
Set the wake-up duration.
Set the wake-up listen duration.
Requires `OPENTHREAD_CONFIG_WAKEUP_END_DEVICE_ENABLE`.
Expand Down
10 changes: 10 additions & 0 deletions src/core/config/mac.h
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,16 @@
#define OPENTHREAD_CONFIG_CSL_RECEIVE_TIME_AHEAD 320
#endif

/**
* @def OPENTHREAD_CONFIG_WED_RECEIVE_TIME_AFTER
*
* Margin to be applied after the end of a WED listen duration to schedule the next listen interval, in units of
* microseconds.
*/
#ifndef OPENTHREAD_CONFIG_WED_RECEIVE_TIME_AFTER
#define OPENTHREAD_CONFIG_WED_RECEIVE_TIME_AFTER 500
#endif

/**
* @def OPENTHREAD_CONFIG_MIN_RECEIVE_ON_AHEAD
*
Expand Down
2 changes: 1 addition & 1 deletion src/core/mac/mac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2494,7 +2494,7 @@ Error Mac::SetWedListenEnabled(bool aEnable)
VerifyOrExit(GetWedListenInterval() > GetWedListenDuration(), error = kErrorInvalidArgs);

#if OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE
if (aEnable && IsCslEnabled())
if (aEnable && GetCslPeriod() > 0)
{
LogWarn("Cannot enable wake-up frame listening while CSL is enabled");
ExitNow(error = kErrorInvalidState);
Expand Down
7 changes: 4 additions & 3 deletions src/core/mac/sub_mac.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -556,9 +556,10 @@ class SubMac : public InstanceLocator, private NonCopyable
static constexpr uint32_t kCslReceiveTimeAhead = OPENTHREAD_CONFIG_CSL_RECEIVE_TIME_AHEAD;
#endif

#if OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE && OPENTHREAD_CONFIG_WAKEUP_END_DEVICE_ENABLE
// Margin to be applied to detect wake-up listening receive slots overlaps with CSL slots, in us
static constexpr uint32_t kWakeupListeningOverlapMargin = 600;
#if OPENTHREAD_CONFIG_WAKEUP_END_DEVICE_ENABLE
// Margin to be applied after the end of a WED listen duration to schedule the next listen interval.
// The value is in usec.
static constexpr uint32_t kWedReceiveTimeAfter = OPENTHREAD_CONFIG_WED_RECEIVE_TIME_AFTER;
#endif

#if OPENTHREAD_CONFIG_MAC_CSL_TRANSMITTER_ENABLE
Expand Down
14 changes: 11 additions & 3 deletions src/core/mac/sub_mac_wed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ void SubMac::UpdateWakeupListening(uint32_t aInterval, uint16_t aDuration, uint8
{
mWedSampleTime = TimerMicro::GetNow() + kCslReceiveTimeAhead;
mWedSampleTimeRadio = otPlatRadioGetNow(&GetInstance()) + kCslReceiveTimeAhead;

if ((mWedSampleTime.GetValue() > mWedListenInterval) && (mWedSampleTimeRadio > mWedListenInterval))
{
mWedSampleTime -= mWedListenInterval;
mWedSampleTimeRadio -= mWedListenInterval;
}

HandleWedTimer();
}

Expand All @@ -73,14 +80,15 @@ void SubMac::HandleWedTimer(Timer &aTimer) { aTimer.Get<SubMac>().HandleWedTimer

void SubMac::HandleWedTimer(void)
{
mWedSampleTime += mWedListenInterval;
mWedSampleTimeRadio += mWedListenInterval;
mWedTimer.FireAt(mWedSampleTime + mWedListenDuration + kWedReceiveTimeAfter);

if (mState != kStateDisabled)
{
IgnoreError(
Get<Radio>().ReceiveAt(mWakeupChannel, static_cast<uint32_t>(mWedSampleTimeRadio), mWedListenDuration));
}
mWedSampleTime += mWedListenInterval;
mWedSampleTimeRadio += mWedListenInterval;
mWedTimer.FireAt(mWedSampleTime - kCslReceiveTimeAhead);
}

} // namespace Mac
Expand Down

0 comments on commit e9bd1d2

Please sign in to comment.