@@ -69,8 +69,8 @@ def onResume(self, screen):
6969 if not self .prefs :
7070 self .prefs = mpos .config .SharedPreferences ("com.micropythonos.system.wifiservice" )
7171
72- global access_points
73- access_points = self .prefs . get_dict ( " access_points" )
72+ self . access_points = self . prefs . get_dict ( " access_points" )
73+ print ( f"loaded access points from preferences: { self .access_points } " )
7474 if len (self .ssids ) == 0 :
7575 if WifiService .wifi_busy == False :
7676 WifiService .wifi_busy = True
@@ -128,7 +128,8 @@ def refresh_list(self):
128128 print ("refresh_list: Clearing current list" )
129129 self .aplist .clean () # this causes an issue with lost taps if an ssid is clicked that has been removed
130130 print ("refresh_list: Populating list with scanned networks" )
131- for ssid in self .ssids :
131+ self .ssids = list (set (self .ssids + list (ssid for ssid in self .access_points )))
132+ for ssid in set (self .ssids ):
132133 if len (ssid ) < 1 or len (ssid ) > 32 :
133134 print (f"Skipping too short or long SSID: { ssid } " )
134135 continue
@@ -143,7 +144,7 @@ def refresh_list(self):
143144 if status != "connected" :
144145 if self .last_tried_ssid == ssid : # implies not connected because not wlan.isconnected()
145146 status = self .last_tried_result
146- elif ssid in access_points :
147+ elif ssid in self . access_points :
147148 status = "saved"
148149 label = lv .label (button )
149150 label .set_text (status )
@@ -176,18 +177,20 @@ def edit_network_result_callback(self, result):
176177 forget = data .get ("forget" )
177178 if forget :
178179 try :
179- del access_points [ssid ]
180+ del self .access_points [ssid ]
181+ self .ssids .remove (ssid )
180182 editor .put_dict ("access_points" , self .access_points )
181183 editor .commit ()
182184 self .refresh_list ()
183185 except Exception as e :
184- print (f"Error when trying to forget access point, it might not have been remembered in the first place: { e } " )
186+ print (f"WARNING: could not forget access point, maybe it wasn't remembered in the first place: { e } " )
185187 else : # save or update
186188 password = data .get ("password" )
187189 hidden = data .get ("hidden" )
188190 self .setPassword (ssid , password , hidden )
189191 editor .put_dict ("access_points" , self .access_points )
190192 editor .commit ()
193+ print (f"access points: { self .access_points } " )
191194 self .start_attempt_connecting (ssid , password )
192195
193196 def start_attempt_connecting (self , ssid , password ):
0 commit comments