Skip to content

Commit f98c0c6

Browse files
author
Maurizio Branca
committed
Add logs on OTA process steps
These additional log statements highlight each step in the Over-the-Air (OTA) update process.
1 parent 5e19f33 commit f98c0c6

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

src/AIoTC_Config.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
# if defined(ARDUINO_AVR_UNO_WIFI_REV2)
6363
# define DEBUG_VERBOSE(fmt, ...)
6464
# else
65-
# define DEBUG_VERBOSE(fmt, ...) //Debug.print(DBG_VERBOSE, fmt, ## __VA_ARGS__)
65+
# define DEBUG_VERBOSE(fmt, ...) Debug.print(DBG_VERBOSE, fmt, ## __VA_ARGS__)
6666
# endif
6767
#endif
6868

src/ArduinoIoTCloudTCP.cpp

+8-2
Original file line numberDiff line numberDiff line change
@@ -369,8 +369,10 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_SyncTime()
369369

370370
ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_ConnectMqttBroker()
371371
{
372+
DEBUG_VERBOSE("ArduinoIoTCloudTCP::%s connecting to %s:%d (attempt %d)", __FUNCTION__, _brokerAddress.c_str(), _brokerPort, _last_connection_attempt_cnt);
372373
if (_mqttClient.connect(_brokerAddress.c_str(), _brokerPort))
373374
{
375+
DEBUG_VERBOSE("ArduinoIoTCloudTCP::%s connected to %s:%d", __FUNCTION__, _brokerAddress.c_str(), _brokerPort);
374376
_last_connection_attempt_cnt = 0;
375377
return State::SubscribeMqttTopics;
376378
}
@@ -395,18 +397,21 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_SubscribeMqttTopics()
395397
return State::ConnectPhy;
396398
}
397399

398-
if (!_mqttClient.subscribe(_dataTopicIn))
400+
DEBUG_VERBOSE("ArduinoIoTCloudTCP::%s subscribing to %s ...", __FUNCTION__, _dataTopicIn.c_str());
401+
if (!_mqttClient.subscribe(_dataTopicIn, 0))
399402
{
400403
DEBUG_ERROR("ArduinoIoTCloudTCP::%s could not subscribe to %s", __FUNCTION__, _dataTopicIn.c_str());
401404
#if !defined(__AVR__)
402405
DEBUG_ERROR("Check your thing configuration, and press the reset button on your board.");
403406
#endif
404407
return State::SubscribeMqttTopics;
405408
}
409+
DEBUG_VERBOSE("ArduinoIoTCloudTCP::%s subscribed to %s", __FUNCTION__, _dataTopicIn.c_str());
406410

407411
if (_shadowTopicIn != "")
408412
{
409-
if (!_mqttClient.subscribe(_shadowTopicIn))
413+
DEBUG_VERBOSE("ArduinoIoTCloudTCP::%s subscribing to %s ...", __FUNCTION__, _shadowTopicIn.c_str());
414+
if (!_mqttClient.subscribe(_shadowTopicIn, 0))
410415
{
411416
DEBUG_ERROR("ArduinoIoTCloudTCP::%s could not subscribe to %s", __FUNCTION__, _shadowTopicIn.c_str());
412417
#if !defined(__AVR__)
@@ -415,6 +420,7 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_SubscribeMqttTopics()
415420
return State::SubscribeMqttTopics;
416421
}
417422
}
423+
DEBUG_VERBOSE("ArduinoIoTCloudTCP::%s subscribed to %s", __FUNCTION__, _shadowTopicIn.c_str());
418424

419425
DEBUG_INFO("Connected to Arduino IoT Cloud");
420426
execCloudEventCallback(ArduinoIoTCloudEvent::CONNECT);

src/utility/ota/OTA-samd.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ int samd_onOTARequest(char const * ota_url)
4747

4848
watchdog_reset();
4949

50+
DEBUG_VERBOSE("ArduinoIoTCloudTCP::%s downloading to nina: %s", __FUNCTION__, ota_url);
5051
/* Trigger direct download to nina module. */
5152
uint8_t nina_ota_err_code = 0;
5253
if (!WiFiStorage.downloadOTA(ota_url, &nina_ota_err_code))
@@ -55,6 +56,9 @@ int samd_onOTARequest(char const * ota_url)
5556
return static_cast<int>(OTAError::DownloadFailed);
5657
}
5758

59+
DEBUG_VERBOSE("ArduinoIoTCloudTCP::%s download successful", __FUNCTION__);
60+
DEBUG_VERBOSE("ArduinoIoTCloudTCP::%s performing reset to reboot", __FUNCTION__);
61+
5862
/* Perform the reset to reboot to SxU. */
5963
NVIC_SystemReset();
6064
#endif /* OTA_STORAGE_SNU */

0 commit comments

Comments
 (0)