Skip to content

Commit 6892ccc

Browse files
committed
wifi ssid and psk edit
1 parent 88b0121 commit 6892ccc

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

audio.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def __init__(self):
6161
self.stream_in.start_stream()
6262
except:
6363
logging.info("Audio: input stream not available")
64-
64+
raise
6565
def exit(self):
6666
# cleanup stuff.
6767
self.stream_in.close()

main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
from config import Config
3434

3535
from flask import Flask, render_template, request, send_file, redirect, Response
36-
from flask.ext.babel import Babel
36+
from flask_babel import Babel
3737
#from flask_sockets import Sockets
3838

3939
logger = logging.getLogger()

wifi.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
class WiFi():
1515

1616
CONFIG_FILE = "/etc/coderbot_wifi.conf"
17-
adapters = ["RT5370", "RTL8188CUS"]
18-
hostapds = {"RT5370": "hostapd.RT5370", "RTL8188CUS": "hostapd.RTL8188"}
17+
adapters = ["default", "RT5370", "RTL8188CUS"]
18+
hostapds = {"default": "hostapd.conf", "RT5370": "hostapd.RT5370", "RTL8188CUS": "hostapd.RTL8188"}
1919
web_url = "http://coderbotsrv.appspot.com/register_ip"
2020
wifi_client_conf_file = "/etc/wpa_supplicant/wpa_supplicant.conf"
2121
_config = {}
@@ -98,6 +98,12 @@ def set_client_params(cls, wssid, wpsk):
9898
f.write(" psk=\""+wpsk+"\"\n")
9999
f.write("}")
100100

101+
@classmethod
102+
def set_ap_params(cls, wssid, wpsk):
103+
adapter = cls.get_adapter_type()
104+
out = os.system("sudo sed -i s/ssid=.*$/ssid=" + wssid + "/ /etc/hostapd/" + cls.hostapds.get(adapter))
105+
out = os.system("sudo sed -i s/wpa_passphrase=.*$/wpa_passphrase=" + wpsk + "/ /etc/hostapd/" + cls.hostapds.get(adapter))
106+
101107
@classmethod
102108
def set_start_as_client(cls):
103109
shutil.copy("/etc/network/interfaces_cli", "/etc/network/interfaces")
@@ -149,7 +155,8 @@ def main():
149155
if len(sys.argv) > 2 and sys.argv[1] == "updatecfg":
150156
if len(sys.argv) > 2 and sys.argv[2] == "ap":
151157
w.set_start_as_ap()
152-
#w.start_as_ap()
158+
if len(sys.argv) > 4:
159+
w.set_ap_params(sys.argv[3], sys.argv[4])
153160
elif len(sys.argv) > 2 and sys.argv[2] == "client":
154161
if len(sys.argv) > 3:
155162
w.set_client_params(sys.argv[3], sys.argv[4])

0 commit comments

Comments
 (0)