@@ -344,7 +344,7 @@ def redraw_payments_cb():
344344 payments_label .set_text (str (wallet .payment_list ))
345345
346346def janitor_cb (timer ):
347- global wallet , config , receive_qr_data
347+ global wallet , config , receive_qr_data , payments_label
348348 if lv .screen_active () == main_screen and (not wallet or not wallet .is_running ()): # just started the app or just returned from settings_screen
349349 main_ui_set_defaults ()
350350 config = mpos .config .SharedPreferences ("com.lightningpiggy.displaywallet" )
@@ -354,23 +354,31 @@ def janitor_cb(timer):
354354 receive_qr_data = config .get_string ("lnbits_static_receive_code" )
355355 wallet = LNBitsWallet (config .get_string ("lnbits_url" ), config .get_string ("lnbits_readkey" ))
356356 except Exception as e :
357- print (f"Couldn't initialize LNBitsWallet because: { e } " )
357+ payments_label . set_text (f"Couldn't initialize LNBitsWallet because: { e } " )
358358 elif wallet_type == "nwc" :
359359 try :
360360 wallet = NWCWallet (config .get_string ("nwc_url" ))
361361 receive_qr_data = wallet .lud16
362362 except Exception as e :
363- print (f"Couldn't initialize NWCWallet because: { e } " )
363+ payments_label . set_text (f"Couldn't initialize NWCWallet because: { e } " )
364364 else :
365- print (f"No or unsupported wallet type configured: '{ wallet_type } '" )
365+ payments_label . set_text (f"No or unsupported wallet type configured: '{ wallet_type } '" )
366366 if receive_qr_data :
367367 print (f"Setting static_receive_code: { receive_qr_data } " )
368368 receive_qr .update (receive_qr_data , len (receive_qr_data ))
369- if wallet :
370- print ("Starting wallet..." )
371- wallet .start (redraw_balance_cb , redraw_payments_cb )
369+ can_check_network = True
370+ try :
371+ import network
372+ except Exception as e :
373+ can_check_network = False
374+ if can_check_network and not network .WLAN (network .STA_IF ).isconnected ():
375+ payments_label .set_text ("WiFi is not connected,\n can't talk to {wallet_type} wallet backend..." )
372376 else :
373- print ("ERROR: could not start any wallet!" ) # maybe call the error callback to show the error to the user
377+ if wallet :
378+ payments_label .set_text ("Connecting to {wallet_type} wallet backend..." )
379+ wallet .start (redraw_balance_cb , redraw_payments_cb )
380+ else :
381+ payments_label .set_text ("Could not start {wallet_type} wallet backend." )
374382 elif lv .screen_active () != main_screen and lv .screen_active () != settings_screen and lv .screen_active () != qr_screen and lv .screen_active () != settings_screen_detail and lv .screen_active () != qr_scanner_screen :
375383 print ("app backgrounded, cleaning up..." )
376384 janitor .delete ()
0 commit comments