Skip to content

Fix rx_when_idle never being propagated to radio config#3

Closed
Copilot wants to merge 7 commits intofor-reviewfrom
copilot/debug-openthread-reassembly-timeout
Closed

Fix rx_when_idle never being propagated to radio config#3
Copilot wants to merge 7 commits intofor-reviewfrom
copilot/debug-openthread-reassembly-timeout

Conversation

Copy link

Copilot AI commented Feb 10, 2026

radio_conf.rx_when_idle is initialized to false and never updated. The ESP radio hardware is never told to keep its receiver on during idle, causing missed 802.15.4 fragments and reassembly-timeout errors.

Two issues compound here:

  1. otPlatRadioSetRxOnWhenIdle was not implemented
  2. The precompiled MTD libraries don't even call otPlatRadioSetRxOnWhenIdle (symbol is unreferenced in all shipped .a files), so implementing it alone is insufficient

Changes

  • platform.rs: Add otPlatRadioSetRxOnWhenIdle extern callback — covers from-source builds where OT calls this
  • lib.rs: Query otThreadGetLinkMode().mRxOnWhenIdle() in plat_changed and sync to radio_conf — covers precompiled MTD libraries that fire state change callbacks but never call otPlatRadioSetRxOnWhenIdle
  • Extract shared update_rx_when_idle helper to deduplicate the two update paths

Flow after fix

OpenThread state change → plat_changed()
  → otThreadGetLinkMode() → mRxOnWhenIdle()
  → radio_conf.rx_when_idle = true
  → next RadioCommand::Rx carries updated Config
  → ESP radio configured with rx_when_idle: true

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 5 commits February 10, 2026 06:53
…correct alarm wrapping

Process tasklets immediately after otPlatRadioReceiveDone, otPlatRadioTxDone,
and otPlatAlarmMilliFired to match the standard OpenThread event loop pattern.
This ensures deferred radio commands (e.g. from MeshForwarder tasklets) are
processed before the radio loop starts its next operation, reducing gaps
where the radio is idle and fragments can be missed.

Also fix the alarm time computation to correctly handle u32 wrapping by
computing the offset from current time in 32-bit wrapping space, rather
than naively converting the truncated u32 back to a 64-bit Instant.

Co-authored-by: ivmarkov <2607589+ivmarkov@users.noreply.github.com>
…sing

Co-authored-by: ivmarkov <2607589+ivmarkov@users.noreply.github.com>
…bility

Fix OpenThread stability: inline tasklet processing after events and correct alarm wrapping
Copilot AI and others added 2 commits February 10, 2026 08:04
- Add otPlatRadioSetRxOnWhenIdle callback in platform.rs for OpenThread
  C library builds that call it (e.g. when OT_RADIO_CAPS_RX_ON_WHEN_IDLE
  is supported)
- Query link mode in plat_changed callback and sync rx_when_idle to
  radio_conf, ensuring the radio hardware is told to stay in receive mode
  when the Thread link mode requires it
- Add plat_radio_set_rx_on_when_idle method in OtContext

Previously, radio_conf.rx_when_idle was initialized to false and never
updated, causing the ESP radio hardware to not stay in receive mode
during idle periods. This led to missed 802.15.4 fragments and
reassembly-timeout errors.

Co-authored-by: ivmarkov <2607589+ivmarkov@users.noreply.github.com>
Co-authored-by: ivmarkov <2607589+ivmarkov@users.noreply.github.com>
Copilot AI changed the title [WIP] Investigate rx_when_idle configuration in openthread Fix rx_when_idle never being propagated to radio config Feb 10, 2026
Copilot AI requested a review from ivmarkov February 10, 2026 08:10
@ivmarkov ivmarkov force-pushed the for-review branch 10 times, most recently from 18574c6 to 3bca3bd Compare February 18, 2026 16:02
@ivmarkov ivmarkov closed this Feb 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments