Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix network connection after soft-boot. #47

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions lib/aiko/net.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@ def set_status(color):
#
# Returns sta_if: Wi-Fi Station reference

def report_connected(sta_if):
global connected
print(W + "Connected: " + sta_if.ifconfig()[0])
common.log("WiFi connected: " + sta_if.ifconfig()[0])
connected = True
return sta_if

def wifi_connect(wifi):
global connected
sta_if = network.WLAN(network.STA_IF)
Expand All @@ -78,17 +85,13 @@ def wifi_connect(wifi):
sta_if.connect(ssid[0], ssid[1])
for retry in range(WIFI_CONNECTING_RETRY_LIMIT):
if sta_if.isconnected():
print(W + "Connected: " + sta_if.ifconfig()[0])
common.log("WiFi connected: " + sta_if.ifconfig()[0])
connected = True
wifi_configuration_update(wifi)
break # for retry
# print(W + "Waiting")
return report_connected(sta_if)
sleep_ms(WIFI_CONNECTING_CLIENT_PERIOD)
if sta_if.isconnected(): break # for ssid
print(W + "Timeout: Bad password ?")
common.log("Timeout: Bad password ?")
if sta_if.isconnected(): break # for ap
if sta_if.isconnected(): # ap or soft-reboot with WiFi enabled
return report_connected(sta_if)
return sta_if

def wifi_configuration_update(wifi):
Expand Down