Improved the retry loop

pull/41/head
Hieromon Ikasamo 5 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",
"value": "",
"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",
@ -184,7 +184,7 @@ bool mqttConnect() {
"abcdefghijklmnopqrstuvwxyz"; // For random generation of client ID.
char clientId[9];
uint8_t retry = 10;
uint8_t retry = 3;
while (!mqttClient.connected()) {
if (serverName.length() <= 0)
break;
@ -205,8 +205,8 @@ bool mqttConnect() {
Serial.println("Connection failed:" + String(mqttClient.state()));
if (!--retry)
break;
delay(3000);
}
delay(3000);
}
return false;
}

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

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

Loading…
Cancel
Save