Skip to content

Commit 4366c40

Browse files
committed
Merge branch 'develop'
2 parents 5f98ca9 + ecba4dc commit 4366c40

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

audioControls.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ def get_instance(cls):
3939
return cls._instance
4040

4141
def __init__(self):
42-
self.mixer = alsaaudio.Mixer('PCM', cardindex=1)
43-
#self.mixer = alsaaudio.PCM(device='numid=1', cardindex=1)
42+
self.mixer = alsaaudio.Mixer('Headphone')
4443

4544
def getVolume(self):
4645
print(self.mixer.getvolume())

main.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,9 @@ def handle_wifi():
192192
psk = request.form.get("wifi_psk")
193193

194194
logging.info("mode " + mode +" ssid: " + ssid + " psk: " + psk)
195-
client_params = " \"" + ssid + "\" \"" + psk + "\"" if ssid != "" and psk != "" else ""
195+
client_params = " --ssid \"" + ssid + "\" --pwd \"" + psk + "\"" if ssid != "" and psk != "" else ""
196196
logging.info(client_params)
197-
os.system("sudo ./wifi.py updatecfg " + mode + client_params)
197+
os.system("sudo ./wifi.py updatecfg --mode " + mode + client_params)
198198
os.system("sudo reboot")
199199
if mode == "ap":
200200
return "http://coder.bot"

wifi.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def get_ipaddr(cls, ifname):
9191
return socket.inet_ntoa(fcntl.ioctl(
9292
s.fileno(),
9393
0x8915, # SIOCGIFADDR
94-
struct.pack('256s', ifname[:15])
94+
struct.pack('256s', ifname.encode('utf-8')[:15])
9595
)[20:24])
9696

9797
@classmethod
@@ -153,7 +153,11 @@ def start_as_client(cls):
153153
time.sleep(1.0)
154154
out = os.system("wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf > /dev/null 2>&1")
155155
out += os.system("dhclient -1 wlan0")
156-
print(out)
156+
print("start_as_client: " + str(out))
157+
ipaddr = cls.get_ipaddr("wlan0")
158+
if ipaddr is None or "169.254" in ipaddr:
159+
os.system("sudo pkill wpa_supplicant")
160+
raise Exception()
157161
try:
158162
cls.register_ipaddr(cls.get_macaddr("wlan0"), cls.get_config().get('bot_name', 'CoderBot'), cls.get_ipaddr("wlan0"), "[email protected]")
159163
print("registered bot, ip: " + str(cls.get_ipaddr("wlan0") + " name: " + cls.get_config().get('bot_name', 'CoderBot')))
@@ -175,7 +179,7 @@ def start_as_ap(cls):
175179
out += str(subprocess.check_output(["ip", "a", "add", "10.0.0.1/24", "dev", "wlan0"]))
176180
out += str(subprocess.check_output(["ip", "link", "set", "dev", "wlan0", "up"]))
177181
out += str(subprocess.check_output(["ifconfig"]))
178-
print(out)
182+
print("start_as_ap: " + str(out))
179183
cls.start_hostapd()
180184
cls.start_dnsmasq()
181185

0 commit comments

Comments
 (0)