Skip to content

Consolidate all send logic into three managed tables - #70

Draft
puddly wants to merge 26 commits into
devfrom
puddly/send-rewrite2
Draft

puddly wants to merge 26 commits into
devfrom
puddly/send-rewrite2

Conversation

@puddly

@puddly puddly commented Oct 23, 2026

Copy link
Copy Markdown
Member

This is a massive rewrite that still needs to be more thoroughly tested.

The goal is to migrate as much send logic and state tracking as possible into a single sans-io crate that manages send tables (Unicasts, UnroutedUnicasts, and Broadcasts) and emits discrete actions when driven. The benefit of this approach is that we can consolidate the various tables and reactors into one and introduce a bunch more compile-time safety guarantees.

AI Summary

Fixes

  • Every send has a deadline. A stalled radio no longer leaves frames queued forever. New handoff_timeout tunable and HandoffTimeout status.
  • The APS-ack timeout starts at handoff, not at the request. A slow route discovery or a sleepy destination no longer eats the ack window.
  • One budget token per send. Retransmissions and retries no longer take new tokens, so they cannot be refused mid-flight.
  • At most one copy of a broadcast is outstanding. A quorum heard while a copy was queued no longer sends it anyway.
  • Cancel settles the send immediately, or refuses it while it is in the radio. It no longer reports success for a send past cancelling.
  • Raw MAC frames get the frame-pending bit at transmit time.

Compile-time guarantees

  • Table actions are must_use; dropping them is a build error under clippy.
  • commit_sends takes the lock guard by value, so actions always run after the unlock.
  • dequeue returns a must_use receipt that only transmitted consumes, so every frame handed to the radio is reported back.
  • Helpers that take &mut ZigbeeCore or &Nib cannot lock the core, so they cannot deadlock under it.
  • The budget's record size is asserted at compile time.

@zigpy-review-bot zigpy-review-bot added the code quality Improvement to code quality label Oct 24, 2026
puddly added 26 commits October 31, 2026 00:01
A discovery expiring exactly now counts as lapsed, as it does in
`expire_discoveries`.
Every enqueue verb takes `now` and the tunables, so the deadline a send
gets is decided next to the stage it starts in. The driver no longer
computes one per enqueue site.
…ress

The enum encoded one fact, whether the frame waits for the device's poll
and under which address it polls, plus a retry count that is a tunable.
Those are two fields on the record; the driver passes them straight
through instead of building a variant at every enqueue site.
@puddly
puddly force-pushed the puddly/send-rewrite2 branch from 3c9f4a1 to 753d662 Compare October 31, 2026 01:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

code quality Improvement to code quality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants