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 ...*/ diff --git a/src/ota/implementation/OTAUnoR4.cpp b/src/ota/implementation/OTAUnoR4.cpp index 5ba12afa9..afe37b4a7 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; } @@ -57,22 +58,25 @@ OTACloudProcessInterface::State UNOR4OTACloudProcess::startOTA() { } OTACloudProcessInterface::State UNOR4OTACloudProcess::fetch() { - int ota_err = OTAUpdate::OTA_ERROR_NONE; - 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; @@ -85,7 +89,6 @@ OTACloudProcessInterface::State UNOR4OTACloudProcess::fetch() { } DEBUG_VERBOSE("OTAUpdate::download() %d bytes downloaded", ota_download); - return FlashOTA; } } @@ -99,13 +102,18 @@ 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() { + /* This is never called; the microcontroller reboots in flashOTA state */ + return Resume; } void UNOR4OTACloudProcess::reset() { 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); 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) 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"); } };