Skip to content

Fix CYW43439 join recovery - #1108

Open
sqt wants to merge 3 commits into
ZigEmbeddedGroup:mainfrom
zz-iot:fix/cyw43439-join-recovery
Open

sqt wants to merge 3 commits into
ZigEmbeddedGroup:mainfrom
zz-iot:fix/cyw43439-join-recovery

Conversation

@sqt

@sqt sqt commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Motivation

  • WiFi join retries can fail because connection events received while waiting for control replies are discarded, or stale state carries over from an earlier attempt.
  • A retry can also interrupt an automatic reconnection that has already succeeded by sending another set_ssid command.

Description of changes

  • Dispatch WiFi events received during control-response polling, clear stale state before joining, and preserve a join that completes while command replies are being processed.
  • Add preserve_auto_reconnect, disabled by default, to retain a successful automatic reconnection when retrying the same network and credentials.
  • Add regression tests for interleaved events and both enabled and disabled reconnection preservation

Comment thread drivers/src/wireless/cyw43439/wifi.zig Resolved
Comment thread drivers/src/wireless/cyw43439/wifi.zig Resolved
@sqt
sqt requested a review from mattnite November 6, 2026 16:21
@mattnite

mattnite commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

@arkadiuszwojcik could you take a look please?

Comment thread drivers/src/wireless/cyw43439/wifi.zig Outdated
// The radio can automatically reassociate while command replies are being
// polled. When retrying the same credentials, keep that authenticated link
// instead of clearing its events and aborting it with another set_ssid.
if (opt.preserve_auto_reconnect and

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

what does this expression even mean?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It's how you can test for authenticated reassociation. I've pulled the test expression out into a helper method to make it more clear what's being checked.

Comment thread drivers/src/wireless/cyw43439/wifi.zig Outdated
const is_event = self.index < events.len;
const len: u16 = if (is_event) JoinTestPackets.event_len else JoinTestPackets.control_len;
if (words.len == 2) { // bus-status read, plus trailing SPI status word
// gSPI status: F2 packet available at bit 8, packet length at bits 9..19.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why are you including the positions of fields and lengths in comments, and doing raw bit manipulations, and duplicating them in tests? This is a very odd choice given you have BusStatus defined as a packed struct, and I had already guided you to not use magic numbers.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The primary reason was because most of the structs I would have needed from ioctl.zig weren't public, so I manually tracked positions and set bytes rather than changing that file (aiming for a contained fix and tests within wifi.zig).

But you're right, it's cleaner to directly use those structs, so I've made them public in ioctl.zig so I can reuse them (along with BusStatus) here.

@sqt
sqt requested a review from mattnite November 17, 2026 13:05

This branch has not been deployed

No deployments
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