@@ -409,55 +409,55 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_SubscribeMqttTopics()
409
409
unsigned long const now = millis ();
410
410
bool const is_subscribe_retry_delay_expired = (now - _last_subscribe_request_tick) > AIOT_CONFIG_SUBSCRIBE_RETRY_DELAY_ms;
411
411
bool const is_first_subscribe_request = (_last_subscribe_request_cnt == 0 );
412
- if (is_first_subscribe_request || is_subscribe_retry_delay_expired)
412
+
413
+ if (!is_first_subscribe_request && !is_subscribe_retry_delay_expired)
413
414
{
414
- if (_last_subscribe_request_cnt > AIOT_CONFIG_SUBSCRIBE_MAX_RETRY_CNT)
415
- {
416
- _last_subscribe_request_cnt = 0 ;
417
- _last_subscribe_request_tick = 0 ;
418
- _mqttClient.stop ();
419
- execCloudEventCallback (ArduinoIoTCloudEvent::DISCONNECT);
420
- return State::ConnectPhy;
421
- }
415
+ return State::SubscribeMqttTopics;
416
+ }
417
+
418
+ if (_last_subscribe_request_cnt > AIOT_CONFIG_SUBSCRIBE_MAX_RETRY_CNT)
419
+ {
420
+ _last_subscribe_request_cnt = 0 ;
421
+ _last_subscribe_request_tick = 0 ;
422
+ _mqttClient.stop ();
423
+ execCloudEventCallback (ArduinoIoTCloudEvent::DISCONNECT);
424
+ return State::ConnectPhy;
425
+ }
422
426
423
- _last_subscribe_request_tick = now;
424
- _last_subscribe_request_cnt++;
427
+ _last_subscribe_request_tick = now;
428
+ _last_subscribe_request_cnt++;
425
429
426
- if (!_mqttClient.subscribe (_dataTopicIn))
427
- {
428
- DEBUG_ERROR (" ArduinoIoTCloudTCP::%s could not subscribe to %s" , __FUNCTION__, _dataTopicIn.c_str ());
430
+ if (!_mqttClient.subscribe (_dataTopicIn))
431
+ {
432
+ DEBUG_ERROR (" ArduinoIoTCloudTCP::%s could not subscribe to %s" , __FUNCTION__, _dataTopicIn.c_str ());
429
433
#if !defined(__AVR__)
430
- DEBUG_ERROR (" Check your thing configuration, and press the reset button on your board." );
434
+ DEBUG_ERROR (" Check your thing configuration, and press the reset button on your board." );
431
435
#endif
432
- return State::SubscribeMqttTopics;
433
- }
436
+ return State::SubscribeMqttTopics;
437
+ }
434
438
435
- if (_shadowTopicIn != " " )
439
+ if (_shadowTopicIn != " " )
440
+ {
441
+ if (!_mqttClient.subscribe (_shadowTopicIn))
436
442
{
437
- if (!_mqttClient.subscribe (_shadowTopicIn))
438
- {
439
- DEBUG_ERROR (" ArduinoIoTCloudTCP::%s could not subscribe to %s" , __FUNCTION__, _shadowTopicIn.c_str ());
443
+ DEBUG_ERROR (" ArduinoIoTCloudTCP::%s could not subscribe to %s" , __FUNCTION__, _shadowTopicIn.c_str ());
440
444
#if !defined(__AVR__)
441
- DEBUG_ERROR (" Check your thing configuration, and press the reset button on your board." );
445
+ DEBUG_ERROR (" Check your thing configuration, and press the reset button on your board." );
442
446
#endif
443
- return State::SubscribeMqttTopics;
444
- }
447
+ return State::SubscribeMqttTopics;
445
448
}
449
+ }
446
450
447
- _last_subscribe_request_cnt = 0 ;
448
- _last_subscribe_request_tick = 0 ;
449
-
450
- DEBUG_INFO (" Connected to Arduino IoT Cloud" );
451
- execCloudEventCallback (ArduinoIoTCloudEvent::CONNECT);
451
+ DEBUG_INFO (" Connected to Arduino IoT Cloud" );
452
+ execCloudEventCallback (ArduinoIoTCloudEvent::CONNECT);
453
+ _last_subscribe_request_cnt = 0 ;
454
+ _last_subscribe_request_tick = 0 ;
452
455
453
- if (_shadowTopicIn != " " )
454
- return State::RequestLastValues;
455
- else
456
- return State::Connected;
457
-
458
- }
456
+ if (_shadowTopicIn != " " )
457
+ return State::RequestLastValues;
458
+ else
459
+ return State::Connected;
459
460
460
- return State::SubscribeMqttTopics;
461
461
}
462
462
463
463
ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_RequestLastValues ()
0 commit comments