Created
March 20, 2022 03:37
-
-
Save anecdata/b3d43870942684570d90e3fc9833292b to your computer and use it in GitHub Desktop.
UDP Server ESP32SPI read-only (very rudimentary)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
import board | |
import busio | |
from digitalio import DigitalInOut | |
import adafruit_esp32spi.adafruit_esp32spi_socket as socket | |
from adafruit_esp32spi import adafruit_esp32spi | |
from secrets import secrets | |
PORT = 5000 | |
spi = board.SPI() | |
esp32_cs = DigitalInOut(board.ESP_CS) | |
esp32_ready = DigitalInOut(board.ESP_BUSY) | |
esp32_reset = DigitalInOut(board.ESP_RESET) | |
esp = adafruit_esp32spi.ESP_SPIcontrol(spi, esp32_cs, esp32_ready, esp32_reset) | |
socket.set_interface(esp) | |
esp.connect_AP(secrets["ssid"], secrets["password"]) | |
print("Connected:", "RSSI =", esp.rssi) | |
s = socket.socket(type=socket.SOCK_DGRAM) | |
esp.start_server(PORT, s.socknum, conn_mode=1) # ip= | |
while True: | |
numbytes_avail = esp.socket_available(s.socknum) | |
if numbytes_avail: | |
print(numbytes_avail) | |
bytes_read = esp.socket_read(s.socknum, numbytes_avail) | |
print(bytes_read) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Arduino functions
WiFiUDP.remoteIP()
andWiFiUDP.remotePort()
are accessed by NINA firmware functiongetRemoteData()
(command code 0x3A), which is unimplemented in the ESP32SPI library as of v4.0.2.