Skip to content

espressif auto-connect (web workflow) hard fault on reload after wifi.radio.enabled = False #8370

@anecdata

Description

@anecdata

CircuitPython version

Adafruit CircuitPython 8.2.4 on 2023-08-22; Adafruit QT Py ESP32-S3 no psram with ESP32S3

Code/REPL

import time
import os
import supervisor
import wifi

print(f"Connected={wifi.radio.connected} IP={wifi.radio.ipv4_address}")
if os.getenv("WIFI_SSID") and not wifi.radio.connected:
    print(f"Connecting...")
    wifi.radio.connect(os.getenv("WIFI_SSID"), os.getenv("WIFI_PASSWORD"))
print(f"Connected={wifi.radio.connected} IP={wifi.radio.ipv4_address}")

# espressif: hard fault on 2nd run if web workflow is enabled
# raspberrypi: can't test, wifi.radio.enabled not fully implemented
wifi.radio.enabled = False
#
# or
#
# espressif: OK* on successive runs regardless of web workflow
# raspberrypi: OK on successive runs
# wifi.radio.stop_station()

# *when using wifi.radio.stop_station()
#   wifi.radio.ipv4_address=None will lag slightly to wifi.radio.connected=False (code.py, but not REPL)
#   Connected=False IP=0.0.0.0
#   or
#   Connected=False IP=192.168.6.210
print(f"Connected={wifi.radio.connected} IP={wifi.radio.ipv4_address}")
while wifi.radio.ipv4_address:
    print(".", end="")
print(f"Connected={wifi.radio.connected} IP={wifi.radio.ipv4_address}")
time.sleep(1)
supervisor.reload()

Behavior

After 1st reload, if web workflow auto-connect is enabled, when using wifi.radio.enabled = False:

Auto-reload is off.
Running in safe mode! Not running saved code.

You are in safe mode because:
CircuitPython core code crashed hard. Whoops!
Hard fault: memory access or instruction error.
Please file an issue with your program at github.com/adafruit/circuitpython/issues.
Press reset to exit safe mode.

Description

No response

Additional information

Also:
When using the commented-out scenario to disconnect wifi (wifi.radio.stop_station() instead of wifi.radio.enabled = False), it doesn't hard fault but wifi.radio.ipv4_address changing to None will slightly lag wifi.radio.connected changing to False. This occurs when running the code in code.py, but not when using REPL paste mode. Output immdiately after wifi.radio.stop_station() is typicallly:

Connected=False IP=0.0.0.0

or

Connected=False IP=192.168.6.210

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions