tinygo-org / drivers

TinyGo drivers for sensors, displays, wireless adaptors, and other devices that use I2C, SPI, GPIO, ADC, and UART interfaces.
https://tinygo.org
BSD 3-Clause "New" or "Revised" License
604 stars 188 forks source link

WiFiNina: HTTP Server #408

Open bpoetzschke opened 2 years ago

bpoetzschke commented 2 years ago

Hi there,

I was wondering whether it's possible to host a web server with the WiFiNina driver? I was trying to mimic the Arduino example however, I always get no data on the socket. I figured that this is because the socket is actually not assigned to the adaptor when calling adaptor.GetSocket() but I do not see any way to override the socket on the device after retrieving the socket.

func main() {
    setup()
    waitSerial()
    connectToAP()

    socket, err := adaptor.GetSocket()
    if err != nil {
        for {
            println("Error getting socket: ", err)
        }
    }
    err = adaptor.StartServer(80, socket, wifinina.ProtoModeTCP)
    if err != nil {
        for {
            println("Error starting server: ", err)
        }
    }
    println("Server running")
    for {
        println("Is socket data available: ", adaptor.IsSocketDataAvailable())
        time.Sleep(time.Second)
    }
}

The call to adaptor.IsSocketDataAvailable() is always returning false.