Hello everyone, please help.
Doing something wrong and can't figure out what!!
I want to retry the Wi-Fi connection 30 times,
If you have success before, continue the program
If not, continue without wifi
HELP
void setup() {
Wire.begin(5, 4);
byte retry = 0;
byte maxRetries = 31;
pinMode(ledpin, OUTPUT);
digitalWrite(ledpin, ledon);
#ifdef DEBUG
Serial.begin(74880);
#endif
WiFi.mode(WIFI_STA);
WiFi.disconnect();
delay(100);
WiFi.begin(ssid, password);
delay(1000);
while ((WiFi.status() != WL_CONNECTED) || (retry > maxRetries)) {
retry++;
delay(500);
toggleLED();
#ifdef DEBUG
Serial.print(retry);
Serial.print("-");
Serial.print(WiFi.status());
Serial.println();
#endif