How do I check my WiFi link status before sending a network request? The only way I can see to check my WiFi status is by using the WiFi.begin() (WiFi - Arduino Reference) method.
What I'm seeing is that if my Arduino boots up and connects to the network, then has no activity for a long period of time, it loses the connection to the network. If this happens, the next action I take seems to reconnect it, but that request fails.
The symptoms I see on the board are as follows:
Link light is green
Push button to trigger network traffic
Link light goes red
Request fails
Link light goes green
Push button to generate network traffic
Request succeeds
I'd like to check the link status on each button press to ensure that I have a valid link before sending the request, and then attempt to re-establish the link if it's not valid.
In the source code. I looked at the WiFi client example. I see the method used there. It checks for the existence of the WiFi shield, but it might have other useful return values.