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 all commits
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
6 changes: 6 additions & 0 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,6 +397,7 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_SubscribeMqttTopics()
return State::ConnectPhy;
}

DEBUG_VERBOSE("ArduinoIoTCloudTCP::%s subscribing to %s ...", __FUNCTION__, _dataTopicIn.c_str());
if (!_mqttClient.subscribe(_dataTopicIn))
{
DEBUG_ERROR("ArduinoIoTCloudTCP::%s could not subscribe to %s", __FUNCTION__, _dataTopicIn.c_str());
Expand All @@ -403,9 +406,11 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_SubscribeMqttTopics()
#endif
return State::SubscribeMqttTopics;
}
DEBUG_VERBOSE("ArduinoIoTCloudTCP::%s subscribed to %s", __FUNCTION__, _dataTopicIn.c_str());

if (_shadowTopicIn != "")
{
DEBUG_VERBOSE("ArduinoIoTCloudTCP::%s subscribing to %s ...", __FUNCTION__, _shadowTopicIn.c_str());
if (!_mqttClient.subscribe(_shadowTopicIn))
{
DEBUG_ERROR("ArduinoIoTCloudTCP::%s could not subscribe to %s", __FUNCTION__, _shadowTopicIn.c_str());
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
5 changes: 5 additions & 0 deletions src/utility/ota/OTA-nano-rp2040.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ int rp2040_connect_onOTARequest(char const * ota_url)

watchdog_reset();

DEBUG_VERBOSE("%s downloading: %s", __FUNCTION__, ota_url);

URI url(ota_url);
Client * client = nullptr;
int port = 0;
Expand Down Expand Up @@ -233,6 +235,7 @@ int rp2040_connect_onOTARequest(char const * ota_url)

DEBUG_INFO("%s: %d bytes received", __FUNCTION__, ftell(file));
fclose(file);
DEBUG_VERBOSE("%s download successful", __FUNCTION__);

/* Unmount the filesystem. */
if ((err = fs.unmount()) != 0)
Expand All @@ -241,6 +244,8 @@ int rp2040_connect_onOTARequest(char const * ota_url)
return static_cast<int>(OTAError::RP2040_ErrorUnmount);
}

DEBUG_VERBOSE("%s performing reset to reboot", __FUNCTION__);

/* Perform the reset to reboot to SFU. */
mbed_watchdog_trigger_reset();
/* If watchdog is enabled we should not reach this point */
Expand Down
3 changes: 3 additions & 0 deletions src/utility/ota/OTA-portenta-h7.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ int portenta_h7_onOTARequest(char const * ota_url)
watchdog_reset();

/* Download the OTA file from the web storage location. */
DEBUG_VERBOSE("Arduino_Portenta_OTA_QSPI::download(%s) started", ota_url);
int const ota_portenta_qspi_download_ret_code = ota_portenta_qspi.download(ota_url, true /* is_https */);
DEBUG_VERBOSE("Arduino_Portenta_OTA_QSPI::download(%s) returns %d", ota_url, ota_portenta_qspi_download_ret_code);

Expand All @@ -83,6 +84,8 @@ int portenta_h7_onOTARequest(char const * ota_url)
return static_cast<int>(ota_portenta_err);
}

DEBUG_VERBOSE("Arduino_Portenta_OTA_QSPI::reboot() performing reset to reboot");

/* Perform the reset to reboot - then the bootloader performs the actual application update. */
NVIC_SystemReset();
}
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