-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnetConfigAccessPoint.py
More file actions
28 lines (20 loc) · 852 Bytes
/
Copy pathnetConfigAccessPoint.py
File metadata and controls
28 lines (20 loc) · 852 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import network
import socket
import configHttpServer
class NetConfigAccessPoint:
def __init__(self, localSsid, httpLocalHostListener):
self.ssid = localSsid
self.serverSocket = httpLocalHostListener.listener_socket
def start(self):
self.create_access_point() # address is always http://192.168.4.1
http_server = self.create_http_config_server()
while True:
http_server.dispatch_client_requests()
def create_access_point(self):
ap_if = network.WLAN(network.AP_IF)
ap_if.active(True)
ap_if.config(essid=self.ssid) # fails if we tried to go to st mode..
addr = socket.getaddrinfo('0.0.0.0', 80)[0][-1]
return addr, ap_if.ifconfig()
def create_http_config_server(self):
return configHttpServer.ConfigHttpServer(self.serverSocket)