Improved the retry loop

pull/41/head
Hieromon Ikasamo 6 years ago committed by Hieromon Ikasamo
parent 21b691ce82
commit 3ba2ed1335
  1. 6
      examples/mqttRSSI/mqttRSSI.ino
  2. 4
      examples/mqttRSSI_FS/mqttRSSI_FS.ino
  3. 4
      examples/mqttRSSI_NA/mqttRSSI_NA.ino

@ -114,7 +114,7 @@ static const char AUX_mqtt_setting[] PROGMEM = R"raw(
"type": "ACInput", "type": "ACInput",
"value": "", "value": "",
"label": "ESP host name", "label": "ESP host name",
"pattern": "^([a-zA-Z0-9]([a-zA-Z0-9-])*[a-zA-Z0-9]){1,32}$" "pattern": "^([a-zA-Z0-9]([a-zA-Z0-9-])*[a-zA-Z0-9]){1,24}$"
}, },
{ {
"name": "save", "name": "save",
@ -184,7 +184,7 @@ bool mqttConnect() {
"abcdefghijklmnopqrstuvwxyz"; // For random generation of client ID. "abcdefghijklmnopqrstuvwxyz"; // For random generation of client ID.
char clientId[9]; char clientId[9];
uint8_t retry = 10; uint8_t retry = 3;
while (!mqttClient.connected()) { while (!mqttClient.connected()) {
if (serverName.length() <= 0) if (serverName.length() <= 0)
break; break;
@ -205,9 +205,9 @@ bool mqttConnect() {
Serial.println("Connection failed:" + String(mqttClient.state())); Serial.println("Connection failed:" + String(mqttClient.state()));
if (!--retry) if (!--retry)
break; break;
}
delay(3000); delay(3000);
} }
}
return false; return false;
} }

@ -66,7 +66,7 @@ bool mqttConnect() {
"abcdefghijklmnopqrstuvwxyz"; // For random generation of client ID. "abcdefghijklmnopqrstuvwxyz"; // For random generation of client ID.
char clientId[9]; char clientId[9];
uint8_t retry = 10; uint8_t retry = 3;
while (!mqttClient.connected()) { while (!mqttClient.connected()) {
if (serverName.length() <= 0) if (serverName.length() <= 0)
break; break;
@ -86,9 +86,9 @@ bool mqttConnect() {
Serial.println("Connection failed:" + String(mqttClient.state())); Serial.println("Connection failed:" + String(mqttClient.state()));
if (!--retry) if (!--retry)
break; break;
}
delay(3000); delay(3000);
} }
}
return false; return false;
} }

@ -102,7 +102,7 @@ bool mqttConnect() {
"abcdefghijklmnopqrstuvwxyz"; // For random generation of client ID. "abcdefghijklmnopqrstuvwxyz"; // For random generation of client ID.
char clientId[9]; char clientId[9];
uint8_t retry = 10; uint8_t retry = 3;
while (!mqttClient.connected()) { while (!mqttClient.connected()) {
if (mqttserver.value.length() <= 0) if (mqttserver.value.length() <= 0)
break; break;
@ -123,9 +123,9 @@ bool mqttConnect() {
Serial.println("Connection failed:" + String(mqttClient.state())); Serial.println("Connection failed:" + String(mqttClient.state()));
if (!--retry) if (!--retry)
break; break;
}
delay(3000); delay(3000);
} }
}
return false; return false;
} }

Loading…
Cancel
Save