Skip to content

Allow duplicate pending APS ACKs and take ownership over APS seq - #57

Open
puddly wants to merge 2 commits into
devfrom
puddly/duplicate-pending-aps-acks
Open

Allow duplicate pending APS ACKs and take ownership over APS seq#57
puddly wants to merge 2 commits into
devfrom
puddly/duplicate-pending-aps-acks

Conversation

@puddly

@puddly puddly commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

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.

Copilot AI review requested due to automatic review settings July 31, 2026 18:56

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_seq in 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>>,
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.

SEDs is generating APS_ACK_TIMEOUT

2 participants