IPv4 address can persist well after wifi AP connection is lost
MicroPython v1.19.1 on 2022-09-20; Raspberry Pi Pico W with RP2040
As noted in a comment in #9455:
wlan.status() of 3 means:
#define CYW43_LINK_UP (3) Connect to wifi with an IP address
as opposed to:
#define | CYW43_LINK_NOIP (2) Connected to wifi, but no IP address
But the device will still have an IP address even when it has become disconnected from the wifi Access Point (at least when it disconnects through the mechanism in 9455). Is this an intended feature, emergent feature, or bug? The IP address also sometimes returns 0.0.0.0, which I suspect is the wlan.status() == 2 case, and is at least is easy to check for.
From #8994:
The idea with soft reset is that it resets Python state but not necessarily hardware state. Eg soft reset won't put GPIO back to a default state, or disable USB. Any hardware that's left untouched after a soft reset should still be in a valid state, and if code expects to run after a soft reset then it must be aware that hardware peripherals can be in a variety of states when MicroPython code starts running.
But this doesn't seem to fall within the realm of hardware state, since the device shows an IP address at times when it doesn't actually have a connection to an AP and, particularly in the DHCP case, doesn't have a valid IP address.
Cannot change default exposed IP (for DHCP etc) on Pico W running in AP mode (remains exposing default 192.168.4.x)
Port, board and/or hardware
Pico W
MicroPython version
MicroPython v1.26.0 on 2025-08-09; Raspberry Pi Pico W with RP2040
Reproduction
- Create a WLAN in IF_AP mode and set IP (and subnet, GW, DNS, etc) via WLAN.ifconfig
- Confirm that ifconfig() returns the expected parameters
- Conclude that the exposed IP address (incl DHCP range etc) when connecting clients to the AP remains the default 192.168.4.1
Expected behaviour
Expected the exposed DHCP gateway address and range to follow the set parameters, instead of the default 192.168.4.1
Observed behaviour
DHCP gateway address and range remain 192.168.4.1
Additional Information
(!) Do ensure ifconfig() is called áfter activating the WLAN, as otherwise it will definitely reset to the default settings, confirmed by printing them. So WLAN.active(true), then WLAN.ifconfig(...)
See also this link
and this link
Code of Conduct
Yes, I agree