File tree Expand file tree Collapse file tree 2 files changed +7
-1
lines changed Expand file tree Collapse file tree 2 files changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -167,6 +167,7 @@ const __FlashStringHelper* AdafruitIO::statusText()
167
167
168
168
aio_status_t AdafruitIO::run (uint16_t busywait_ms)
169
169
{
170
+ uint32_t timeStart = millis ();
170
171
aio_status_t net_status = networkStatus ();
171
172
// If we aren't connected, return network status -- fail quickly
172
173
// Previous version would just hang on a network error
@@ -177,7 +178,8 @@ aio_status_t AdafruitIO::run(uint16_t busywait_ms)
177
178
178
179
// loop until we have a connection
179
180
// 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;
181
183
182
184
if (busywait_ms > 0 )
183
185
_packetread_timeout = busywait_ms;
Original file line number Diff line number Diff line change 12
12
#ifndef ADAFRUITIO_H
13
13
#define ADAFRUITIO_H
14
14
15
+ #ifndef ADAFRUITIO_RUN_TIMEOUT
16
+ #define ADAFRUITIO_RUN_TIMEOUT 60000
17
+ #endif
18
+
15
19
#include " Arduino.h"
16
20
#include " Adafruit_MQTT.h"
17
21
#include " AdafruitIO_Definitions.h"
You can’t perform that action at this time.
0 commit comments