Skip to content

Commit 88b69fe

Browse files
committed
Fixed #2
1 parent b0f0845 commit 88b69fe

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

server.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,12 +181,22 @@ def __init__(
181181
if self.v:
182182
print("Installing server CA certificate for server verification")
183183
self.context.load_verify_locations(cadata=server_cert)
184+
self.connect_wifi()
185+
186+
def connect_wifi(self) -> None:
187+
"""Creates the wifi connection to the access point"""
188+
wifi.radio.enabled = True
184189
if self.v:
185190
print("Connecting to the access point...")
186-
wifi.radio.connect(conf.AP_SSID)
191+
wifi.radio.connect(self.conf.AP_SSID)
187192
if self.v:
188193
print("Initializing socket pool...")
189-
self.pool = socketpool.SocketPool(wifi.radio)
194+
self.pool = socketpool.SocketPool(wifi.radio)
195+
196+
def close_wifi(self) -> None:
197+
"""Disconnects from the access point and shuts off the radio"""
198+
self.close_socket()
199+
wifi.radio.enabled = False
190200

191201
def connect_socket(self) -> None:
192202
"""Creates a socket connection to the server"""
@@ -210,6 +220,11 @@ def close_socket(self) -> None:
210220
self.sock.close()
211221
del self.sock
212222
collect()
223+
224+
@property
225+
def radio(self):
226+
"""Returns a wifi.radio object that can be used for further control"""
227+
return wifi.radio
213228

214229
def _do_request(
215230
self,

0 commit comments

Comments
 (0)