Skip to content

Commit ce9dba5

Browse files
committed
Add DEBUG prints to follow configuration path
1 parent 33bfe4e commit ce9dba5

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/ArduinoIoTCloudTCP.cpp

+15
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

@@ -327,6 +328,7 @@ void ArduinoIoTCloudTCP::update()
327328
/* Check if the state has changed in message handler */
328329
if(_next_state != State::Invalid)
329330
{
331+
DEBUG_VERBOSE("ArduinoIoTCloudTCP::%s State changed in message handler...", __FUNCTION__);
330332
_state = _next_state;
331333
_next_state = State::Invalid;
332334
}
@@ -403,6 +405,7 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_ConnectMqttBroker()
403405
if (_mqttClient.connect(_brokerAddress.c_str(), _brokerPort))
404406
{
405407
_last_connection_attempt_cnt = 0;
408+
DEBUG_VERBOSE("ArduinoIoTCloudTCP::%s connected to %s:%d", __FUNCTION__, _brokerAddress.c_str(), _brokerPort);
406409
return State::SendDeviceProperties;
407410
}
408411

@@ -423,6 +426,8 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_SendDeviceProperties()
423426
return State::Disconnect;
424427
}
425428

429+
DEBUG_VERBOSE("ArduinoIoTCloudTCP::%s", __FUNCTION__);
430+
426431
#if OTA_ENABLED
427432
sendOTAPropertiesToCloud();
428433
#endif
@@ -441,6 +446,8 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_SubscribeDeviceTopic()
441446
return State::SubscribeDeviceTopic;
442447
}
443448

449+
DEBUG_VERBOSE("ArduinoIoTCloudTCP::%s subscribed to %s", __FUNCTION__, _deviceTopicIn.c_str());
450+
444451
if (_last_device_subscribe_cnt > AIOT_CONFIG_LASTVALUES_SYNC_MAX_RETRY_CNT)
445452
{
446453
_last_device_subscribe_cnt = 0;
@@ -456,6 +463,7 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_SubscribeDeviceTopic()
456463
_next_device_subscribe_attempt_tick = millis() + subscribe_retry_delay;
457464
_last_device_subscribe_cnt++;
458465

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

@@ -474,6 +482,8 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_WaitDeviceConfig()
474482
if (millis() > _next_device_subscribe_attempt_tick)
475483
{
476484
/* 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);
477487
if (_mqttClient.unsubscribe(_deviceTopicIn))
478488
{
479489
return State::SubscribeDeviceTopic;
@@ -492,6 +502,7 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_CheckDeviceConfig()
492502
if(_deviceSubscribedToThing == true)
493503
{
494504
/* Unsubscribe from old things topics and go on with a new subsctiption */
505+
DEBUG_VERBOSE("ArduinoIoTCloudTCP::%s Unsubscribing from old thing topics", __FUNCTION__);
495506
_mqttClient.unsubscribe(_shadowTopicIn);
496507
_mqttClient.unsubscribe(_dataTopicIn);
497508
_deviceSubscribedToThing = false;
@@ -506,6 +517,7 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_CheckDeviceConfig()
506517
attach_retry_delay = min(attach_retry_delay, static_cast<unsigned long>(AIOT_CONFIG_MAX_DEVICE_TOPIC_ATTACH_RETRY_DELAY_ms));
507518
_next_device_subscribe_attempt_tick = millis() + attach_retry_delay;
508519
_last_device_attach_cnt++;
520+
DEBUG_VERBOSE("ArduinoIoTCloudTCP::%s Device not attached to a valid Thing. New Request delay: %d", __FUNCTION__, attach_retry_delay);
509521
return State::WaitDeviceConfig;
510522
}
511523

@@ -517,6 +529,8 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_CheckDeviceConfig()
517529

518530
ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_SubscribeThingTopics()
519531
{
532+
DEBUG_VERBOSE("ArduinoIoTCloudTCP::%s", __FUNCTION__);
533+
520534
if (!_mqttClient.connected())
521535
{
522536
return State::Disconnect;
@@ -687,6 +701,7 @@ void ArduinoIoTCloudTCP::handleMessage(int length)
687701
/* Topic for OTA properties and device configuration */
688702
if (_deviceTopicIn == topic) {
689703
CBORDecoder::decode(_device_property_container, (uint8_t*)bytes, length);
704+
DEBUG_VERBOSE("ArduinoIoTCloudTCP::%s [%d] device configuration or OTA message received", __FUNCTION__, millis());
690705
_last_device_subscribe_cnt = 0;
691706
_next_device_subscribe_attempt_tick = 0;
692707
}

0 commit comments

Comments
 (0)