88
99import mpos .config
1010import mpos .ui .anim
11+ import mpos .wifi
1112
1213have_network = True
1314try :
@@ -46,8 +47,8 @@ def onCreate(self):
4647 self .aplist .align (lv .ALIGN .TOP_MID ,0 ,0 )
4748 print ("create_ui: Creating error label" )
4849 self .error_label = lv .label (main_screen )
49- self .error_label .set_text ("" )
50- self .error_label .align ( lv .ALIGN .BOTTOM_MID ,0 ,- 40 )
50+ self .error_label .set_text ("THIS IS ERROR TEXT THAT WILL BE SET LATER " )
51+ self .error_label .align_to ( self . aplist , lv .ALIGN .OUT_BOTTOM_MID ,0 ,0 )
5152 self .error_label .add_flag (lv .obj .FLAG .HIDDEN )
5253 print ("create_ui: Creating Scan button" )
5354 self .scan_button = lv .button (main_screen )
@@ -63,8 +64,12 @@ def onResume(self, screen):
6364 global access_points
6465 access_points = mpos .config .SharedPreferences ("com.micropythonos.system.wifiservice" ).get_dict ("access_points" )
6566 self .keep_running = True
66- if len (self .ssids ) == 0 :
67- self .start_scan_networks ()
67+ if mpos .wifi .WifiService .wifi_busy == False :
68+ mpos .wifi .WifiService .wifi_busy = True
69+ if len (self .ssids ) == 0 :
70+ self .start_scan_networks ()
71+ else :
72+ self .show_error ("Wifi is busy, please try again later." )
6873
6974 def onStop (self , screen ):
7075 self .keep_running = False
@@ -75,7 +80,7 @@ def show_error(self, message):
7580 print (f"show_error: Displaying error: { message } " )
7681 lv .async_call (lambda l : self .error_label .set_text (message ), None )
7782 lv .async_call (lambda l : self .error_label .remove_flag (lv .obj .FLAG .HIDDEN ), None )
78- timer = lv .timer_create (lambda t : self .error_label .add_flag (lv .obj .FLAG .HIDDEN ),3000 ,None )
83+ timer = lv .timer_create (lambda t : self .error_label .add_flag (lv .obj .FLAG .HIDDEN ),5000 ,None )
7984 timer .set_repeat_count (1 )
8085
8186 def scan_networks_thread (self ):
@@ -99,6 +104,7 @@ def scan_networks_thread(self):
99104 self .show_error ("Wi-Fi scan failed" )
100105 # scan done:
101106 self .busy_scanning = False
107+ mpos .wifi .WifiService .wifi_busy = False
102108 if self .keep_running :
103109 # Schedule UI updates because different thread
104110 lv .async_call (lambda l : self .scan_button_label .set_text (self .scan_button_scan_text ), None )
@@ -147,7 +153,7 @@ def refresh_list(self):
147153 def scan_cb (self , event ):
148154 print ("scan_cb: Scan button clicked, refreshing list" )
149155 self .start_scan_networks ()
150-
156+
151157 def select_ssid_cb (self ,ssid ):
152158 print (f"select_ssid_cb: SSID selected: { ssid } " )
153159 intent = Intent (activity_class = PasswordPage )
0 commit comments