@@ -282,15 +282,11 @@ void ArduinoIoTCloudClass::handleMessage(int length)
282
282
}
283
283
284
284
void ArduinoIoTCloudClass::connectionCheck () {
285
- if (connection != NULL ){
285
+ if (connection != NULL ) {
286
286
connection->check ();
287
-
288
287
if (connection->getStatus () != CONNECTION_STATE_CONNECTED) {
289
- if (iotStatus == IOT_STATUS_CLOUD_CONNECTED){
290
- setIoTConnectionState (IOT_STATUS_CLOUD_DISCONNECTED);
291
- }else {
292
- // setIoTConnectionState(IOT_STATUS_CLOUD_CONNECTING);
293
- }
288
+ if (iotStatus == IOT_STATUS_CLOUD_CONNECTED)
289
+ setIoTConnectionState (IOT_STATUS_CLOUD_RECONNECTING);
294
290
return ;
295
291
}
296
292
}
@@ -299,7 +295,7 @@ void ArduinoIoTCloudClass::connectionCheck() {
299
295
300
296
301
297
switch (iotStatus) {
302
- case IOT_STATUS_IDLE :
298
+ case IOT_STATUS_CLOUD_IDLE :
303
299
{
304
300
int connectionAttempt;
305
301
if (connection == NULL ){
@@ -314,17 +310,15 @@ void ArduinoIoTCloudClass::connectionCheck() {
314
310
}
315
311
setIoTConnectionState (IOT_STATUS_CLOUD_CONNECTING);
316
312
break ;
317
- }
318
-
313
+ }
319
314
case IOT_STATUS_CLOUD_ERROR:
320
315
debugMessage (" Cloud Error. Retrying..." , 0 );
321
316
setIoTConnectionState (IOT_STATUS_CLOUD_RECONNECTING);
322
317
break ;
323
318
case IOT_STATUS_CLOUD_CONNECTED:
324
319
debugMessage (" ." , 4 , false , true );
325
- break ;
326
- case IOT_STATUS_CLOUD_DISCONNECTED:
327
- setIoTConnectionState (IOT_STATUS_CLOUD_RECONNECTING);
320
+ if (!_mqttClient->connected ())
321
+ setIoTConnectionState (IOT_STATUS_CLOUD_RECONNECTING);
328
322
break ;
329
323
case IOT_STATUS_CLOUD_RECONNECTING:
330
324
int arduinoIoTReconnectionAttempt;
0 commit comments