|
1 | 1 | from phew import server, template, logging, access_point, dns
|
2 | 2 | from phew.template import render_template
|
3 |
| -from phew.server import redirect, stop |
| 3 | +from phew.server import redirect, stop, close |
4 | 4 | import gc
|
5 | 5 | import network
|
6 | 6 | import time
|
@@ -59,7 +59,9 @@ def start_network(self, ssid:str=None, robot_id:int= None, password:str=None):
|
59 | 59 | ssid = f"XRP_{robot_id}"
|
60 | 60 | password = "remote.xrp"
|
61 | 61 | self.access_point = access_point(ssid, password)
|
62 |
| - self.ip = network.WLAN(network.AP_IF).ifconfig()[0] |
| 62 | + logging.info(f"Starting Access Point \"{ssid}\"") |
| 63 | + self.wlan = network.WLAN(network.AP_IF) |
| 64 | + self.ip = self.wlan.ifconfig()[0] |
63 | 65 |
|
64 | 66 | def connect_to_network(self, ssid:str=None, password:str=None, timeout = 10):
|
65 | 67 | """
|
@@ -112,6 +114,9 @@ def stop_server(self):
|
112 | 114 | """
|
113 | 115 | Shuts off the webserver and network and stops handling requests
|
114 | 116 | """
|
| 117 | + logging.enable_logging_types(logging.LOG_INFO) |
| 118 | + logging.info("Stopping Webserver and Network Connections") |
| 119 | + |
115 | 120 | stop()
|
116 | 121 | self.wlan.active(False)
|
117 | 122 |
|
@@ -218,8 +223,8 @@ def _handleUserFunctionRequest(self, text) -> bool:
|
218 | 223 | return False
|
219 | 224 | user_function()
|
220 | 225 | return True
|
221 |
| - except: |
222 |
| - logging.error("User function "+text+" caused an exception") |
| 226 | + except RuntimeError as xcpt: |
| 227 | + logging.error("User function "+text+" caused an exception: "+str(xcpt)) |
223 | 228 | return False
|
224 | 229 |
|
225 | 230 | def _generateHTML(self):
|
|
0 commit comments