Skip to content

Reduce build warnings #556

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

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
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/ArduinoIoTCloudDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ ArduinoCloudDevice::State ArduinoCloudDevice::handleSendCapabilities() {
deliver(reinterpret_cast<Message*>(&deviceBegin));

/* Subscribe to device topic to request */
ThingBeginCmd thingBegin = { ThingBeginCmdId };
ThingBeginCmd thingBegin = { ThingBeginCmdId, {} };
deliver(reinterpret_cast<Message*>(&thingBegin));

/* No device configuration received. Wait: 4s -> 8s -> 16s -> 32s -> 32s ...*/
Expand Down
24 changes: 16 additions & 8 deletions src/ota/implementation/OTAUnoR4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ UNOR4OTACloudProcess::UNOR4OTACloudProcess(MessageStream *ms)
}

OTACloudProcessInterface::State UNOR4OTACloudProcess::resume(Message* msg) {
(void)msg;
return OtaBegin;
}

Expand All @@ -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;
Expand All @@ -85,7 +89,6 @@ OTACloudProcessInterface::State UNOR4OTACloudProcess::fetch() {
}

DEBUG_VERBOSE("OTAUpdate::download() %d bytes downloaded", ota_download);

return FlashOTA;
}
}
Expand All @@ -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() {
Expand Down
2 changes: 2 additions & 0 deletions src/ota/interface/OTAInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ OTACloudProcessInterface::State OTACloudProcessInterface::otaBegin() {

struct OtaBeginUp msg = {
OtaBeginUpId,
{}
};

SHA256 sha256_calc;
Expand Down Expand Up @@ -199,6 +200,7 @@ void OTACloudProcessInterface::reportStatus(int32_t state_data) {

struct OtaProgressCmdUp msg = {
OtaProgressCmdUpId,
{}
};

memcpy(msg.params.id, context->id, ID_SIZE);
Expand Down
2 changes: 0 additions & 2 deletions src/ota/interface/OTAInterfaceDefault.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions src/property/types/automation/CloudTelevision.h
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
};
Expand Down
Loading