Marijn78

Untitled

May 12th, 2020
110
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. bool wifiConnect() {
  2.   if (!WiFi.config(local_IP, gateway, subnet, primaryDNS, secondaryDNS)) {
  3.     if (debug) Serial.println("STA Failed to configure");
  4.     return false;
  5.   }
  6.   if (debug) Serial.println("Connecting to " + String(ssid));
  7.   WiFi.begin(ssid, password);
  8.   while (WiFi.status() != WL_CONNECTED) {
  9.     delay(500);
  10.     if (debug) Serial.print(".");
  11.     delay(500);
  12.     counter++;
  13.     if (counter >= wifiTimeoutSeconds) {
  14.       if (debug) Serial.println("Wifi Connection Timeout..");
  15.       timeoutCount++;
  16.       return false;
  17.     }
  18.   }
  19.   if (debug) Serial.println("WiFi connected!");
  20.   return true;
  21. }
RAW Paste Data