You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importtimeimportwifiimportosimporttracebackimportmicrocontrollerimportsupervisortime.sleep(3)
whileTrue:
try:
print(f"starting station...", end=" ")
wifi.radio.start_station()
whilenotwifi.radio.connected:
wifi.radio.connect(os.getenv("WIFI_SSID"), os.getenv("WIFI_PASSWORD"))
print(f"connected={wifi.radio.connected}{wifi.radio.ipv4_address}")
print(f"stopping station...")
wifi.radio.stop_station() # no delay between stop station stop and start APwifi.radio.start_ap('test', 'lksdfjhksdfjlsdfjgh')
print(f"ap_active={wifi.radio.ap_active}{wifi.radio.ipv4_address_ap}")
time.sleep(5)
microcontroller.reset()
exceptExceptionasex:
print(f"")
traceback.print_exception(ex, ex, ex.__traceback__)
Behavior
This arose on Discord (https://discord.com/channels/327254708534116352/537365702651150357/1100202386905112576 or discord://discord.com/channels/327254708534116352/537365702651150357/1100202386905112576). About 10% of the time, wifi.radio.start_ap() will fail with RuntimeError: Wifi is in station mode. if it immediately follows wifi.radio.stop_station().
do not exhibit any timing issues. Only when switching from Station to AP.
Addendum: Pico W starts up in Station mode. Even if it never connects to an AP, this can still happen. In that case, it doesn't make sense to check wifi.radio.connected, so a time delay may be the only workaround.
The text was updated successfully, but these errors were encountered:
That makes sense. If the delay is known, the code can wait. It could also poll some status itself and return quicker if it has stopped, but that may not be possible. It shouldn't poll indefinitely in case the status is never satisfied.
CircuitPython version
Code/REPL
Behavior
This arose on Discord (https://discord.com/channels/327254708534116352/537365702651150357/1100202386905112576 or discord://discord.com/channels/327254708534116352/537365702651150357/1100202386905112576). About 10% of the time,
wifi.radio.start_ap()
will fail withRuntimeError: Wifi is in station mode.
if it immediately followswifi.radio.stop_station()
.A small time delay, or:
seems to suffice to let start_ap() succeed consistently.
Is this the solution, or could
wifi.radio.stop_station()
not return until the station is fully stopped?Description
No response
Additional information
Station-only loops like:
or
do not exhibit any timing issues. Only when switching from Station to AP.
Addendum: Pico W starts up in Station mode. Even if it never connects to an AP, this can still happen. In that case, it doesn't make sense to check
wifi.radio.connected
, so a time delay may be the only workaround.The text was updated successfully, but these errors were encountered: