Thanks to the advice I received here, I'm making good progress porting my Uno Ethernet code to the R4 WiFi. My sketch detects a suitable WiFi network, connects to it, and displays NET on the LED matrix. When my C#.Net app on the PC connects to the R4, it displays APP, and accepts commands from the app, blinking APP each time it receives one. Looking good.
The PC app can disconnect from the R4, then connect again later to send more commands. I would like the matrix to display NET, not APP, when the app disconnects, but I can't figure out how to detect that disconnection.
I've tried code around client.connected() and client.available(), but APP is never replaced with NET.
My code essentially looks like this:
client = server.available();
if (client)
{
if(client.available())
{
Serial.println("client.available()");
displayMatrix(appFrame); // Display "APP" when control app connected
}
else
{
Serial.println("NOT client.connected()");
displayMatrix(netFrame); // Else display "NET"
}
}
Does anyone have any suggestions? Thanks.
--- Mike