@@ -71,6 +71,7 @@ extern "C" void updateTimezoneInfo()
71
71
72
72
extern " C" void setThingIdOutdated ()
73
73
{
74
+ DEBUG_VERBOSE (" Set thing_id outdated flag" );
74
75
ArduinoCloud.setThingIdOutdatedFlag ();
75
76
}
76
77
@@ -329,6 +330,7 @@ void ArduinoIoTCloudTCP::update()
329
330
/* Check if the state has changed in message handler */
330
331
if (_next_state != State::Invalid)
331
332
{
333
+ DEBUG_VERBOSE (" ArduinoIoTCloudTCP::%s State changed in message handler..." , __FUNCTION__);
332
334
_state = _next_state;
333
335
_next_state = State::Invalid;
334
336
}
@@ -405,6 +407,7 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_ConnectMqttBroker()
405
407
if (_mqttClient.connect (_brokerAddress.c_str (), _brokerPort))
406
408
{
407
409
_last_connection_attempt_cnt = 0 ;
410
+ DEBUG_VERBOSE (" ArduinoIoTCloudTCP::%s connected to %s:%d" , __FUNCTION__, _brokerAddress.c_str (), _brokerPort);
408
411
return State::SendDeviceProperties;
409
412
}
410
413
@@ -425,6 +428,7 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_SendDeviceProperties()
425
428
return State::Disconnect;
426
429
}
427
430
431
+ DEBUG_VERBOSE (" ArduinoIoTCloudTCP::%s" , __FUNCTION__);
428
432
sendDevicePropertiesToCloud ();
429
433
return State::SubscribeDeviceTopic;
430
434
}
@@ -441,6 +445,8 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_SubscribeDeviceTopic()
441
445
return State::SubscribeDeviceTopic;
442
446
}
443
447
448
+ DEBUG_VERBOSE (" ArduinoIoTCloudTCP::%s subscribed to %s" , __FUNCTION__, _deviceTopicIn.c_str ());
449
+
444
450
if (_last_device_subscribe_cnt > AIOT_CONFIG_LASTVALUES_SYNC_MAX_RETRY_CNT)
445
451
{
446
452
_last_device_subscribe_cnt = 0 ;
@@ -456,6 +462,7 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_SubscribeDeviceTopic()
456
462
_next_device_subscribe_attempt_tick = millis () + subscribe_retry_delay;
457
463
_last_device_subscribe_cnt++;
458
464
465
+ DEBUG_VERBOSE (" ArduinoIoTCloudTCP::%s waiting device configuration from %s" , __FUNCTION__, _deviceTopicIn.c_str ());
459
466
return State::WaitDeviceConfig;
460
467
}
461
468
@@ -474,6 +481,8 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_WaitDeviceConfig()
474
481
if (millis () > _next_device_subscribe_attempt_tick)
475
482
{
476
483
/* Configuration not received or device not attached to a valid thing. Try to resubscribe */
484
+ DEBUG_VERBOSE (" ArduinoIoTCloudTCP::%s configuration not received or device not attached to a valid thing" , __FUNCTION__);
485
+ DEBUG_VERBOSE (" ArduinoIoTCloudTCP::%s new subscription attempt at tick time %d" , __FUNCTION__, _next_device_subscribe_attempt_tick);
477
486
if (_mqttClient.unsubscribe (_deviceTopicIn))
478
487
{
479
488
return State::SubscribeDeviceTopic;
@@ -492,6 +501,7 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_CheckDeviceConfig()
492
501
if (_deviceSubscribedToThing == true )
493
502
{
494
503
/* Unsubscribe from old things topics and go on with a new subsctiption */
504
+ DEBUG_VERBOSE (" ArduinoIoTCloudTCP::%s Unsubscribing from old thing topics" , __FUNCTION__);
495
505
_mqttClient.unsubscribe (_shadowTopicIn);
496
506
_mqttClient.unsubscribe (_dataTopicIn);
497
507
_deviceSubscribedToThing = false ;
@@ -506,6 +516,7 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_CheckDeviceConfig()
506
516
attach_retry_delay = min (attach_retry_delay, static_cast <unsigned long >(AIOT_CONFIG_MAX_DEVICE_TOPIC_ATTACH_RETRY_DELAY_ms));
507
517
_next_device_subscribe_attempt_tick = millis () + attach_retry_delay;
508
518
_last_device_attach_cnt++;
519
+ DEBUG_VERBOSE (" ArduinoIoTCloudTCP::%s Device not attached to a valid Thing. New Request delay: %d" , __FUNCTION__, attach_retry_delay);
509
520
return State::WaitDeviceConfig;
510
521
}
511
522
@@ -517,6 +528,8 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_CheckDeviceConfig()
517
528
518
529
ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_SubscribeThingTopics ()
519
530
{
531
+ DEBUG_VERBOSE (" ArduinoIoTCloudTCP::%s" , __FUNCTION__);
532
+
520
533
if (!_mqttClient.connected ())
521
534
{
522
535
return State::Disconnect;
@@ -716,6 +729,7 @@ void ArduinoIoTCloudTCP::handleMessage(int length)
716
729
/* Topic for OTA properties and device configuration */
717
730
if (_deviceTopicIn == topic) {
718
731
CBORDecoder::decode (_device_property_container, (uint8_t *)bytes, length);
732
+ DEBUG_VERBOSE (" ArduinoIoTCloudTCP::%s [%d] device configuration or OTA message received" , __FUNCTION__, millis ());
719
733
_last_device_subscribe_cnt = 0 ;
720
734
_next_device_subscribe_attempt_tick = 0 ;
721
735
}
0 commit comments