From 824f9c4f8f5e15458ef0397f8c08bc6a8b2b2708 Mon Sep 17 00:00:00 2001 From: pennam Date: Fri, 6 Jun 2025 10:07:46 +0200 Subject: [PATCH 1/9] Device: fix missing initializer warnign --- src/ArduinoIoTCloudDevice.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ArduinoIoTCloudDevice.cpp b/src/ArduinoIoTCloudDevice.cpp index 58f00d202..17ce9626b 100644 --- a/src/ArduinoIoTCloudDevice.cpp +++ b/src/ArduinoIoTCloudDevice.cpp @@ -110,7 +110,7 @@ ArduinoCloudDevice::State ArduinoCloudDevice::handleSendCapabilities() { deliver(reinterpret_cast(&deviceBegin)); /* Subscribe to device topic to request */ - ThingBeginCmd thingBegin = { ThingBeginCmdId }; + ThingBeginCmd thingBegin = { ThingBeginCmdId, {} }; deliver(reinterpret_cast(&thingBegin)); /* No device configuration received. Wait: 4s -> 8s -> 16s -> 32s -> 32s ...*/ From 08f8b58c463193bb3237f2b4e505f3fb3f99a611 Mon Sep 17 00:00:00 2001 From: pennam Date: Fri, 6 Jun 2025 10:08:23 +0200 Subject: [PATCH 2/9] CloudTelevision: suppress aliasing warning --- src/property/types/automation/CloudTelevision.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/property/types/automation/CloudTelevision.h b/src/property/types/automation/CloudTelevision.h index 75967dd4f..f1d203d3b 100644 --- a/src/property/types/automation/CloudTelevision.h +++ b/src/property/types/automation/CloudTelevision.h @@ -226,8 +226,14 @@ class CloudTelevision : public Property { setAttribute(_cloud_value.swi, "swi"); setAttribute(_cloud_value.vol, "vol"); setAttribute(_cloud_value.mut, "mut"); +/* PlaybackCommands and InputValue are enum of type int so we can safely disable + * strict aliasing warnings here. + */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstrict-aliasing" setAttribute((int&)_cloud_value.pbc, "pbc"); setAttribute((int&)_cloud_value.inp, "inp"); +#pragma GCC diagnostic pop setAttribute(_cloud_value.cha, "cha"); } }; From 79eb0ca186c8b1148ef25b7cbf1ad432aa840c4d Mon Sep 17 00:00:00 2001 From: pennam Date: Fri, 6 Jun 2025 10:09:46 +0200 Subject: [PATCH 3/9] UNOR4 OTA: suppress unused variable warning --- src/ota/implementation/OTAUnoR4.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ota/implementation/OTAUnoR4.cpp b/src/ota/implementation/OTAUnoR4.cpp index 5ba12afa9..68a06d775 100644 --- a/src/ota/implementation/OTAUnoR4.cpp +++ b/src/ota/implementation/OTAUnoR4.cpp @@ -32,6 +32,7 @@ UNOR4OTACloudProcess::UNOR4OTACloudProcess(MessageStream *ms) } OTACloudProcessInterface::State UNOR4OTACloudProcess::resume(Message* msg) { + (void)msg; return OtaBegin; } From 59e326fece5fa34b6fa0012db2a2199449904e75 Mon Sep 17 00:00:00 2001 From: pennam Date: Fri, 6 Jun 2025 10:10:35 +0200 Subject: [PATCH 4/9] UNOR4 OTA: remove unused variable --- src/ota/implementation/OTAUnoR4.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/ota/implementation/OTAUnoR4.cpp b/src/ota/implementation/OTAUnoR4.cpp index 68a06d775..e630f9d13 100644 --- a/src/ota/implementation/OTAUnoR4.cpp +++ b/src/ota/implementation/OTAUnoR4.cpp @@ -58,8 +58,6 @@ OTACloudProcessInterface::State UNOR4OTACloudProcess::startOTA() { } OTACloudProcessInterface::State UNOR4OTACloudProcess::fetch() { - int ota_err = OTAUpdate::OTA_ERROR_NONE; - String fv = WiFi.firmwareVersion(); if(fv >= "0.5.0") { auto progress = ota.downloadProgress(); From 87766d8cdc531f834ea3793b436ce59919276f2e Mon Sep 17 00:00:00 2001 From: pennam Date: Fri, 6 Jun 2025 10:14:10 +0200 Subject: [PATCH 5/9] UNOR4 OTA: add missing return value --- src/ota/implementation/OTAUnoR4.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/ota/implementation/OTAUnoR4.cpp b/src/ota/implementation/OTAUnoR4.cpp index e630f9d13..9569960fd 100644 --- a/src/ota/implementation/OTAUnoR4.cpp +++ b/src/ota/implementation/OTAUnoR4.cpp @@ -105,6 +105,8 @@ OTACloudProcessInterface::State UNOR4OTACloudProcess::flashOTA() { } OTACloudProcessInterface::State UNOR4OTACloudProcess::reboot() { + /* This is never called; the microcontroller reboots in flashOTA state */ + return Resume; } void UNOR4OTACloudProcess::reset() { From 7623846b43984f608305aa28516daf8e70c18446 Mon Sep 17 00:00:00 2001 From: pennam Date: Fri, 6 Jun 2025 10:16:00 +0200 Subject: [PATCH 6/9] UNOR4 OTA: add missing return value --- src/ota/implementation/OTAUnoR4.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/ota/implementation/OTAUnoR4.cpp b/src/ota/implementation/OTAUnoR4.cpp index 9569960fd..3fd014d9a 100644 --- a/src/ota/implementation/OTAUnoR4.cpp +++ b/src/ota/implementation/OTAUnoR4.cpp @@ -98,10 +98,13 @@ OTACloudProcessInterface::State UNOR4OTACloudProcess::flashOTA() { } /* Flash new firmware */ - if ((ota_err = ota.update(UPDATE_FILE_NAME)) != OTAUpdate::OTA_ERROR_NONE) { // This reboots the MCU + if ((ota_err = ota.update(UPDATE_FILE_NAME)) != OTAUpdate::OTA_ERROR_NONE) { DEBUG_VERBOSE("OTAUpdate::update() failed with %d", ota_err); return convertUnor4ErrorToState(ota_err); } + + /* This is never called because ota.uptade reboots the microcontroller */ + return Resume; } OTACloudProcessInterface::State UNOR4OTACloudProcess::reboot() { From 86bbcc114fde0aaa1405b8fac7eeaf89ec1d99d9 Mon Sep 17 00:00:00 2001 From: pennam Date: Fri, 6 Jun 2025 10:20:44 +0200 Subject: [PATCH 7/9] OTAInterface: add missing initializers --- src/ota/interface/OTAInterface.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/ota/interface/OTAInterface.cpp b/src/ota/interface/OTAInterface.cpp index e72d062d4..13644cabb 100644 --- a/src/ota/interface/OTAInterface.cpp +++ b/src/ota/interface/OTAInterface.cpp @@ -106,6 +106,7 @@ OTACloudProcessInterface::State OTACloudProcessInterface::otaBegin() { struct OtaBeginUp msg = { OtaBeginUpId, + {} }; SHA256 sha256_calc; @@ -199,6 +200,7 @@ void OTACloudProcessInterface::reportStatus(int32_t state_data) { struct OtaProgressCmdUp msg = { OtaProgressCmdUpId, + {} }; memcpy(msg.params.id, context->id, ID_SIZE); From aad8c4b1435e24f265c2e25f8d267faa07fc95ad Mon Sep 17 00:00:00 2001 From: pennam Date: Fri, 6 Jun 2025 10:21:26 +0200 Subject: [PATCH 8/9] OTAInterfaceDefault: remove unused static function declaration --- src/ota/interface/OTAInterfaceDefault.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/ota/interface/OTAInterfaceDefault.cpp b/src/ota/interface/OTAInterfaceDefault.cpp index fbea43e68..97389d430 100644 --- a/src/ota/interface/OTAInterfaceDefault.cpp +++ b/src/ota/interface/OTAInterfaceDefault.cpp @@ -14,8 +14,6 @@ #include "OTAInterfaceDefault.h" #include "../OTA.h" -static uint32_t crc_update(uint32_t crc, const void * data, size_t data_len); - OTADefaultCloudProcessInterface::OTADefaultCloudProcessInterface(MessageStream *ms, Client* client) : OTACloudProcessInterface(ms) , client(client) From fd2e4eee8bb71fce741b97b2cf53e197e9da6761 Mon Sep 17 00:00:00 2001 From: pennam Date: Fri, 6 Jun 2025 10:35:16 +0200 Subject: [PATCH 9/9] UNOR4 OTA: fix signed comparison warning --- src/ota/implementation/OTAUnoR4.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/ota/implementation/OTAUnoR4.cpp b/src/ota/implementation/OTAUnoR4.cpp index 3fd014d9a..afe37b4a7 100644 --- a/src/ota/implementation/OTAUnoR4.cpp +++ b/src/ota/implementation/OTAUnoR4.cpp @@ -59,19 +59,24 @@ OTACloudProcessInterface::State UNOR4OTACloudProcess::startOTA() { OTACloudProcessInterface::State UNOR4OTACloudProcess::fetch() { String fv = WiFi.firmwareVersion(); - if(fv >= "0.5.0") { + /* Firmware supports non blocking OTA */ + if (fv >= "0.5.0") { auto progress = ota.downloadProgress(); + if (progress < 0) { + return OtaDownloadFail; + } - if((millis() - context->lastReportTime) > 5000) { // Report the download progress each X millisecond + if ((millis() - context->lastReportTime) > 5000) { // Report the download progress each X millisecond DEBUG_VERBOSE("OTA Download Progress %d/%d", progress, context->downloadSize); reportStatus(progress); context->lastReportTime = millis(); } - if(progress < context->downloadSize) { + /* It is safe to cast progress here because we are sure that is positive */ + if ((size_t)progress < context->downloadSize) { return Fetch; - } else if(progress > context->downloadSize || progress < 0) { + } else if ((size_t)progress > context->downloadSize) { return OtaDownloadFail; } else { return FlashOTA; @@ -84,7 +89,6 @@ OTACloudProcessInterface::State UNOR4OTACloudProcess::fetch() { } DEBUG_VERBOSE("OTAUpdate::download() %d bytes downloaded", ota_download); - return FlashOTA; } }