File tree Expand file tree Collapse file tree 2 files changed +9
-11
lines changed Expand file tree Collapse file tree 2 files changed +9
-11
lines changed Original file line number Diff line number Diff line change @@ -461,11 +461,12 @@ def remove_doreset_file():
461
461
pass
462
462
463
463
def align_wifi_config ():
464
- out = os .popen ("sudo ./wifi.py getcfg --ssid" ).read ()
465
- if "coderbot_" in out :
466
- app .bot_config ["wifi_ssid" ] = out .split ()[0 ]
467
- Config .write (app .bot_config )
468
- app .bot_config = Config .get ()
464
+ if app .bot_config ["wifi_ssid" ] == "coderbot_CHANGEATFIRSTRUN" :
465
+ out = os .popen ("sudo ./wifi.py getcfg --ssid" ).read ()
466
+ if "coderbot_" in out :
467
+ app .bot_config ["wifi_ssid" ] = out .split ()[0 ]
468
+ Config .write (app .bot_config )
469
+ app .bot_config = Config .get ()
469
470
470
471
# Finally, get the server running
471
472
def run_server ():
@@ -476,7 +477,7 @@ def run_server():
476
477
app .bot_config = Config .read ()
477
478
align_wifi_config ()
478
479
bot = CoderBot .get_instance (motor_trim_factor = float (app .bot_config .get ('move_motor_trim' , 1.0 )),
479
- encoder = bool ( app .bot_config .get ('encoder' )), encoder = bool ( app . bot_config . get ( 'encoder' ) ))
480
+ hw_version = app .bot_config .get ('hardware_version' ))
480
481
audio = Audio .get_instance ()
481
482
audio .say (app .bot_config .get ("sound_start" ))
482
483
Original file line number Diff line number Diff line change @@ -148,6 +148,7 @@ def get_ap_params(cls):
148
148
@classmethod
149
149
def set_start_as_client (cls ):
150
150
cls ._config ["wifi_mode" ] = "client"
151
+ os .system ("sudo sed -i s/^disabled_network=/network=/ /etc/wpa_supplicant/wpa_supplicant.conf" )
151
152
cls .save_config ()
152
153
153
154
@classmethod
@@ -157,13 +158,8 @@ def set_bot_name(cls, name):
157
158
158
159
@classmethod
159
160
def start_as_client (cls ):
160
- cls .stop_dnsmasq ()
161
- cls .stop_hostapd ()
162
161
try :
163
162
time .sleep (1.0 )
164
- out = os .system ("wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf > /dev/null 2>&1" )
165
- out += os .system ("dhclient -1 wlan0" )
166
- print ("start_as_client: " + str (out ))
167
163
ipaddr = cls .get_ipaddr ("wlan0" )
168
164
if ipaddr is None or "169.254" in ipaddr :
169
165
os .system ("sudo pkill wpa_supplicant" )
@@ -180,6 +176,7 @@ def start_as_client(cls):
180
176
@classmethod
181
177
def set_start_as_ap (cls ):
182
178
cls ._config ["wifi_mode" ] = "ap"
179
+ os .system ("sudo sed -i s/^network=/disabled_network=/ /etc/wpa_supplicant/wpa_supplicant.conf" )
183
180
cls .save_config ()
184
181
185
182
@classmethod
You can’t perform that action at this time.
0 commit comments