Skip to content

Conversation

@earlephilhower
Copy link
Owner

@earlephilhower earlephilhower commented Sep 29, 2025

Fixes #3157
Fixes #1837

The SDK's CYW43 WiFi connection scheme combined both link layer (WiFi net connection) and IP (getting an IP address from DHCP) into a single step. We worked around it with a hack wrapped function, but it resulted in the WiFi.begin() timeout being 2x as long as specified.

Remove the SDK's cyw43_arch_wifi_connect_timeout_ms and replace with our own custom CYW43::begin which will only look at the link layer. Note that the SDK docs are hokey and the cyw43_link_status is set to 1 while network connection attempts are underway. This means we can't actually just look at the link state, it will be in JOIN even if it's not really joined. So, we peek at the state internal CYW43 join FSM to see we're really connected.

This exposed a corner case which @ledereyes seems to have run into in his own app where the LwipIntfDev could potentially try and register the same netif twice because the underlying lower-level CYW43 link had failed. Ensure we netif_remove() in that case to avoid this issue.

On WiFi.end(), just disconnect the network and don't deinitialize the chip in case Bluetooth is active.

Fixes #3157
Fixes #1837

The SDK's CYW43 WiFi connection scheme combined both link layer (WiFi net
connection) and IP (getting an IP address from DHCP) into a single step.
We worked around it with a hack wrapped function, but it resulted in
the WiFi.begin() timeout being 2x as long as specified.

Remove the SDK's cyw43_arch_wifi_connect_timeout_ms and replace with
our own custom CYW43::begin which will only look at the link layer.
Note that the SDK docs are hokey and the cyw43_link_status is set to 1
*while network connection attempts are underway.*  This means we can't
actually just look at the link state, it will be in JOIN even if it's
not really joined.  So, we peek at the state internal CYW43 join FSM
to see we're *really* connected.

This exposed a corner case which @ledereyes seems to have run into in
his own app where the LwipIntfDev could potentially try and register
the same netif twice because the underlying lower-level CYW43 link
had failed.  Ensure we netif_remove() in that case to avoid this issue.

On WiFi.end(), just disconnect the network and don't deinitialize the
chip in case Bluetooth is active.
@earlephilhower earlephilhower merged commit 8208b1f into master Sep 30, 2025
28 checks passed
@earlephilhower earlephilhower deleted the red branch September 30, 2025 20:01
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.

Second call to WiFi.begin() + ArduinoOTA running seems to block forever on RP2040 Feature Request: Run BT and WiFi Simultaneously on Pico W

2 participants