File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -230,8 +230,7 @@ char* AdafruitIO::userAgent()
230230
231231aio_status_t AdafruitIO::mqttStatus ()
232232{
233- static uint32_t lastTried = 0 ; // remember last attempt to connect
234- // if the connection irretrievably failed,
233+ // if the connection failed,
235234 // return so we don't hammer IO
236235 if (_status == AIO_CONNECT_FAILED)
237236 {
@@ -249,12 +248,7 @@ aio_status_t AdafruitIO::mqttStatus()
249248
250249 if (_mqtt->connected ())
251250 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;
256251
257- lastTried = millis ();
258252 switch (_mqtt->connect (_username, _key)) {
259253 case 0 :
260254 return AIO_CONNECTED;
@@ -266,6 +260,8 @@ aio_status_t AdafruitIO::mqttStatus()
266260 case 3 : // mqtt service unavailable
267261 case 6 : // throttled
268262 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);
269265 return AIO_DISCONNECTED;
270266 default :
271267 return AIO_DISCONNECTED;
You can’t perform that action at this time.
0 commit comments