--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/eric7/MicroPython/Devices/MCUScripts/circuitPy7WiFiConnect.py Tue Feb 28 17:54:33 2023 +0100 @@ -0,0 +1,22 @@ +try: + from secrets import secrets + + def connectWiFi(): + import wifi + + 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) + + connectWiFi() +except ImportError: + print("WiFi secrets are kept in 'secrets.py', please add them there!")