Skip to content

Commit 67c51aa

Browse files
committed
implemented connectionCheck() on update
1 parent 337ba7f commit 67c51aa

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/ArduinoIoTCloud.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,7 @@ void ArduinoIoTCloudClass::poll()
159159
void ArduinoIoTCloudClass::update()
160160
{
161161
// If user call update() without parameters use the default ones
162-
if(iotStatus == IOT_STATUS_CLOUD_CONNECTED){
163-
update(MAX_RETRIES, RECONNECTION_TIMEOUT);
164-
}
165-
162+
update(MAX_RETRIES, RECONNECTION_TIMEOUT);
166163
}
167164

168165
bool ArduinoIoTCloudClass::mqttReconnect(int const maxRetries, int const timeout)
@@ -189,6 +186,10 @@ bool ArduinoIoTCloudClass::mqttReconnect(int const maxRetries, int const timeout
189186

190187
void ArduinoIoTCloudClass::update(int const reconnectionMaxRetries, int const reconnectionTimeoutMs)
191188
{
189+
connectionCheck();
190+
if(iotStatus != IOT_STATUS_CLOUD_CONNECTED){
191+
return;
192+
}
192193
// Method's argument controls
193194
int const maxRetries = (reconnectionMaxRetries > 0) ? reconnectionMaxRetries : MAX_RETRIES;
194195
int const timeout = (reconnectionTimeoutMs > 0) ? reconnectionTimeoutMs : RECONNECTION_TIMEOUT;

0 commit comments

Comments
 (0)