Skip to content

TimeService: check connection status before network/ntp time request #317

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

Merged
merged 2 commits into from
May 30, 2022

Conversation

pennam
Copy link
Collaborator

@pennam pennam commented May 11, 2022

Background: a user reported a crash using ArduinoIoTCloud on ESP32 .

After a bit of research we discovered the root cause was an early NTP request due to a property initialization into the setup function. In the arduino-esp32 core the network stack is initialized when the .begin() function is called and in case of this library this happens at the first call of ArduinoCloud.update()

This PR slightly chage the behaviour of TimeSerivice adding a connection check before starting a remote time request to the connection handler or via NTP.

Doing in this way we avoid the crash reported on esp32 core and for the other platforms to submit time request that would return invalid values.

@codecov-commenter
Copy link

codecov-commenter commented May 11, 2022

Codecov Report

Merging #317 (eb53f8b) into master (451d57d) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##           master     #317   +/-   ##
=======================================
  Coverage   94.87%   94.87%           
=======================================
  Files          27       27           
  Lines        1113     1113           
=======================================
  Hits         1056     1056           
  Misses         57       57           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 451d57d...eb53f8b. Read the comment docs.

@per1234 per1234 added type: imperfection Perceived defect in any part of project topic: code Related to content of the project itself labels May 11, 2022
@pennam pennam requested a review from aentinger May 11, 2022 08:03
@pennam pennam requested a review from ubidefeo May 17, 2022 08:20
@arduino-libraries arduino-libraries deleted a comment from github-actions bot May 17, 2022
@pennam pennam requested a review from mirkokurt May 19, 2022 13:56
@github-actions
Copy link

Memory usage change @ 398bef8

Board flash % RAM for global variables %
arduino:mbed:envie_m7 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:mbed_nano:nanorp2040connect 🔺 0 - +18 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:mbed_nicla:nicla_vision 🔺 0 - +64 0.0 - +0.01 0 - 0 0.0 - 0.0
arduino:samd:mkr1000 🔺 +16 - +24 +0.01 - +0.01 0 - 0 0.0 - 0.0
arduino:samd:mkrgsm1400 🔺 +16 - +24 +0.01 - +0.01 0 - 0 0.0 - 0.0
arduino:samd:mkrnb1500 🔺 +16 - +24 +0.01 - +0.01 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 - +16 0.0 - +0.01 0 - 0 0.0 - 0.0
arduino:samd:nano_33_iot 🔺 0 - +16 0.0 - +0.01 0 - 0 0.0 - 0.0
esp32:esp32:esp32 🔺 +44 - +44 0.0 - 0.0 0 - 0 0.0 - 0.0
esp8266:esp8266:huzzah 🔺 +16 - +32 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/utility/ArduinoIoTCloud_Travis_CI
flash
% examples/utility/ArduinoIoTCloud_Travis_CI
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:mbed:envie_m7 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_nano:nanorp2040connect 18 0.0 0 0.0 18 0.0 0 0.0 18 0.0 0 0.0 18 0.0 0 0.0 0 0.0 0 0.0
arduino:mbed_nicla:nicla_vision 0 0.0 0 0.0 64 0.01 0 0.0 64 0.01 0 0.0 0 0.0 0 0.0
arduino:samd:mkr1000 24 0.01 0 0.0 16 0.01 0 0.0 24 0.01 0 0.0 16 0.01 0 0.0
arduino:samd:mkrgsm1400 16 0.01 0 0.0 16 0.01 0 0.0 24 0.01 0 0.0 16 0.01 0 0.0
arduino:samd:mkrnb1500 16 0.01 0 0.0 16 0.01 0 0.0 24 0.01 0 0.0 16 0.01 0 0.0
arduino:samd:mkrwan1300 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0
arduino:samd:mkrwifi1010 16 0.01 0 0.0 16 0.01 0 0.0 16 0.01 0 0.0 16 0.01 0 0.0 0 0.0 0 0.0
arduino:samd:nano_33_iot 16 0.01 0 0.0 16 0.01 0 0.0 16 0.01 0 0.0 16 0.01 0 0.0 0 0.0 0 0.0
esp32:esp32:esp32 44 0.0 0 0.0 44 0.0 0 0.0 44 0.0 0 0.0
esp8266:esp8266:huzzah 32 0.0 0 0.0 16 0.0 0 0.0 16 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/utility/ArduinoIoTCloud_Travis_CI<br>flash,%,examples/utility/ArduinoIoTCloud_Travis_CI<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:mbed:envie_m7,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_nano:nanorp2040connect,18,0.0,0,0.0,18,0.0,0,0.0,18,0.0,0,0.0,18,0.0,0,0.0,0,0.0,0,0.0
arduino:mbed_nicla:nicla_vision,0,0.0,0,0.0,64,0.01,0,0.0,64,0.01,0,0.0,0,0.0,0,0.0,,,,
arduino:samd:mkr1000,24,0.01,0,0.0,16,0.01,0,0.0,24,0.01,0,0.0,16,0.01,0,0.0,,,,
arduino:samd:mkrgsm1400,16,0.01,0,0.0,16,0.01,0,0.0,24,0.01,0,0.0,16,0.01,0,0.0,,,,
arduino:samd:mkrnb1500,16,0.01,0,0.0,16,0.01,0,0.0,24,0.01,0,0.0,16,0.01,0,0.0,,,,
arduino:samd:mkrwan1300,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,,,,,,,,
arduino:samd:mkrwifi1010,16,0.01,0,0.0,16,0.01,0,0.0,16,0.01,0,0.0,16,0.01,0,0.0,0,0.0,0,0.0
arduino:samd:nano_33_iot,16,0.01,0,0.0,16,0.01,0,0.0,16,0.01,0,0.0,16,0.01,0,0.0,0,0.0,0,0.0
esp32:esp32:esp32,44,0.0,0,0.0,44,0.0,0,0.0,44,0.0,0,0.0,,,,,,,,
esp8266:esp8266:huzzah,32,0.0,0,0.0,16,0.0,0,0.0,16,0.0,0,0.0,,,,,,,,

Copy link
Collaborator

@mirkokurt mirkokurt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@arduino-libraries arduino-libraries deleted a comment from github-actions bot May 24, 2022
@pennam
Copy link
Collaborator Author

pennam commented May 30, 2022

TESTS:
ESP32 DEVKIT V1 ✔️
MKRWiFi 1010: ✔️
RP2040 CONNECT: ✔️
MKGGSM1400: ✔️
PORTENTA H7: ✔️
NICLA VISION: ✔️

@pennam pennam merged commit a594d95 into arduino-libraries:master May 30, 2022
@pennam pennam deleted the esp32_init branch May 17, 2024 09:10
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: imperfection Perceived defect in any part of project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants