Skip to content

Commit 08b7945

Browse files
committed
Add DEBUG prints to follow configuration path
1 parent 105409e commit 08b7945

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/ArduinoIoTCloudTCP.cpp

+14
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ extern "C" void updateTimezoneInfo()
7171

7272
extern "C" void setThingIdOutdated()
7373
{
74+
DEBUG_VERBOSE("Set thing_id outdated flag");
7475
ArduinoCloud.setThingIdOutdatedFlag();
7576
}
7677

@@ -404,6 +405,7 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_ConnectMqttBroker()
404405
if (_mqttClient.connect(_brokerAddress.c_str(), _brokerPort))
405406
{
406407
_last_connection_attempt_cnt = 0;
408+
DEBUG_VERBOSE("ArduinoIoTCloudTCP::%s connected to %s:%d", __FUNCTION__, _brokerAddress.c_str(), _brokerPort);
407409
return State::SendDeviceProperties;
408410
}
409411

@@ -424,6 +426,8 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_SendDeviceProperties()
424426
return State::Disconnect;
425427
}
426428

429+
DEBUG_VERBOSE("ArduinoIoTCloudTCP::%s", __FUNCTION__);
430+
427431
#if OTA_ENABLED
428432
sendOTAPropertiesToCloud();
429433
#endif
@@ -442,6 +446,8 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_SubscribeDeviceTopic()
442446
return State::SubscribeDeviceTopic;
443447
}
444448

449+
DEBUG_VERBOSE("ArduinoIoTCloudTCP::%s subscribed to %s", __FUNCTION__, _deviceTopicIn.c_str());
450+
445451
if (_last_device_subscribe_cnt > AIOT_CONFIG_LASTVALUES_SYNC_MAX_RETRY_CNT)
446452
{
447453
_last_device_subscribe_cnt = 0;
@@ -457,6 +463,7 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_SubscribeDeviceTopic()
457463
_next_device_subscribe_attempt_tick = millis() + subscribe_retry_delay;
458464
_last_device_subscribe_cnt++;
459465

466+
DEBUG_VERBOSE("ArduinoIoTCloudTCP::%s waiting device configuration from %s", __FUNCTION__, _deviceTopicIn.c_str());
460467
return State::WaitDeviceConfig;
461468
}
462469

@@ -475,6 +482,8 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_WaitDeviceConfig()
475482
if (millis() > _next_device_subscribe_attempt_tick)
476483
{
477484
/* Configuration not received or device not attached to a valid thing. Try to resubscribe */
485+
DEBUG_VERBOSE("ArduinoIoTCloudTCP::%s configuration not received or device not attached to a valid thing", __FUNCTION__);
486+
DEBUG_VERBOSE("ArduinoIoTCloudTCP::%s new subscription attempt at tick time %d", __FUNCTION__, _next_device_subscribe_attempt_tick);
478487
if (_mqttClient.unsubscribe(_deviceTopicIn))
479488
{
480489
return State::SubscribeDeviceTopic;
@@ -493,6 +502,7 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_CheckDeviceConfig()
493502
if(_deviceSubscribedToThing == true)
494503
{
495504
/* Unsubscribe from old things topics and go on with a new subsctiption */
505+
DEBUG_VERBOSE("ArduinoIoTCloudTCP::%s Unsubscribing from old thing topics", __FUNCTION__);
496506
_mqttClient.unsubscribe(_shadowTopicIn);
497507
_mqttClient.unsubscribe(_dataTopicIn);
498508
_deviceSubscribedToThing = false;
@@ -507,6 +517,7 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_CheckDeviceConfig()
507517
attach_retry_delay = min(attach_retry_delay, static_cast<unsigned long>(AIOT_CONFIG_MAX_DEVICE_TOPIC_ATTACH_RETRY_DELAY_ms));
508518
_next_device_subscribe_attempt_tick = millis() + attach_retry_delay;
509519
_last_device_attach_cnt++;
520+
DEBUG_VERBOSE("ArduinoIoTCloudTCP::%s Device not attached to a valid Thing. New Request delay: %d", __FUNCTION__, attach_retry_delay);
510521
return State::WaitDeviceConfig;
511522
}
512523

@@ -518,6 +529,8 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_CheckDeviceConfig()
518529

519530
ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_SubscribeThingTopics()
520531
{
532+
DEBUG_VERBOSE("ArduinoIoTCloudTCP::%s", __FUNCTION__);
533+
521534
if (!_mqttClient.connected())
522535
{
523536
return State::Disconnect;
@@ -688,6 +701,7 @@ void ArduinoIoTCloudTCP::handleMessage(int length)
688701
/* Topic for OTA properties and device configuration */
689702
if (_deviceTopicIn == topic) {
690703
CBORDecoder::decode(_device_property_container, (uint8_t*)bytes, length);
704+
DEBUG_VERBOSE("ArduinoIoTCloudTCP::%s [%d] device configuration or OTA message received", __FUNCTION__, millis());
691705
_last_device_subscribe_cnt = 0;
692706
_next_device_subscribe_attempt_tick = 0;
693707
}

0 commit comments

Comments
 (0)