Sun, 16 Mar 2025 12:53:12 +0100
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).
9828 | 1 | try: |
2 | from secrets import secrets | |
3 | ||
9890
66a6d3f131cc
Changed the MCU script to a pythonic naming.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9836
diff
changeset
|
4 | def connect_wifi(): |
9828 | 5 | import wifi |
6 | ||
9836 | 7 | print("Connecting WiFi to '{0}' ...".format(secrets["ssid"])) |
10153 | 8 | |
9 | if secrets["hostname"]: | |
10 | wifi.radio.hostname = secrets["hostname"] | |
11 | ||
9828 | 12 | wifi.radio.start_station() |
13 | try: | |
14 | wifi.radio.connect( | |
15 | secrets["ssid"], | |
16 | "" if secrets["password"] is None else secrets["password"] | |
17 | ) | |
18 | except Exception as exc: | |
19 | print("WiFi connection failed:", str(exc)) | |
20 | if wifi.radio.ipv4_address is None: | |
21 | print("WiFi connection failed") | |
22 | else: | |
23 | print("WiFi connected:", wifi.radio.ipv4_address) | |
24 | ||
9890
66a6d3f131cc
Changed the MCU script to a pythonic naming.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9836
diff
changeset
|
25 | connect_wifi() |
9828 | 26 | except ImportError: |
27 | print("WiFi secrets are kept in 'secrets.py', please add them there!") |