1111
1212ssids = []
1313busy_scanning = False
14-
1514busy_connecting = False
1615
1716access_points = {}
@@ -67,7 +66,7 @@ def save_config():
6766
6867def scan_done_callback ():
6968 print ("scan_done_callback called" )
70- global busy_scanning , scan_button_label
69+ global busy_scanning , scan_button_label , scan_button
7170 refresh_list ()
7271 scan_button_label .set_text (scan_button_scan_text )
7372 scan_button .add_flag (lv .obj .FLAG .CLICKABLE )
@@ -104,14 +103,18 @@ def start_scan_networks():
104103
105104def attempt_connecting_done (ssid , result ):
106105 print (f"Connecting to { ssid } got result: { result } " )
107- global busy_connecting
106+ global busy_connecting , scan_button_label , scan_button
108107 refresh_list (ssid , result )
109108 busy_connecting = False
109+ scan_button_label .set_text (scan_button_scan_text )
110+ scan_button .add_flag (lv .obj .FLAG .CLICKABLE )
111+
110112
111113def attempt_connecting (ssid ,password ):
112114 print (f"attempt_connecting: Attempting to connect to SSID: { ssid } " )
113115 result = "connected"
114116 try :
117+ wlan .disconnect ()
115118 wlan .connect (ssid ,password )
116119 for i in range (10 ):
117120 if wlan .isconnected ():
@@ -124,12 +127,14 @@ def attempt_connecting(ssid,password):
124127 except Exception as e :
125128 print (f"attempt_connecting: Connection error: { e } " )
126129 result = f"{ e } "
127- show_error ("Connection failed" )
130+ show_error ("Connecting to {ssid} failed! " )
128131 attempt_connecting_done (ssid , result )
129132
130133def start_attempt_connecting (ssid ,password ):
131134 print (f"start_attempt_connecting: Attempting to connect to SSID: { ssid } " )
132- global busy_connecting
135+ global busy_connecting , scan_button_label , scan_button
136+ scan_button .remove_flag (lv .obj .FLAG .CLICKABLE )
137+ scan_button_label .set_text (f"Connecting to { ssid } ..." )
133138 if busy_connecting :
134139 print ("Not attempting connect because busy_connecting." )
135140 else :
@@ -274,7 +279,7 @@ def create_ui():
274279 global aplist ,appscreen ,error_label ,scan_button_label ,scan_button
275280 print ("create_ui: Creating list widget" )
276281 aplist = lv .list (appscreen )
277- aplist .set_size (lv .pct (100 ),180 )
282+ aplist .set_size (lv .pct (100 ),lv . pct ( 80 ) )
278283 aplist .align (lv .ALIGN .TOP_MID ,0 ,0 )
279284 print ("create_ui: Creating error label" )
280285 error_label = lv .label (appscreen )
@@ -283,7 +288,7 @@ def create_ui():
283288 error_label .add_flag (lv .obj .FLAG .HIDDEN )
284289 print ("create_ui: Creating Scan button" )
285290 scan_button = lv .button (appscreen )
286- scan_button .set_size (100 , 30 )
291+ scan_button .set_size (lv . SIZE_CONTENT , lv . pct ( 15 ) )
287292 scan_button .align (lv .ALIGN .BOTTOM_MID ,0 ,- 5 )
288293 scan_button_label = lv .label (scan_button )
289294 scan_button_label .set_text (scan_button_scan_text )
0 commit comments