Skip to content

Send back SendUnicastResult with the APS seq and allow overrides - #68

Open
puddly wants to merge 1 commit into
devfrom
puddly/unicast-result-aps-seq2
Open

puddly wants to merge 1 commit into
devfrom
puddly/unicast-result-aps-seq2

Conversation

@puddly

@puddly puddly commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

See #64 for more info.

This introduces SendUnicastResult, which returns the APS sequence number picked by Ziggurat for the unicast send. This allows zigpy to control retries by flipping the force_aps_seq bit and passing back this same APS sequence number.

@zigpy-review-bot zigpy-review-bot added the new feature Adds new feature label Oct 17, 2026
@puddly
puddly marked this pull request as ready for review October 23, 2026 15:11
Copilot AI balanced review requested due to automatic review settings October 23, 2026 15:11

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.

🟡 Changes recommended

The new return type breaks the embedded dispatcher, and ACK handling can incorrectly time out sleepy-child sends and counter-preserving retries.

3 open issues
What changed in this PR

This PR exposes the APS sequence number assigned to unicast sends and lets hosts reuse it for retries, supporting duplicate rejection as discussed in issue #64.

Changes:

  • Adds SendUnicastResult and a force_aps_seq flag to the control protocol.
  • Passes optional counter overrides through the bridge and stack, returning the selected counter to the server.
  • Revises sleepy-destination ACK timeout calculation and removes the separate indirect timeout setting.
File Description
crates/​ziggurat-zigbee/​src/​constants.rs Removes the separate indirect ACK timeout setting.
crates/​ziggurat-server/​src/​main.rs Returns the selected APS sequence number for unicast requests.
crates/​ziggurat-protocol/​src/​wire.rs Defines counter overrides and the unicast result payload.
crates/​ziggurat-protocol/​src/​bridge.rs Connects protocol counter selection and results to the stack.
crates/​ziggurat-driver/​src/​zigbee_stack/​aps.rs Supports counter reuse and revises sleepy-device timeouts.
crates/​ziggurat-driver/​src/​zigbee_stack.rs Introduces the ApsCounter type alias.

Review effort: Balanced

Comment thread crates/ziggurat-protocol/src/bridge.rs
fn aps_ack_timeout(&self, destination: Nwk, sleepy_destination: bool) -> Duration {
if sleepy_destination || self.sleepy_child_eui64(destination).is_some() {
self.tunables.aps_ack_timeout_indirect()
if sleepy_destination && self.sleepy_child_eui64(destination).is_none() {
) -> Result<(SendHandle, ApsCounter), EnqueueError> {
let asdu = FrameBytes::from_slice(&data).map_err(|_| EnqueueError::PayloadTooLong)?;
let aps_seq = self.next_aps_counter();
let aps_seq = aps_counter.unwrap_or_else(|| self.next_aps_counter());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new feature Adds new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants