Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add logs on OTA process steps #282

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/AIoTC_Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
# if defined(ARDUINO_AVR_UNO_WIFI_REV2)
# define DEBUG_VERBOSE(fmt, ...)
# else
# define DEBUG_VERBOSE(fmt, ...) //Debug.print(DBG_VERBOSE, fmt, ## __VA_ARGS__)
# define DEBUG_VERBOSE(fmt, ...) Debug.print(DBG_VERBOSE, fmt, ## __VA_ARGS__)
# endif
#endif

Expand Down
10 changes: 8 additions & 2 deletions src/ArduinoIoTCloudTCP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,8 +369,10 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_SyncTime()

ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_ConnectMqttBroker()
{
DEBUG_VERBOSE("ArduinoIoTCloudTCP::%s connecting to %s:%d (attempt %d)", __FUNCTION__, _brokerAddress.c_str(), _brokerPort, _last_connection_attempt_cnt);
if (_mqttClient.connect(_brokerAddress.c_str(), _brokerPort))
{
DEBUG_VERBOSE("ArduinoIoTCloudTCP::%s connected to %s:%d", __FUNCTION__, _brokerAddress.c_str(), _brokerPort);
_last_connection_attempt_cnt = 0;
return State::SubscribeMqttTopics;
}
Expand All @@ -395,18 +397,21 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_SubscribeMqttTopics()
return State::ConnectPhy;
}

if (!_mqttClient.subscribe(_dataTopicIn))
DEBUG_VERBOSE("ArduinoIoTCloudTCP::%s subscribing to %s ...", __FUNCTION__, _dataTopicIn.c_str());
if (!_mqttClient.subscribe(_dataTopicIn, 0))
{
DEBUG_ERROR("ArduinoIoTCloudTCP::%s could not subscribe to %s", __FUNCTION__, _dataTopicIn.c_str());
#if !defined(__AVR__)
DEBUG_ERROR("Check your thing configuration, and press the reset button on your board.");
#endif
return State::SubscribeMqttTopics;
}
DEBUG_VERBOSE("ArduinoIoTCloudTCP::%s subscribed to %s", __FUNCTION__, _dataTopicIn.c_str());

if (_shadowTopicIn != "")
{
if (!_mqttClient.subscribe(_shadowTopicIn))
DEBUG_VERBOSE("ArduinoIoTCloudTCP::%s subscribing to %s ...", __FUNCTION__, _shadowTopicIn.c_str());
if (!_mqttClient.subscribe(_shadowTopicIn, 0))
zmoog marked this conversation as resolved.
Show resolved Hide resolved
{
DEBUG_ERROR("ArduinoIoTCloudTCP::%s could not subscribe to %s", __FUNCTION__, _shadowTopicIn.c_str());
#if !defined(__AVR__)
Expand All @@ -415,6 +420,7 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_SubscribeMqttTopics()
return State::SubscribeMqttTopics;
}
}
DEBUG_VERBOSE("ArduinoIoTCloudTCP::%s subscribed to %s", __FUNCTION__, _shadowTopicIn.c_str());

DEBUG_INFO("Connected to Arduino IoT Cloud");
execCloudEventCallback(ArduinoIoTCloudEvent::CONNECT);
Expand Down
4 changes: 4 additions & 0 deletions src/utility/ota/OTA-samd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ int samd_onOTARequest(char const * ota_url)

watchdog_reset();

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

DEBUG_VERBOSE("ArduinoIoTCloudTCP::%s download successful", __FUNCTION__);
DEBUG_VERBOSE("ArduinoIoTCloudTCP::%s performing reset to reboot", __FUNCTION__);

/* Perform the reset to reboot to SxU. */
NVIC_SystemReset();
#endif /* OTA_STORAGE_SNU */
Expand Down