Skip to content

Commit 3755df6

Browse files
committed
updated clean OS setup notes, removed redundant wifi parsing
1 parent a80bc80 commit 3755df6

File tree

5 files changed

+79
-63
lines changed

5 files changed

+79
-63
lines changed

user_program/login.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
ssh pi@192.168.1.62
1+
ssh pi@169.254.194.124

user_program/old/temp.py

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,57 @@
1+
-----------
2+
3+
4+
def update_wifi_credentials():
5+
config_file_path = '/etc/wpa_supplicant/wpa_supplicant.conf'
6+
if os.path.isfile(config_file_path) is False:
7+
print('update_wifi_credentials: system config file not found')
8+
return
9+
new_wifi_info_path = "/home/pi/usb4vc/config/wifi_info.json"
10+
if os.path.isfile(new_wifi_info_path) is False:
11+
print('update_wifi_credentials: user wifi info file not found')
12+
return
13+
14+
with open(new_wifi_info_path) as json_file:
15+
wifi_dict = json.load(json_file)
16+
17+
config_str = f"""
18+
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
19+
update_config=1
20+
country={wifi_dict['wifi_country_code']}
21+
22+
network={{
23+
ssid="{wifi_dict['wifi_name']}"
24+
psk="{wifi_dict['wifi_password']}"
25+
}}
26+
"""
27+
28+
config_str_unsecured = f"""
29+
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
30+
update_config=1
31+
country={wifi_dict['wifi_country_code']}
32+
33+
network={{
34+
ssid="{wifi_dict['wifi_name']}"
35+
key_mgmt=NONE
36+
}}
37+
"""
38+
to_write = config_str
39+
if len(wifi_dict['wifi_password']) == 0:
40+
to_write = config_str_unsecured
41+
with open(config_file_path, 'w') as wifi_config_file:
42+
wifi_config_file.write(to_write)
43+
os.system("wpa_cli -i wlan0 reconfigure")
44+
45+
check_rpi_model()
46+
47+
try:
48+
update_wifi_credentials()
49+
except Exception as e:
50+
print('update_wifi_credentials exception:', e)
51+
52+
-------------------
53+
54+
155
custom_name_to_ev_codename(usb4vc_gamepads.xbox_one_to_linux_ev_code_dict, )
256

357
def custom_name_to_ev_codename(lookup_dict, button_name):

user_program/setup.txt

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -74,20 +74,6 @@ sudo nano /boot/cmdline.txt
7474

7575
Add quiet after rootwait
7676

77-
raspberry pi 3
78-
before speedup:
79-
80-
19.16
81-
18.07
82-
19.11
83-
18.37
84-
85-
86-
after speedup:
87-
88-
16.95
89-
16.45
90-
9177
-------------
9278

9379
usb auto mount:
@@ -100,6 +86,15 @@ change to PrivateMounts=no
10086

10187
-----------
10288

89+
zero out free space to compress better:
90+
91+
cat /dev/zero > ./zero.file
92+
wait until it exits
93+
sync
94+
rm zero.file
95+
96+
-----------
97+
10398
usb folder format:
10499

105100
usb root:
@@ -116,6 +111,19 @@ usb4vc_data
116111

117112
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx NO LONGER NEEDED xxxxxxxxxxxxxxxxxxxxxxxx
118113

114+
raspberry pi 3
115+
before speedup:
116+
117+
19.16
118+
18.07
119+
19.11
120+
18.37
121+
122+
123+
after speedup:
124+
125+
16.95
126+
16.45
119127
--------------
120128
Nintendo Pro controller
121129
https://retropie.org.uk/docs/Nintendo-Switch-Controllers/

user_program/sync.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
# sh sync.sh; ssh -t [email protected] "pkill python3;cd ~/usb4vc/rpi_app;python3 usb4vc_main.py"
44

55
scp ./* [email protected]:~/usb4vc/rpi_app
6-
# ssh -t [email protected] "pkill python3;cd ~/usb4vc/rpi_app;python3 usb4vc_main.py"
6+
ssh -t [email protected] "pkill python3;cd ~/usb4vc/rpi_app;python3 usb4vc_main.py"
77
# ssh -t [email protected] "pkill python3;cd ~/usb4vc/rpi_app;python3 firmware_flasher.py /home/pi/usb4vc/firmware/PBFW_IBMPC_PBID1_V0_1_5.hex"
88
# ssh -t [email protected] "pkill python3;cd ~/usb4vc/rpi_app;python3 bb_tester.py"

user_program/usb4vc_main.py

Lines changed: 1 addition & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -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-
10059
check_rpi_model()
10160

102-
try:
103-
update_wifi_credentials()
104-
except Exception as e:
105-
print('update_wifi_credentials exception:', e)
106-
10761
usb4vc_ui.ui_init()
10862
usb4vc_ui.ui_thread.start()
10963

0 commit comments

Comments
 (0)