adafruit / Adafruit_CircuitPython_AirLift

Manage AirLift coprocessors for use with Wifi and Bluetooth
MIT License
3 stars 3 forks source link

ESP Airlift socket cannot be assigned to HTTPServer #9

Closed smoczyna closed 1 year ago

smoczyna commented 1 year ago

Following assignment causes http sever to fail on start. Is the socket incompatible here ? The same issue happens in circuit python v7 and v8

from adafruit_esp32spi import adafruit_esp32spi
import adafruit_esp32spi.adafruit_esp32spi_socket as socket
from adafruit_httpserver.server import HTTPServer
...
esp = adafruit_esp32spi.ESP_SPIcontrol(spi, esp32_cs, esp32_ready, esp32_reset)
socket.set_interface(esp)
server = HTTPServer(socket)
server.start(esp.pretty_ip(esp.ip_address))

error message:

>>> %Run -c $EDITOR_CONTENT
Creating display
Creating server socket
ESP32 found and in idle mode
Firmware vers. bytearray(b'1.2.2\x00')
MAC addr: ...
...
Connecting to AP...
Connected to jama   RSSI: -27
My IP address is 192.168.0.24
Creating HTTP Server...
starting server..
Traceback (most recent call last):
  File "<stdin>", line 175, in <module>
  File "adafruit_httpserver/server.py", line 91, in start
AttributeError: 'socket' object has no attribute 'bind'
>>> 
anecdata commented 1 year ago

The adafruit_httpserver library is designed to work with CPython-compatible circuitpython-native sockets (espressif and raspberrypi / Pico W). The sockets exposed by the ESP32SPI NINA firmware are based on Arduino and have a different API (no bind, listen, or accept).

There are examples of HTTP servers for Airlift, for example: https://github.com/adafruit/Adafruit_CircuitPython_ESP32SPI/tree/main/examples/server

dhalbert commented 1 year ago

We would like to redo the ESP32SPI library to be API compatible, but haven't done that yet. Maybe it would be a new library, since it would obsolete so much code.

smoczyna commented 1 year ago

all right, that example mentioned above work fine, thanks