!WL_CONNECTED is the normal way to detect a diconnected WiFi, just do a normal begin. Check the library samples to be sure, but I think that is correct. Here is a code snippet from a WiFi web server. It assumes it gets fixed magically, but you may want to count the number of tries then do a new begin.
I found another thread which seems to indicate that isn't 100% reliable. It suggested the following code that actually pings the gateway to see if it's live:
bool isWifiConnected(){
//check connected
if ( WiFi.status() != WL_CONNECTED) {
return false;
}
//test ping the gateway
IPAddress gip = WiFi.gatewayIP();
int pingResult = WiFi.ping(gip);
if (pingResult < 0) {
return false;
}
//connected
return true;
}
Side note: I did a forum search expecting to find something like this, but apparently didn't search on the correct keywoard. That thread popped up on the side of this one!
Ok, I haven't seen that particular example but it sounds like a good idea. If a failure is detected, I would still recommend restarting only the WiFi, not the entire board.