8000 Can't re-start wifi AP on Pico W · Issue #8718 · adafruit/circuitpython · GitHub
[go: up one dir, main page]

Skip to content
Can't re-start wifi AP on Pico W #8718
@anecdata

Description

@anecdata

CircuitPython version

Adafruit CircuitPython 9.0.0-alpha.6 on 2023-12-12; Raspberry Pi Pico W with rp2040

Code/REPL

import time
import os
import wifi
import traceback

AP_SSID = "Bob"
AP_PASSWORD = "YourUncle"
DELAY = 5

time.sleep(3)  # wait for serial
print("="*25)

# start clean
if wifi.radio.connected or wifi.radio.ipv4_address:
    wifi.radio.stop_station()
if wifi.radio.ap_active or wifi.radio.ipv4_address_ap:
    wifi.radio.stop_ap()
while True:
    print("Starting AP... ", end="")
    try:
        wifi.radio.start_ap(ssid=AP_SSID, password=AP_PASSWORD)
    except Exception as ex:
        traceback.print_exception(ex, ex, ex.__traceback__)
    time.sleep(0.1)
    print(f"{wifi.radio.ipv4_address_ap=}")
    time.sleep(DELAY)
    print("Stopping AP... ", end="")
    try:
        wifi.radio.stop_ap()
    except Exception as ex:
        traceback.print_exception(ex, ex, ex.__traceback__)
    time.sleep(0.1)
    print(f"{wifi.radio.ipv4_address_ap=}")
    time.sleep(DELAY)

Behavior

9.0.0-alpha.6 is the first release to have both #8590 and #8326, but there seems to be a regression. Under 8.2.8 and 8.2.9 (with 8590, but not with 8326), the code above runs fine. But under 9.0.0-alpha.6, I can't find a sequence that lets me start an AP a second time:

Adafruit CircuitPython 9.0.0-alpha.6 on 2023-12-12; Raspberry Pi Pico W with rp2040
>>> import microcontroller ; microcontroller.on_next_reset(microcontroller.RunMode.NORMAL) ; microcontroller.reset()

[17:19:41.986] Disconnected
[17:19:42.991] Warning: Could not open tty device (No such file or directory)
[17:19:42.991] Waiting for tty device..
[17:19:46.009] Connected
=========================
Starting AP... wifi.radio.ipv4_address_ap=192.168.4.1
Stopping AP... wifi.radio.ipv4_address_ap=None
Starting AP... Traceback (most recent call last):
  File "code.py", line 21, in <module>
RuntimeError: AP could not be started
wifi.radio.ipv4_address_ap=None

...ad infinitum

Description

No response

Additional information

Code runs fine on espressif, but note that a delay is needed after start_ap() for ipv4_address_ap to become active.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugnetworkrp2040Raspberry Pi RP2040third-partyAwaiting action on a third party for a fix or an answer to a request

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0