-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Add wifi.radio.connected, wifi.radio.ap_active #7823
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
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.
Tested .connected
more thoroughly, looks good all around through mode and started / enabled changes.
.ap_active
is now True
(only) when wifi is started / enabled, and after start_ap()
(mode
is AP or AP+STA). It goes False
if wifi is disabled or if stop_ap()
. Tested various sequences, and everything tracked.
.ap_active
seems to be True
(only) when there is a valid wifi.radio.ipv4_address_ap
, and vice versa.
Both new properties LGTM on espressif
!
I'll try to work on raspberrypi
later, but since they are driver one-liners and you tested them, no need to wait on me.
I see 124 artifacts, but no Pico W? |
The latest changes only changed a file in There doesn't seem to be an easy way to get there from the PR, that I can find. |
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.
raspberrypi
.connected
and .ap_active
LGTM.
(Simpler scenarios with the current CYW implementation #7101 (review))
.connected
and .ipv4_address
are both correct immediately after a .connect()
, and again after a .stop_station()
.
ap_active
and ipv4_address_ap
are both correct immediately after a .start_ap()
(APs can't currently be stopped).
code and results...
import time
import wifi
from secrets import secrets
time.sleep(3) # wait for serial
print(f"Connecting...")
wifi.radio.connect(secrets["ssid"], secrets["password"])
start = time.monotonic_ns()
while not wifi.radio.connected:
pass
print(f"connected in {start - time.monotonic_ns()}ns connected={wifi.radio.connected} ipv4={wifi.radio.ipv4_address}")
print(f"Stopping STA...")
wifi.radio.stop_station()
print(f"connected={wifi.radio.connected} ipv4={wifi.radio.ipv4_address}")
time.sleep(1)
print(f"Connecting...")
wifi.radio.connect(secrets["ssid"], secrets["password"])
start = time.monotonic_ns()
while not wifi.radio.ipv4_address:
pass
print(f"IPv4 in {start - time.monotonic_ns()}ns connected={wifi.radio.connected} ipv4={wifi.radio.ipv4_address}")
print(f"Stopping STA...")
wifi.radio.stop_station()
print(f"connected={wifi.radio.connected} ipv4={wifi.radio.ipv4_address}")
time.sleep(1)
print(f"Starting AP...")
wifi.radio.start_ap("Bob", "YourUncle")
print(f"ap_active={wifi.radio.ap_active} ipv4={wifi.radio.ipv4_address_ap}")
Connecting...
connected in 0ns connected=True ipv4=192.168.6.198
Stopping STA...
connected=False ipv4=None
Connecting...
IPv4 in 0ns connected=True ipv4=192.168.6.198
Stopping STA...
connected=False ipv4=None
Starting AP...
ap_active=True ipv4=192.168.4.1
Fixes wifi.radio: provide "connected" and "access point is up" boolean properties #7377.
Add
wifi.Radio.connected
read-only property.Add
wifi.Radio.ap_active
read-only property.Rework some
wifi
documentation slightly.Tested on Pico W and Metro ESP32-S2.