I'm having a little trouble with AP_IF mode. I'm trying to make a WiFi setup page, such that the user connects to an AP and gets served a configuration page. If I do
ap = network.WLAN(network.AP_IF)
ap.active(True)
ap.config(essid="Setup")
The AP gets created, and the client can connect to it. However, if I then use one of the socket http server examples:
import socket
addr = socket.getaddrinfo('0.0.0.0', 80)[0][-1]
s = socket.socket()
s.bind(addr)
s.listen(1)
while True:
cl, addr = s.accept()
print('client connected from', addr)
cl_file = cl.makefile('rwb', 0)
while True:
line = cl_file.readline()
if not line or line == b'\r\n':
break
rows = ['<tr><td>%s</td><td>%d</td></tr>' % (str(p), p.value()) for p in pins]
response = html % '\n'.join(rows)
cl.send(response)
cl.close()
And try to connect to 0.0.0.0:80 over the softAP, no client connection attempt is registered, and nothing gets sent to the client. In addition, ap.isconnected() gives an OSError: STA required, instead of the behavior documented here.
There's probably something I'm missing in AP/Socket setup - or is AP currently incompatible with the socket module?
Thanks for this incredible project, by the way, it makes my life a lot easier :>