src/eric7/MicroPython/Devices/MCUScripts/circuitPy7WiFiConnect.py

Sun, 16 Mar 2025 12:53:12 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 16 Mar 2025 12:53:12 +0100
branch
eric7
changeset 11170
6d6199d668fb
parent 10153
ffe7432f716b
permissions
-rw-r--r--

Added the Adafruit Feather nRF52840 to the list of known NRF52 boards and changed the list of known CircuitPython boards to be more explicit with respect to Adafruit boards (i.e. VID 0x239A).

try:
    from secrets import secrets

    def connect_wifi():
        import wifi

        print("Connecting WiFi to '{0}' ...".format(secrets["ssid"]))

        if secrets["hostname"]:
            wifi.radio.hostname = secrets["hostname"]

        wifi.radio.start_station()
        try:
            wifi.radio.connect(
                secrets["ssid"],
                "" if secrets["password"] is None else secrets["password"]
            )
        except Exception as exc:
            print("WiFi connection failed:", str(exc))
        if wifi.radio.ipv4_address is None:
            print("WiFi connection failed")
        else:
            print("WiFi connected:", wifi.radio.ipv4_address)

    connect_wifi()
except ImportError:
    print("WiFi secrets are kept in 'secrets.py', please add them there!")

eric ide

mercurial