From b5a743d895b08244329647f3eb9d34611620a087 Mon Sep 17 00:00:00 2001 From: David Todd Date: Sun, 26 Jan 2020 19:18:42 -0600 Subject: [PATCH] Had to define connect first --- pixo/wifi.py | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/pixo/wifi.py b/pixo/wifi.py index b17edc3..78432c9 100644 --- a/pixo/wifi.py +++ b/pixo/wifi.py @@ -14,23 +14,6 @@ MAX_WAIT = 5 STA_IF = network.WLAN(network.STA_IF) AP_IF = network.WLAN(network.AP_IF) -# TODO: iterate over known access points and save multiple passwords -if not STA_IF.isconnected(): - connect(STA_IF, 'Standard') - -# We check this twice to enable AP mode if we failed to connect -# Normally this happens if the password has been misconfigured, -# or if the device moves to a different location (more likely) -if not STA_IF.isconnected(): - # Disable STA_IF to stop serial spam - # You can enable it again by doing `import wifi` - # Followed by `wifi.STA_IF.active(True)` - Then you can call the `wifi.connect_standard` - # method to try connecting again (after `creds.py` has been fixed) - STA_IF.active(False) - - connect(AP_IF, 'Access Point') - - def connect(interface, interface_name): print("Configuring %s interface with credentials from creds.py" % interface_name) start_time = time.time() @@ -53,4 +36,20 @@ def connect(interface, interface_name): break if interface.isconnected(): - Pixo().fill_image(WIFI_IMG, False).force_color((40, 200, 40)) \ No newline at end of file + Pixo().fill_image(WIFI_IMG, False).force_color((40, 200, 40)) + +# TODO: iterate over known access points and save multiple passwords +if not STA_IF.isconnected(): + connect(STA_IF, 'Standard') + +# We check this twice to enable AP mode if we failed to connect +# Normally this happens if the password has been misconfigured, +# or if the device moves to a different location (more likely) +if not STA_IF.isconnected(): + # Disable STA_IF to stop serial spam + # You can enable it again by doing `import wifi` + # Followed by `wifi.STA_IF.active(True)` - Then you can call the `wifi.connect_standard` + # method to try connecting again (after `creds.py` has been fixed) + STA_IF.active(False) + + connect(AP_IF, 'Access Point') \ No newline at end of file