I have an airlift shield on a Grand Central. Examples found work fine but not what I want. I want simple client or server capabilities with a socket. So I can talk to a PC. Simple enough using python on PC's. I can get a client working with esp32spi_socket. As well as the preliminary adafruit_esp32spi to connect to my wifi access point. But I'd really like to replicate a server similar to this, which is python on a PC:
s = socket.socket() # Create a socket object
host = socket.gethostname() # Get local machine name
port = 12345 # Reserve a port for your service.
s.bind((host, port)) # Bind to the port
s.listen(5) # Now wait for client connection.
c, addr = s.accept() # Establish connection with client.
c.send(b'Thank you for connecting\n')
c.close() # Close the connection
I wish to use the methods within adafruit_esp32spi rather than the esp32spi_socket. But for the life of me I can't seem to get:
get_socket() to work. It always returns 0 even if I call it twice which does not seem right. Anyone have any insight. I must be skipping some stuff that needs to be done. The documentation seems pretty weak. Which is a bit of a disappointment from adafruit.
Here's what I try, though only one iteration of what I have tried and I am faking it here in a futile attempt to get something to work.
#Stuff to set up access point, then
esp.wifi_set_network(esp.ssid)
sockNum=esp.get_socket()
print('sockNum=',sockNum)
sockNum2=esp.get_socket()
print('sockNum2=',sockNum2)
esp.start_server(12345, sockNum)
print('Server state=',esp.server_state(sockNum))
esp.socket_write(sockNum, b'This is a test\n')
I am grasping at straws.
Airlift as client/server on circuit python
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
Please be positive and constructive with your questions and comments.