Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/neradoc/circuitpython_universal_sockets
The UniversalSocket class to abstract native and ESP32 sockets to feed into something taking either.
https://github.com/neradoc/circuitpython_universal_sockets
Last synced: about 1 month ago
JSON representation
The UniversalSocket class to abstract native and ESP32 sockets to feed into something taking either.
- Host: GitHub
- URL: https://github.com/neradoc/circuitpython_universal_sockets
- Owner: Neradoc
- License: mit
- Created: 2023-04-15T01:25:02.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-04-15T01:30:36.000Z (over 1 year ago)
- Last Synced: 2024-10-22T09:48:19.751Z (2 months ago)
- Language: Python
- Homepage:
- Size: 3.91 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Circuitpython_Universal_Sockets
The UniversalSocket class to abstract native and ESP32 sockets to feed into something taking either.Example using the HTTPServer library with ESP32SPI:
```py
from universal_socket import UniversalSocket
from adafruit_esp32spi import adafruit_esp32spi
import adafruit_esp32spi.adafruit_esp32spi_socket as socket
from adafruit_httpserver.server import HTTPServeresp32_cs = DigitalInOut(board.ESP_CS)
esp32_ready = DigitalInOut(board.ESP_BUSY)
esp32_reset = DigitalInOut(board.ESP_RESET)spi = busio.SPI(board.SCK, board.MOSI, board.MISO)
esp = adafruit_esp32spi.ESP_SPIcontrol(
spi, esp32_cs, esp32_ready, esp32_reset
)esp.connect_AP(
os.getenv("CIRCUITPY_WIFI_SSID"),
os.getenv("CIRCUITPY_WIFI_PASSWORD"),
)socket.set_interface(esp)
usock = UniversalSocket(socket, iface=esp)
server = HTTPServer(usock)
IP_ADDRESS = "%d.%d.%d.%d" % tuple(esp.ip_address)server.serve_forever(host=str(IP_ADDRESS), port=80, root_path="/www")
```