Skip to content
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
25 changes: 23 additions & 2 deletions host/root/scripts/wifi_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import sys
import time
import threading
import socket

# usb or sd card
user_dir = os.getenv("USER_DIR", "/usbdrive")
Expand Down Expand Up @@ -60,7 +61,7 @@ def update_menu():
try :
# update wifi network labels
if (wifi.state == wifi.CONNECTING) :
menu.header = 'Connecting'+dots[wifi.connecting_timer % 4]
menu.header = 'Connecting' + dots[wifi.connecting_timer % 4]
update_net_status_label('.')
elif (wifi.state == wifi.CONNECTED) :
menu.header = 'Connected ' + wifi.current_net
Expand All @@ -81,6 +82,13 @@ def update_menu():
else :
update_web_server_menu_entry(False)

# update ip address entry
if (wifi.state == wifi.CONNECTED) :
ip_address = socket.gethostbyname(socket.gethostname())
update_ip_address_entry(ip_address)
else :
update_ip_address_entry(False)

finally :
menu_lock.release()

Expand Down Expand Up @@ -112,6 +120,18 @@ def update_web_server_menu_entry(stat):
except :
pass

def update_ip_address_entry(stat):
if (stat) :
label = 'IP: ' + stat
else :
label = 'IP: (None)'
for i in range(len(menu.items)) :
try :
if (menu.items[i][2]['type'] == 'ip_address') :
menu.items[i][0] = label
except :
pass

# bg connection checker
def check_status():
while True:
Expand Down Expand Up @@ -168,8 +188,9 @@ def error_wifi_file() :
error_wifi_file()
print "bad wifi file"

menu.items.append(['IP: ', non, {'type':'ip_address'}])
menu.items.append(['Start Web Server', non, {'type':'web_server_control'}])
menu.items.append(['Turn Wifi Off', disconnect])
menu.items.append(['Turn WiFi Off', disconnect])
menu.items.append(['< Home', quit])
menu.selection = 0

Expand Down