Skip to content

Commit 5e40995

Browse files
committed
Working webserver in both modes
1 parent 7edeecd commit 5e40995

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

Examples/webserver_example.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,12 @@ 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-
webserver.start_server(1)
36+
def connect_and_start_webserver(ssid, password, robot_id):
37+
# Connect to the network and start the webserver in bridge mode
38+
webserver.connect_to_network(ssid, password, robot_id)
39+
webserver.start_server()
40+
41+
def start_network_and_webserver(robot_id):
42+
# Start the webserver in access point mode
43+
webserver.start_network(robot_id)
44+
webserver.start_server()

XRPLib/webserver.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ def __init__(self):
2020
"""
2121

2222
gc.threshold(50000) # garbage collection
23-
self.DOMAIN = "remote.xrp"
2423
self.logged_data = {}
2524
self.buttons = {"forwardButton": lambda: logging.debug("Button not initialized"),
2625
"backButton": lambda: logging.debug("Button not initialized"),
@@ -58,7 +57,9 @@ def connect_to_network(self, ssid:str, password:str, robot_id:int, timeout = 10)
5857

5958
def start_server(self):
6059
"""
61-
Begin the webserver on whatever network is configured, at the ip 'remote.xrp'
60+
Begin the webserver in either access point or bridge mode. The IP is printed to the console.
61+
62+
Preconditions: Either start_network or connect_to_network must be called before this method.
6263
"""
6364
logging.info(f"Starting DNS Server at {self.ip}")
6465
dns.run_catchall(self.ip)

0 commit comments

Comments
 (0)