I have configured my esp8266 as access point and want it to react on certain data send from a smartphone over a socket it listens on.
This is my code:
The loop runs once and gives the right output and then nothing happens. I can only break it with Ctrl+C.
Code: Select all
import usocket as socket addr = socket.getaddrinfo('0.0.0.0', 80)[-1] while True: s = socket.socket() s.bind(addr) s.listen(1) cl, addr = s.accept() data=str(cl.recv(1024)) if data[-2] == "0": print(data[-2]) elif data[-2] == "1": print(data[-2]) s.close()
I read that I have to put the s=socket.socket() line into the loop. Is that right?
Can you please help me?