-
Notifications
You must be signed in to change notification settings - Fork 1.3k
picow: ask at a lower level if the interface is up #7075
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Closes: adafruit#7072 ``` Adafruit CircuitPython 8.0.0-beta.2-9-g5192082e64-dirty on 2022-10-17; Raspberry Pi Pico W with rp2040 >>> import wifi >>> print(wifi.radio.ipv4_address) None >>> import os >>> wifi.radio.connect(os.getenv('WIFI_SSID'), os.getenv('WIFI_PASSWORD')) >>> print(wifi.radio.ipv4_address) 10.0.2.94 ```
@BiffoBear your testing here would also be helpful. Note that this build will only have the fix for this problem, not the one for #7076. |
Won't this also close #6996 ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested this successfully with a Pico W using the slightly modified version of code from the issue:
print(f"ipv4_gateway : {wifi.radio.ipv4_gateway}")
print(f"ipv4_subnet : {wifi.radio.ipv4_subnet}")
print(f"ipv4_address : {wifi.radio.ipv4_address}")
print(f"ipv4_dns : {wifi.radio.ipv4_dns}")
wifi.radio.connect(secrets["ssid"], secrets["password"])
print("---------------------")
print(f"ipv4_gateway : {wifi.radio.ipv4_gateway}")
print(f"ipv4_subnet : {wifi.radio.ipv4_subnet}")
print(f"ipv4_address : {wifi.radio.ipv4_address}")
print(f"ipv4_dns : {wifi.radio.ipv4_dns}")
With this build I do get None before connecting and real values after connecting.
When I use ctrl-c then ctrl-d to restart the script I do still have real values from the prints before the connection, but I assume it's intended to behave this way since there is no explicit disconnect action and therefore technically it's just staying connected similar to how displays do across the soft reset.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to @fomayguy's results, I did it in boot.py, then again in code.py:
boot.py output:
#### boot.py ####
None
None
None
None
Connecting..........
192.168.6.202
192.168.4.1
255.255.252.0
1.1.1.2
#### code.py ####
192.168.6.202
192.168.4.1
255.255.252.0
1.1.1.2
Connecting...
192.168.6.202
192.168.4.1
255.255.252.0
1.1.1.2
We should retest this when we have a code mechanism to disconnect (e.g., wifi.radio.enabled = False
or wifi.radio.stop_station()
) to verify that disconnection invalidates the IPv4 info and they all return None
.
With rp2040 there's no disconnect-from-wifi call that I've been able to find, so it stays connected across soft reset. This is different than the espressif port. |
MicroPython has a wlan.disconnect() for Cyw43 (also p.44) |
OK, I see |
(but honestly after using both wifi workflow on espressif and the never-disconnects wifi of picow -- I want wifi connections to stay across soft reset!) |
There are a variety of uses cases for wanting to: disconnect; turn off STA (and/or AP); even deinit wifi (we don't have that currently in either native port). • reduce resource consumption (power, ram) Oh also, at least in the Espressif case, each time you connect to a multi-AP SSID, it will pick the best one, so roaming with a device within a multi-AP SSID area will be able to optimize the connections better. I haven't come across any info on PiCow in the context of multi-AP SSIDs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. Thank you.
Closes: #7072