Skip to content

Commit 620f544

Browse files
committed
Fixed opening secrets.json bug
1 parent 75ecbd5 commit 620f544

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
.vscode/
2-
.git/
2+
.git/
3+
4+
secrets.json

Examples/webserver_example.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,14 @@ def log_time_and_range():
3333
timer = Timer(-1)
3434
timer.init(freq=4, mode=Timer.PERIODIC, callback=lambda t: log_time_and_range())
3535

36-
def connect_and_start_webserver(ssid, password, robot_id):
36+
def connect_and_start_webserver():
3737
# Connect to the network and start the webserver in bridge mode
38-
webserver.connect_to_network(ssid, password, robot_id)
38+
# Network ssid and password are stored in root/secrets.json
39+
webserver.connect_to_network()
3940
webserver.start_server()
4041

41-
def start_network_and_webserver(robot_id):
42+
def start_network_and_webserver():
4243
# Start the webserver in access point mode
43-
webserver.start_network(robot_id)
44+
# Network ssid and password are stored in root/secrets.json
45+
webserver.start_network()
4446
webserver.start_server()

XRPLib/webserver.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ def start_network(self, ssid:str=None, robot_id:int= None, password:str=None):
4545
:type password: str, optional
4646
"""
4747
if ssid is None:
48-
with open("../secrets.json") as secrets_file:
48+
with open("../../secrets.json") as secrets_file:
4949
secrets = json.load(secrets_file)
5050
ssid = secrets["ap_ssid"]
5151
password = secrets["ap_password"]
5252
if robot_id is None:
5353
robot_id = secrets["robot_id"]
54-
ssid.replace("{robot_id}", robot_id)
54+
ssid = ssid.replace("{robot_id}", str(robot_id))
5555
self.access_point = access_point(ssid, password)
5656
self.ip = network.WLAN(network.AP_IF).ifconfig()[0]
5757

@@ -70,7 +70,7 @@ def connect_to_network(self, ssid:str=None, password:str=None, timeout = 10):
7070
self.wlan = network.WLAN(network.STA_IF)
7171
self.wlan.active(True) # configure board to connect to wifi
7272
if ssid is None:
73-
with open("../secrets.json") as secrets_file:
73+
with open("../../secrets.json") as secrets_file:
7474
secrets = json.load(secrets_file)
7575
ssid = secrets["wifi_ssid"]
7676
password = secrets["wifi_password"]

0 commit comments

Comments
 (0)