drivers icon indicating copy to clipboard operation
drivers copied to clipboard

WiFiNina: HTTP Server

Open bpoetzschke opened this issue 2 years ago • 0 comments

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.

bpoetzschke avatar May 04 '22 02:05 bpoetzschke