What am I doing wrong here? The 1.15.1 documentation is where I pulled this code from. Is this an issue with the custom firmware?
import network
from time import sleep
#import usocket as socket
def connect_wifi():
N1 = network.WLAN_SPI(network.STA_IF)
N1.active(True)
connected = False
while not connected:
N1.connect("wifissid","ssidpass")
if N1.isconnected():
connected = True
else:
print("Not Connected, trying again.")
sleep(1)
print("Connected! My IP is: {}".format(N1.ifconfig()[0]))
def http_serve():
html = """<!DOCTYPE html>
<html>
<head> <title>Seeed Wio RP2040 Webpage</title> </head>
<body> <h1>Test Body Header 1</h1>
</body>
</html>
"""
import socket
addr = socket.getaddrinfo('0.0.0.0', 80)[0][-1]
s = socket.socket()
s.bind(addr)
s.listen(1)
print('listening on', addr)
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
response = html
cl.send('HTTP/1.0 200 OK\r\nContent-type: text/html\r\n\r\n')
cl.send(response)
cl.close()
connect_wifi()
http_serve()