File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -167,6 +167,7 @@ const __FlashStringHelper* AdafruitIO::statusText()
167167
168168aio_status_t AdafruitIO::run (uint16_t busywait_ms)
169169{
170+ uint32_t timeStart = millis ();
170171 aio_status_t net_status = networkStatus ();
171172 // If we aren't connected, return network status -- fail quickly
172173 // Previous version would just hang on a network error
@@ -177,7 +178,8 @@ aio_status_t AdafruitIO::run(uint16_t busywait_ms)
177178
178179 // loop until we have a connection
179180 // mqttStatus() will try to reconnect before returning
180- while (mqttStatus () != AIO_CONNECTED){}
181+ while (mqttStatus () != AIO_CONNECTED && millis () - timeStart < ADAFRUITIO_RUN_TIMEOUT){}
182+ if (mqttStatus () != AIO_CONNECTED) return _status;
181183
182184 if (busywait_ms > 0 )
183185 _packetread_timeout = busywait_ms;
Original file line number Diff line number Diff line change 1212#ifndef ADAFRUITIO_H
1313#define ADAFRUITIO_H
1414
15+ #ifndef ADAFRUITIO_RUN_TIMEOUT
16+ #define ADAFRUITIO_RUN_TIMEOUT 60000
17+ #endif
18+
1519#include " Arduino.h"
1620#include " Adafruit_MQTT.h"
1721#include " AdafruitIO_Definitions.h"
You can’t perform that action at this time.
0 commit comments