File tree Expand file tree Collapse file tree 1 file changed +3
-7
lines changed Expand file tree Collapse file tree 1 file changed +3
-7
lines changed Original file line number Diff line number Diff line change @@ -230,8 +230,7 @@ char* AdafruitIO::userAgent()
230
230
231
231
aio_status_t AdafruitIO::mqttStatus ()
232
232
{
233
- static uint32_t lastTried = 0 ; // remember last attempt to connect
234
- // if the connection irretrievably failed,
233
+ // if the connection failed,
235
234
// return so we don't hammer IO
236
235
if (_status == AIO_CONNECT_FAILED)
237
236
{
@@ -249,12 +248,7 @@ aio_status_t AdafruitIO::mqttStatus()
249
248
250
249
if (_mqtt->connected ())
251
250
return AIO_CONNECTED;
252
-
253
- // don't try to connect more often than the throttle interval
254
- if (lastTried != 0 && millis () < (lastTried + AIO_THROTTLE_RECONNECT_INTERVAL))
255
- return AIO_DISCONNECTED;
256
251
257
- lastTried = millis ();
258
252
switch (_mqtt->connect (_username, _key)) {
259
253
case 0 :
260
254
return AIO_CONNECTED;
@@ -266,6 +260,8 @@ aio_status_t AdafruitIO::mqttStatus()
266
260
case 3 : // mqtt service unavailable
267
261
case 6 : // throttled
268
262
case 7 : // banned -> all MQTT bans are temporary, so eventual retry is permitted
263
+ // delay to prevent fast reconnects
264
+ delay (AIO_THROTTLE_RECONNECT_INTERVAL);
269
265
return AIO_DISCONNECTED;
270
266
default :
271
267
return AIO_DISCONNECTED;
You can’t perform that action at this time.
0 commit comments