@@ -128,12 +128,21 @@ def network_changed(self, online):
128128 elif self .current_state == UpdateState .IDLE or self .current_state == UpdateState .CHECKING_UPDATE :
129129 # Was checking for updates when network dropped
130130 self .set_state (UpdateState .WAITING_WIFI )
131+ elif self .current_state == UpdateState .ERROR :
132+ # Was in error state, might be network-related
133+ # Update UI to show we're waiting for network
134+ self .set_state (UpdateState .WAITING_WIFI )
131135 else :
132136 # Went online
133137 if self .current_state == UpdateState .IDLE or self .current_state == UpdateState .WAITING_WIFI :
134138 # Was waiting for network, now can check for updates
135139 self .set_state (UpdateState .CHECKING_UPDATE )
136140 self .schedule_show_update_info ()
141+ elif self .current_state == UpdateState .ERROR :
142+ # Was in error state (possibly network error), retry now that network is back
143+ print ("OSUpdate: Retrying update check after network came back online" )
144+ self .set_state (UpdateState .CHECKING_UPDATE )
145+ self .schedule_show_update_info ()
137146 elif self .current_state == UpdateState .DOWNLOAD_PAUSED :
138147 # Download was paused, will auto-resume in download thread
139148 pass
@@ -193,7 +202,7 @@ def show_update_info(self, timer=None):
193202 update_info ["changelog" ]
194203 )
195204 except ValueError as e :
196- # JSON parsing or validation error
205+ # JSON parsing or validation error (not network related)
197206 self .set_state (UpdateState .ERROR )
198207 self .status_label .set_text (self ._get_user_friendly_error (e ))
199208 except RuntimeError as e :
@@ -202,9 +211,15 @@ def show_update_info(self, timer=None):
202211 self .status_label .set_text (self ._get_user_friendly_error (e ))
203212 except Exception as e :
204213 print (f"show_update_info got exception: { e } " )
205- # Unexpected error
206- self .set_state (UpdateState .ERROR )
207- self .status_label .set_text (self ._get_user_friendly_error (e ))
214+ # Check if this is a network connectivity error
215+ if self .update_downloader ._is_network_error (e ):
216+ # Network not available - wait for it to come back
217+ print ("OSUpdate: Network error while checking for updates, waiting for WiFi" )
218+ self .set_state (UpdateState .WAITING_WIFI )
219+ else :
220+ # Other unexpected error
221+ self .set_state (UpdateState .ERROR )
222+ self .status_label .set_text (self ._get_user_friendly_error (e ))
208223
209224 def handle_update_info (self , version , download_url , changelog ):
210225 self .download_update_url = download_url
@@ -286,7 +301,7 @@ def update_with_lvgl(self, url):
286301 # Update succeeded - set boot partition and restart
287302 self .update_ui_threadsafe_if_foreground (self .status_label .set_text ,"Update finished! Restarting..." )
288303 # Small delay to show the message
289- time .sleep_ms ( 2000 )
304+ time .sleep ( 5 )
290305 self .update_downloader .set_boot_partition_and_restart ()
291306 return
292307
0 commit comments