@@ -42,7 +42,7 @@ def check_rpi_model():
4242 print ('stored_model' , stored_model )
4343 if current_model != stored_model :
4444 usb4vc_ui .oled_print_model_changed ()
45- for x in range (50 ):
45+ for x in range (20 ):
4646 print ("!!!!!!!!!! DO NOT UNPLUG UNTIL I REBOOT !!!!!!!!!!" )
4747 print ("!!!!!!!!!! DO NOT UNPLUG UNTIL I REBOOT !!!!!!!!!!" )
4848 print ("!!!!!!!!!! DO NOT UNPLUG UNTIL I REBOOT !!!!!!!!!!" )
@@ -56,54 +56,8 @@ def check_rpi_model():
5656 os .system ('sudo reboot' )
5757 time .sleep (10 )
5858
59- def update_wifi_credentials ():
60- config_file_path = '/etc/wpa_supplicant/wpa_supplicant.conf'
61- if os .path .isfile (config_file_path ) is False :
62- print ('update_wifi_credentials: system config file not found' )
63- return
64- new_wifi_info_path = "/home/pi/usb4vc/config/wifi_info.json"
65- if os .path .isfile (new_wifi_info_path ) is False :
66- print ('update_wifi_credentials: user wifi info file not found' )
67- return
68-
69- with open (new_wifi_info_path ) as json_file :
70- wifi_dict = json .load (json_file )
71-
72- config_str = f"""
73- ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
74- update_config=1
75- country={ wifi_dict ['wifi_country_code' ]}
76-
77- network={{
78- ssid="{ wifi_dict ['wifi_name' ]} "
79- psk="{ wifi_dict ['wifi_password' ]} "
80- }}
81- """
82-
83- config_str_unsecured = f"""
84- ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
85- update_config=1
86- country={ wifi_dict ['wifi_country_code' ]}
87-
88- network={{
89- ssid="{ wifi_dict ['wifi_name' ]} "
90- key_mgmt=NONE
91- }}
92- """
93- to_write = config_str
94- if len (wifi_dict ['wifi_password' ]) == 0 :
95- to_write = config_str_unsecured
96- with open (config_file_path , 'w' ) as wifi_config_file :
97- wifi_config_file .write (to_write )
98- os .system ("wpa_cli -i wlan0 reconfigure" )
99-
10059check_rpi_model ()
10160
102- try :
103- update_wifi_credentials ()
104- except Exception as e :
105- print ('update_wifi_credentials exception:' , e )
106-
10761usb4vc_ui .ui_init ()
10862usb4vc_ui .ui_thread .start ()
10963
0 commit comments