If I'm not mistaken, you can do the same having a:
bool wifiConnected = false;
And taking in account
the WiFi events
you can simply set in the event that global variable:
WIFI_EVENT_STA_CONNECTED then wifiConnected = true
WIFI_EVENT_STA_DISCONNECTED then wifiConnected = false
If there is another way please enlighten me. But otherwise this just adding 3 lines and checking for the wifiConnected state.