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

TCP: do not disconnect if ota client is connected #532

Merged
merged 1 commit into from
Feb 25, 2025

Conversation

pennam
Copy link
Collaborator

@pennam pennam commented Feb 19, 2025

It can happen that mqttclient disconnects during ota fetching. In this case we should also check for ota client state before go in disconnected state.

If ota client is still connected is better to give ota priority and try to finish to download before disconnect.

@andreagilardoni
Copy link
Contributor

Should we instead move this logic inside of ArduinoIoTCloudTCP::update()?

  • In this way the ota process is independent from the mqtt client and is able to continue, even if the client is disconnected.
  • The Mqtt client, in the mean time, is able to be restored
  • If the failure is at network level both will fail and the ota FSM handles it by itself
  • ota are triggered by mqtt incoming commands, so nothing strange will happen on that case

What do you think about it?

Copy link

codecov bot commented Feb 19, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.39%. Comparing base (0ae902b) to head (30c7001).
Report is 3 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #532   +/-   ##
=======================================
  Coverage   95.39%   95.39%           
=======================================
  Files          33       33           
  Lines        1521     1521           
=======================================
  Hits         1451     1451           
  Misses         70       70           

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

@pennam
Copy link
Collaborator Author

pennam commented Feb 19, 2025

Should we instead move this logic inside of ArduinoIoTCloudTCP::update()?

  • In this way the ota process is independent from the mqtt client and is able to continue, even if the client is disconnected.
  • The Mqtt client, in the mean time, is able to be restored
  • If the failure is at network level both will fail and the ota FSM handles it by itself
  • ota are triggered by mqtt incoming commands, so nothing strange will happen on that case

What do you think about it?

what exactly do you want to move in the update function?

@andreagilardoni
Copy link
Contributor

I think that moving the call for _ota.update(); could be just enough

This comment was marked as outdated.

@pennam pennam force-pushed the check-ota-before-disconnect branch from a3b42b7 to b0d6092 Compare February 19, 2025 14:21

This comment was marked as outdated.

@andreagilardoni andreagilardoni force-pushed the check-ota-before-disconnect branch 3 times, most recently from 3b3e82c to 63838f5 Compare February 20, 2025 14:20
@pennam pennam force-pushed the check-ota-before-disconnect branch from 63838f5 to 30c7001 Compare February 25, 2025 08:05
Copy link

Memory usage change @ 30c7001

Board flash % RAM for global variables %
arduino:esp32:nano_nora 🔺 0 - +20 0.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
arduino:mbed_giga:giga 🔺 0 - +64 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:mbed_nano:nanorp2040connect 🔺 0 - +22 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:mbed_nicla:nicla_vision 🔺 0 - +64 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:mbed_opta:opta 🔺 0 - +64 0.0 - 0.0 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 - +32 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 🔺 0 - +24 0.0 - +0.01 0 - 0 0.0 - 0.0
arduino:samd:nano_33_iot 🔺 0 - +24 0.0 - +0.01 0 - 0 0.0 - 0.0
esp32:esp32:esp32 🔺 0 - +24 0.0 - 0.0 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/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/ArduinoIoTCloud-Schedule
flash
% examples/ArduinoIoTCloud-Schedule
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 20 0.0 0 0.0 20 0.0 0 0.0 20 0.0 0 0.0 12 0.0 0 0.0 20 0.0 0 0.0 0 0.0 0 0.0 20 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 0 0.0 0 0.0 0 0.0 0 0.0 64 0.0 0 0.0 64 0.0 0 0.0 64 0.0 0 0.0 0 0.0 0 0.0 64 0.0 0 0.0 0 0.0 0 0.0
arduino:mbed_nano:nanorp2040connect 22 0.0 0 0.0 22 0.0 0 0.0 22 0.0 0 0.0 22 0.0 0 0.0 22 0.0 0 0.0 0 0.0 0 0.0 22 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0
arduino:mbed_nicla:nicla_vision 64 0.0 0 0.0 64 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 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_opta:opta 0 0.0 0 0.0 64 0.0 0 0.0 64 0.0 0 0.0 64 0.0 0 0.0 64 0.0 0 0.0 0 0.0 0 0.0 64 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 16 0.01 0 0.0 16 0.01 0 0.0 32 0.01 0 0.0 0 0.0 0 0.0 16 0.01 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
arduino:samd:mkrwifi1010 24 0.01 0 0.0 16 0.01 0 0.0 24 0.01 0 0.0 24 0.01 0 0.0 16 0.01 0 0.0 0 0.0 0 0.0 24 0.01 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0
arduino:samd:nano_33_iot 24 0.01 0 0.0 16 0.01 0 0.0 24 0.01 0 0.0 24 0.01 0 0.0 16 0.01 0 0.0 0 0.0 0 0.0 24 0.01 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0
esp32:esp32:esp32 20 0.0 0 0.0 24 0.0 0 0.0 20 0.0 0 0.0 20 0.0 0 0.0 24 0.0 0 0.0 0 0.0 0 0.0 24 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/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/ArduinoIoTCloud-Schedule<br>flash,%,examples/ArduinoIoTCloud-Schedule<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,20,0.0,0,0.0,20,0.0,0,0.0,20,0.0,0,0.0,12,0.0,0,0.0,20,0.0,0,0.0,0,0.0,0,0.0,20,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,0,0.0,0,0.0,0,0.0,0,0.0,64,0.0,0,0.0,64,0.0,0,0.0,64,0.0,0,0.0,0,0.0,0,0.0,64,0.0,0,0.0,0,0.0,0,0.0
arduino:mbed_nano:nanorp2040connect,22,0.0,0,0.0,22,0.0,0,0.0,22,0.0,0,0.0,22,0.0,0,0.0,22,0.0,0,0.0,0,0.0,0,0.0,22,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0
arduino:mbed_nicla:nicla_vision,64,0.0,0,0.0,64,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,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_opta:opta,0,0.0,0,0.0,64,0.0,0,0.0,64,0.0,0,0.0,64,0.0,0,0.0,64,0.0,0,0.0,0,0.0,0,0.0,64,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,16,0.01,0,0.0,16,0.01,0,0.0,32,0.01,0,0.0,,,,,0,0.0,0,0.0,16,0.01,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,,,,,,,,,,,,
arduino:samd:mkrwifi1010,24,0.01,0,0.0,16,0.01,0,0.0,24,0.01,0,0.0,24,0.01,0,0.0,16,0.01,0,0.0,0,0.0,0,0.0,24,0.01,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0
arduino:samd:nano_33_iot,24,0.01,0,0.0,16,0.01,0,0.0,24,0.01,0,0.0,24,0.01,0,0.0,16,0.01,0,0.0,0,0.0,0,0.0,24,0.01,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0
esp32:esp32:esp32,20,0.0,0,0.0,24,0.0,0,0.0,20,0.0,0,0.0,20,0.0,0,0.0,24,0.0,0,0.0,0,0.0,0,0.0,24,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,,,,,,,,

@pennam pennam merged commit 86f52c7 into arduino-libraries:master Feb 25, 2025
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants