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

OTA: chunked download #520

Merged
merged 18 commits into from
Dec 16, 2024
Merged

Conversation

pennam
Copy link
Collaborator

@pennam pennam commented Dec 11, 2024

This pull request introduces several changes to the OTA update process in the Arduino IoT Cloud library. The key changes focus on improving the reliability of OTA updates by adding support for chunked downloads and refining OTA policy management.

Improvements to OTA policy management:

  • src/ArduinoIoTCloudTCP.h: Replaced setOtaPolicies with enableOtaPolicy and disableOtaPolicy methods to manage OTA policies more flexibly. Added a new method setOTAChunkMode to enable or disable chunked downloads.
  • src/ota/interface/OTAInterface.cpp: Updated the otaAvailable method to use the new getOtaPolicy method for checking OTA policies.
  • src/ota/interface/OTAInterface.h: Added new methods enableOtaPolicy, disableOtaPolicy, and getOtaPolicy to manage OTA policies. Introduced a new ChunkDownload flag for chunked downloads.

Enhancements to OTA download process:

  • src/ota/interface/OTAInterfaceDefault.cpp: Refactored the startOTA and fetch methods to support chunked downloads. Added a new method requestOta to handle HTTP requests for OTA updates, including chunked requests.
  • src/ota/interface/OTAInterfaceDefault.h: Added new constants and methods to support chunked downloads, including maxChunkSize, requestOta, and fetchMore. Updated the Context struct to include new fields for managing chunked downloads.

Copy link

codecov bot commented Dec 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.39%. Comparing base (d97fe31) to head (0f53459).
Report is 21 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #520   +/-   ##
=======================================
  Coverage   95.39%   95.39%           
=======================================
  Files          33       33           
  Lines        1520     1520           
=======================================
  Hits         1450     1450           
  Misses         70       70           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@per1234 per1234 added type: enhancement Proposed improvement topic: code Related to content of the project itself labels Dec 11, 2024
@pennam
Copy link
Collaborator Author

pennam commented Dec 11, 2024

@andreagilardoni would it be better to use OtaFlags instead of adding a new enum to select the download mode?

@andreagilardoni
Copy link
Contributor

@andreagilardoni would it be better to use OtaFlags instead of adding a new enum to select the download mode?

I think you are right! this could be a good use for them, since they are designed to accommodate settings for the OtaProcedure

@pennam pennam changed the title OTA: chunked download (ETH) OTA: chunked download Dec 12, 2024
@arduino-libraries arduino-libraries deleted a comment from github-actions bot Dec 12, 2024
@arduino-libraries arduino-libraries deleted a comment from github-actions bot Dec 12, 2024
@arduino-libraries arduino-libraries deleted a comment from github-actions bot Dec 12, 2024
Copy link

Memory usage change @ 0f53459

Board flash % RAM for global variables %
arduino:esp32:nano_nora 🔺 0 - +352 0.0 - +0.01 0 - 0 0.0 - 0.0
arduino:mbed_edge:edge_control 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:mbed_giga:giga 🔺 0 - +216 0.0 - +0.01 0 - 0 0.0 - 0.0
arduino:mbed_nano:nanorp2040connect 🔺 0 - +226 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:mbed_nicla:nicla_vision 🔺 0 - +216 0.0 - +0.01 0 - 0 0.0 - 0.0
arduino:mbed_opta:opta 🔺 0 - +216 0.0 - +0.01 0 - 0 0.0 - 0.0
arduino:mbed_portenta:envie_m7 N/A N/A N/A N/A
arduino:renesas_portenta:portenta_c33 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:renesas_uno:unor4wifi 🔺 0 - +16 0.0 - +0.01 0 - 0 0.0 - 0.0
arduino:samd:mkr1000 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:samd:mkrgsm1400 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:samd:mkrnb1500 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:samd:mkrwan1300 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:samd:mkrwifi1010 💚 -8 - 0 -0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:samd:nano_33_iot 💚 -8 - 0 -0.0 - 0.0 0 - 0 0.0 - 0.0
esp32:esp32:esp32 🔺 0 - +372 0.0 - +0.03 0 - 0 0.0 - 0.0
esp8266:esp8266:huzzah 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
Click for full report table
Board examples/ArduinoIoTCloud-Advanced
flash
% examples/ArduinoIoTCloud-Advanced
RAM for global variables
% examples/ArduinoIoTCloud-Basic
flash
% examples/ArduinoIoTCloud-Basic
RAM for global variables
% examples/ArduinoIoTCloud-Callbacks
flash
% examples/ArduinoIoTCloud-Callbacks
RAM for global variables
% examples/ArduinoIoTCloud-Schedule
flash
% examples/ArduinoIoTCloud-Schedule
RAM for global variables
% examples/utility/ArduinoIoTCloud_Travis_CI
flash
% examples/utility/ArduinoIoTCloud_Travis_CI
RAM for global variables
% examples/ArduinoIoTCloud-DeferredOTA
flash
% examples/ArduinoIoTCloud-DeferredOTA
RAM for global variables
% examples/ArduinoIoTCloud-Notecard
flash
% examples/ArduinoIoTCloud-Notecard
RAM for global variables
% examples/utility/Provisioning
flash
% examples/utility/Provisioning
RAM for global variables
% examples/utility/SelfProvisioning
flash
% examples/utility/SelfProvisioning
RAM for global variables
%
arduino:esp32:nano_nora 352 0.01 0 0.0 340 0.01 0 0.0 336 0.01 0 0.0 328 0.01 0 0.0 340 0.01 0 0.0 348 0.01 0 0.0 0 0.0 0 0.0
arduino:mbed_edge:edge_control 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0
arduino:mbed_giga:giga 216 0.01 0 0.0 216 0.01 0 0.0 216 0.01 0 0.0 208 0.01 0 0.0 208 0.01 0 0.0 216 0.01 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0
arduino:mbed_nano:nanorp2040connect 222 0.0 0 0.0 222 0.0 0 0.0 222 0.0 0 0.0 222 0.0 0 0.0 222 0.0 0 0.0 226 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0
arduino:mbed_nicla:nicla_vision 208 0.01 0 0.0 216 0.01 0 0.0 208 0.01 0 0.0 216 0.01 0 0.0 216 0.01 0 0.0 208 0.01 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0
arduino:mbed_opta:opta 216 0.01 0 0.0 208 0.01 0 0.0 216 0.01 0 0.0 208 0.01 0 0.0 208 0.01 0 0.0 216 0.01 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0
arduino:mbed_portenta:envie_m7 N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A
arduino:renesas_portenta:portenta_c33 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0
arduino:renesas_uno:unor4wifi 16 0.01 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 16 0.01 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0
arduino:samd:mkr1000 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0
arduino:samd:mkrgsm1400 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0
arduino:samd:mkrnb1500 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0
arduino:samd:mkrwan1300 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0
arduino:samd:mkrwifi1010 -8 -0.0 0 0.0 -8 -0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0
arduino:samd:nano_33_iot -8 -0.0 0 0.0 -8 -0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0
esp32:esp32:esp32 340 0.03 0 0.0 352 0.03 0 0.0 352 0.03 0 0.0 356 0.03 0 0.0 328 0.03 0 0.0 372 0.03 0 0.0 0 0.0 0 0.0
esp8266:esp8266:huzzah 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0
Click for full report CSV
Board,examples/ArduinoIoTCloud-Advanced<br>flash,%,examples/ArduinoIoTCloud-Advanced<br>RAM for global variables,%,examples/ArduinoIoTCloud-Basic<br>flash,%,examples/ArduinoIoTCloud-Basic<br>RAM for global variables,%,examples/ArduinoIoTCloud-Callbacks<br>flash,%,examples/ArduinoIoTCloud-Callbacks<br>RAM for global variables,%,examples/ArduinoIoTCloud-Schedule<br>flash,%,examples/ArduinoIoTCloud-Schedule<br>RAM for global variables,%,examples/utility/ArduinoIoTCloud_Travis_CI<br>flash,%,examples/utility/ArduinoIoTCloud_Travis_CI<br>RAM for global variables,%,examples/ArduinoIoTCloud-DeferredOTA<br>flash,%,examples/ArduinoIoTCloud-DeferredOTA<br>RAM for global variables,%,examples/ArduinoIoTCloud-Notecard<br>flash,%,examples/ArduinoIoTCloud-Notecard<br>RAM for global variables,%,examples/utility/Provisioning<br>flash,%,examples/utility/Provisioning<br>RAM for global variables,%,examples/utility/SelfProvisioning<br>flash,%,examples/utility/SelfProvisioning<br>RAM for global variables,%
arduino:esp32:nano_nora,352,0.01,0,0.0,340,0.01,0,0.0,336,0.01,0,0.0,328,0.01,0,0.0,340,0.01,0,0.0,348,0.01,0,0.0,0,0.0,0,0.0
arduino:mbed_edge:edge_control,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,,,,,0,0.0,0,0.0
arduino:mbed_giga:giga,216,0.01,0,0.0,216,0.01,0,0.0,216,0.01,0,0.0,208,0.01,0,0.0,208,0.01,0,0.0,216,0.01,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0
arduino:mbed_nano:nanorp2040connect,222,0.0,0,0.0,222,0.0,0,0.0,222,0.0,0,0.0,222,0.0,0,0.0,222,0.0,0,0.0,226,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0
arduino:mbed_nicla:nicla_vision,208,0.01,0,0.0,216,0.01,0,0.0,208,0.01,0,0.0,216,0.01,0,0.0,216,0.01,0,0.0,208,0.01,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,,,,
arduino:mbed_opta:opta,216,0.01,0,0.0,208,0.01,0,0.0,216,0.01,0,0.0,208,0.01,0,0.0,208,0.01,0,0.0,216,0.01,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,,,,
arduino:mbed_portenta:envie_m7,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,,,,
arduino:renesas_portenta:portenta_c33,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,,,,,0,0.0,0,0.0,0,0.0,0,0.0,,,,
arduino:renesas_uno:unor4wifi,16,0.01,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,16,0.01,0,0.0,0,0.0,0,0.0,,,,,0,0.0,0,0.0,,,,,,,,
arduino:samd:mkr1000,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,,,,,0,0.0,0,0.0,0,0.0,0,0.0,,,,
arduino:samd:mkrgsm1400,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,,,,,0,0.0,0,0.0,0,0.0,0,0.0,,,,
arduino:samd:mkrnb1500,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,,,,,0,0.0,0,0.0,0,0.0,0,0.0,,,,
arduino:samd:mkrwan1300,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,,,,,0,0.0,0,0.0,,,,,,,,
arduino:samd:mkrwifi1010,-8,-0.0,0,0.0,-8,-0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0
arduino:samd:nano_33_iot,-8,-0.0,0,0.0,-8,-0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0
esp32:esp32:esp32,340,0.03,0,0.0,352,0.03,0,0.0,352,0.03,0,0.0,356,0.03,0,0.0,328,0.03,0,0.0,372,0.03,0,0.0,0,0.0,0,0.0,,,,,,,,
esp8266:esp8266:huzzah,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,,,,,,,,,,,,,,,,

@arduino-libraries arduino-libraries deleted a comment from github-actions bot Dec 12, 2024
@pennam pennam merged commit a5dcd3d into arduino-libraries:master Dec 16, 2024
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: code Related to content of the project itself type: enhancement Proposed improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants