Files
openthread/tests
Abtin Keshavarzian 5c8c318627 [sub-mac] introduce unified ReceiveAt logic for timed RX (#13491)
This commit introduces a unified `ReceiveAt` abstraction in `SubMac` to
handle timed reception windows (CSL receiver, WED / Thread-Direct wakeup
listener)

Motivation & Benefits:

Previously, CSL sample window calculation and scheduling differed between
platform-offloaded timing (`OT_RADIO_CAPS_RECEIVE_TIMING`) and stack-driven
timing (`SubMac` software timers):
- `GetCslWindowEdges()` added `kCslReceiveTimeAhead` lead time to the window
  margin, only for offloaded callers to manually subtract it back out before
  calling `Radio::ReceiveAt()`.
- Stack-driven mode relied on separate timers for sample/sleep transitions
  (`HandleCslReceiveOrSleep`, `HandleWedReceiveOrSleep`), leading to code
  duplication and inconsistent timing margins across platform vs stack-driven
  executions.

This commit harmonizes timed reception handling:
- `GetCslWindowEdges()` cleanly computes target window bounds without caller-side
  adjustments.
- `SubMac::ReceiveAt()` provides a single, consistent API for both offloaded
  and stack-driven timing.
- Provides a clean foundation for Thread-Direct wakeup listening (WED) and
  future timed reception features.

Key changes:

- State Machine Refactoring: Simplifies the state management adding
  `kStateTimedReceive`. The radio state is `kStateTimedReceive` when
  actively receiving in a target rx window, and `kStateSleep` otherwise.
- `TimedRx` Helper Class: Encapsulates window parameters (`mStartTime`,
  `mDuration`, `mChannel`) and state checks (`HasStarted`, `HasEnded`).
- Pending & Active Window Preemption: `UpdateTimedRxState()` manages
  the timed RX schedules and sets the timer accordingly. It ensures
  pending windows starting before an active window ends are promoted
  seamlessly.
- Unit Test: Adds a detailed `test_sub_mac_recv_at.cpp` covering various
  behaviors (including edge-cases) of `ReceiveAt()` logic.
2026-08-31 14:27:24 -07:00
..