Help detecting wifi disconnect

Hello -

I am using NodeMCU 1.0 board. When the WiFi router is disconnected or rebooting, the sketch does connect to Blynk automatically. And I know I can send push notifications to the iPhone when device lost connection which is also working great.

The only thing is when WiFi disconnect happens, NodeMCE can’t reach the access point or the WiFi password is invalid, I would like to flash my LED on NodeMCU so I know WiFi cannot be reached. I found several threads in search but seems like they are old. One of the many things I tried is the following but seems the code never reaches there if the WiFi cannot be reached.

void setup()
{
  // Debug console
  Serial.begin(9600);

  // Start Blynk processing
  Blynk.begin(auth, ssid, pass);

  while (Blynk.connect() == false) {
    // Wait until connected
    // TODO: This is not detecting if wifi isn't avail. Need to way to blink LED for that
    digitalWrite(LED_BUILTIN, HIGH);
    delay(100);
    digitalWrite(LED_BUILTIN, LOW);
    delay(100);
  }

@DIYTerminator Blynk.begin() will not handle bad passwords or if the AP is down.

You can use the regular Arduino WiFi.begin() loop with a break at x seconds or Blynk’s equivelant of Blynk.connectWiFi() again with break.

You then use Blynk.config() and Blynk.connect() possibly with a timeout or again another break.

See http://docs.blynk.cc/#blynk-firmware-connection-management