Skip to content

Commit f2d0bdf

Browse files
committed
Add DEBUG prints to follow configuration path
1 parent 98ed735 commit f2d0bdf

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

@@ -329,6 +330,7 @@ void ArduinoIoTCloudTCP::update()
329330
/* Check if the state has changed in message handler */
330331
if(_next_state != State::Invalid)
331332
{
333+
DEBUG_VERBOSE("ArduinoIoTCloudTCP::%s State changed in message handler...", __FUNCTION__);
332334
_state = _next_state;
333335
_next_state = State::Invalid;
334336
}
@@ -405,6 +407,7 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_ConnectMqttBroker()
405407
if (_mqttClient.connect(_brokerAddress.c_str(), _brokerPort))
406408
{
407409
_last_connection_attempt_cnt = 0;
410+
DEBUG_VERBOSE("ArduinoIoTCloudTCP::%s connected to %s:%d", __FUNCTION__, _brokerAddress.c_str(), _brokerPort);
408411
return State::SendDeviceProperties;
409412
}
410413

@@ -425,6 +428,7 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_SendDeviceProperties()
425428
return State::Disconnect;
426429
}
427430

431+
DEBUG_VERBOSE("ArduinoIoTCloudTCP::%s", __FUNCTION__);
428432
sendDevicePropertiesToCloud();
429433
return State::SubscribeDeviceTopic;
430434
}
@@ -441,6 +445,8 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_SubscribeDeviceTopic()
441445
return State::SubscribeDeviceTopic;
442446
}
443447

448+
DEBUG_VERBOSE("ArduinoIoTCloudTCP::%s subscribed to %s", __FUNCTION__, _deviceTopicIn.c_str());
449+
444450
if (_last_device_subscribe_cnt > AIOT_CONFIG_LASTVALUES_SYNC_MAX_RETRY_CNT)
445451
{
446452
_last_device_subscribe_cnt = 0;
@@ -456,6 +462,7 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_SubscribeDeviceTopic()
456462
_next_device_subscribe_attempt_tick = millis() + subscribe_retry_delay;
457463
_last_device_subscribe_cnt++;
458464

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

@@ -474,6 +481,8 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_WaitDeviceConfig()
474481
if (millis() > _next_device_subscribe_attempt_tick)
475482
{
476483
/* 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);
477486
if (_mqttClient.unsubscribe(_deviceTopicIn))
478487
{
479488
return State::SubscribeDeviceTopic;
@@ -492,6 +501,7 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_CheckDeviceConfig()
492501
if(_deviceSubscribedToThing == true)
493502
{
494503
/* Unsubscribe from old things topics and go on with a new subsctiption */
504+
DEBUG_VERBOSE("ArduinoIoTCloudTCP::%s Unsubscribing from old thing topics", __FUNCTION__);
495505
_mqttClient.unsubscribe(_shadowTopicIn);
496506
_mqttClient.unsubscribe(_dataTopicIn);
497507
_deviceSubscribedToThing = false;
@@ -506,6 +516,7 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_CheckDeviceConfig()
506516
attach_retry_delay = min(attach_retry_delay, static_cast<unsigned long>(AIOT_CONFIG_MAX_DEVICE_TOPIC_ATTACH_RETRY_DELAY_ms));
507517
_next_device_subscribe_attempt_tick = millis() + attach_retry_delay;
508518
_last_device_attach_cnt++;
519+
DEBUG_VERBOSE("ArduinoIoTCloudTCP::%s Device not attached to a valid Thing. New Request delay: %d", __FUNCTION__, attach_retry_delay);
509520
return State::WaitDeviceConfig;
510521
}
511522

@@ -517,6 +528,8 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_CheckDeviceConfig()
517528

518529
ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_SubscribeThingTopics()
519530
{
531+
DEBUG_VERBOSE("ArduinoIoTCloudTCP::%s", __FUNCTION__);
532+
520533
if (!_mqttClient.connected())
521534
{
522535
return State::Disconnect;
@@ -716,6 +729,7 @@ void ArduinoIoTCloudTCP::handleMessage(int length)
716729
/* Topic for OTA properties and device configuration */
717730
if (_deviceTopicIn == topic) {
718731
CBORDecoder::decode(_device_property_container, (uint8_t*)bytes, length);
732+
DEBUG_VERBOSE("ArduinoIoTCloudTCP::%s [%d] device configuration or OTA message received", __FUNCTION__, millis());
719733
_last_device_subscribe_cnt = 0;
720734
_next_device_subscribe_attempt_tick = 0;
721735
}

0 commit comments

Comments
 (0)