Allow duplicate pending APS ACKs and take ownership over APS seq - #57
Open
puddly wants to merge 2 commits into
Open
Allow duplicate pending APS ACKs and take ownership over APS seq#57puddly wants to merge 2 commits into
puddly wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR addresses APS_ACK_TIMEOUTs by ensuring the stack (not zigpy/host) owns the APS sequence/counter space, preventing collisions between host-originated APS frames and stack-originated frames (e.g., ZDP / APS commands), and by allowing multiple pending APS-ACK waits to coexist.
Changes:
- Treat
aps_seqin the wire protocol as an ignored/stability field and stop passing it from the bridge into the driver stack. - Make the stack generate APS counters internally (including random seeding on startup) for unicast/broadcast/groupcast and other stack-originated traffic.
- Replace the pending APS-ACK tracking structure to support duplicate keys and resolve ACKs against the oldest matching in-flight entry.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| crates/ziggurat-protocol/src/wire.rs | Documents aps_seq as ignored (kept for wire stability) across unicast/broadcast/groupcast payloads. |
| crates/ziggurat-protocol/src/bridge.rs | Stops forwarding host-provided aps_seq into stack send APIs. |
| crates/ziggurat-driver/src/zigbee_stack/aps.rs | Tracks pending APS ACKs in a Vec, matches the oldest entry, and makes the stack pick the APS counter for outgoing frames. |
| crates/ziggurat-driver/src/zigbee_stack.rs | Adds ack_data to PendingApsAck, switches pending ACK storage to Vec, and seeds the APS counter randomly. |
| crates/ziggurat-driver/src/rng.rs | Adds random_u8() to support random APS counter seeding. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+686
to
+689
| /// Sends awaiting an end-to-end APS ack. Unordered, like | ||
| /// [`Self::pending_unicast_retries`]: an ack key does not identify an entry, so | ||
| /// several in-flight frames can share one and the oldest match wins. | ||
| pub pending_aps_acks: Mutex<Vec<PendingApsAck>>, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #56.
Fundamentally, we shouldn't allow zigpy to supply the APS sequence number to begin with: the stack should own it, especially once we start sending more ZDO requests for topology scanning. This aligns Ziggurat with all the other radio libraries.