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

Avoid connect to APN to loop forever in case of missing connection #25

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

maidnl
Copy link
Contributor

@maidnl maidnl commented Jan 23, 2025

This PR introduces 2 changes (those changes have been found useful during Arduino Opta Cellular development, that uses this library):

  1. the function getSimStatus() is now public (it is useful to have the chance to know if the SIM is available or it has to be unlocked)
  2. The connect function in case the connection to the APN is not available (for example the antenna is missing and so a reliable communication cannot be established) was blocking. With this PR a parameter has been introduced to choose if the function must remain blocking (default) or it exits after a timeout.

@maidnl maidnl requested review from sebromero and pennam January 23, 2025 09:39
Copy link

Memory usage change @ 56d0bc2

Board flash % RAM for global variables %
arduino:mbed_portenta:envie_m7 N/A N/A N/A N/A
arduino:renesas_portenta:portenta_c33 🔺 0 - +20 0.0 - 0.0 0 - 0 0.0 - 0.0
Click for full report table
Board examples/HTTPClient
flash
% examples/HTTPClient
RAM for global variables
% examples/HTTPSClient
flash
% examples/HTTPSClient
RAM for global variables
% examples/GetTime
flash
% examples/GetTime
RAM for global variables
% examples/GetLocation
flash
% examples/GetLocation
RAM for global variables
% examples/DeleteSMS
flash
% examples/DeleteSMS
RAM for global variables
% examples/ReceiveSMS
flash
% examples/ReceiveSMS
RAM for global variables
% examples/SendSMS
flash
% examples/SendSMS
RAM for global variables
% examples/ModemTerminal
flash
% examples/ModemTerminal
RAM for global variables
%
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 20 0.0 0 0.0 16 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 16 0.0 0 0.0 20 0.0 0 0.0 20 0.0 0 0.0
Click for full report CSV
Board,examples/HTTPClient<br>flash,%,examples/HTTPClient<br>RAM for global variables,%,examples/HTTPSClient<br>flash,%,examples/HTTPSClient<br>RAM for global variables,%,examples/GetTime<br>flash,%,examples/GetTime<br>RAM for global variables,%,examples/GetLocation<br>flash,%,examples/GetLocation<br>RAM for global variables,%,examples/DeleteSMS<br>flash,%,examples/DeleteSMS<br>RAM for global variables,%,examples/ReceiveSMS<br>flash,%,examples/ReceiveSMS<br>RAM for global variables,%,examples/SendSMS<br>flash,%,examples/SendSMS<br>RAM for global variables,%,examples/ModemTerminal<br>flash,%,examples/ModemTerminal<br>RAM for global variables,%
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,20,0.0,0,0.0,16,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,16,0.0,0,0.0,20,0.0,0,0.0,20,0.0,0,0.0

Copy link
Contributor

@sebromero sebromero left a comment

Choose a reason for hiding this comment

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

We have to use camel case for variable names according to the style guide. Otherwise looks good. I haven't tested it though.

@maidnl maidnl force-pushed the opta_cellular_dev branch from 56d0bc2 to e436eab Compare January 23, 2025 13:50
@maidnl
Copy link
Contributor Author

maidnl commented Jan 23, 2025

Thanks @sebromero. The PR is updated with your observations.

Copy link

Memory usage change @ e436eab

Board flash % RAM for global variables %
arduino:mbed_portenta:envie_m7 N/A N/A N/A N/A
arduino:renesas_portenta:portenta_c33 🔺 0 - +20 0.0 - 0.0 0 - 0 0.0 - 0.0
Click for full report table
Board examples/HTTPClient
flash
% examples/HTTPClient
RAM for global variables
% examples/HTTPSClient
flash
% examples/HTTPSClient
RAM for global variables
% examples/GetTime
flash
% examples/GetTime
RAM for global variables
% examples/GetLocation
flash
% examples/GetLocation
RAM for global variables
% examples/DeleteSMS
flash
% examples/DeleteSMS
RAM for global variables
% examples/ReceiveSMS
flash
% examples/ReceiveSMS
RAM for global variables
% examples/SendSMS
flash
% examples/SendSMS
RAM for global variables
% examples/ModemTerminal
flash
% examples/ModemTerminal
RAM for global variables
%
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 20 0.0 0 0.0 16 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 16 0.0 0 0.0 20 0.0 0 0.0 20 0.0 0 0.0
Click for full report CSV
Board,examples/HTTPClient<br>flash,%,examples/HTTPClient<br>RAM for global variables,%,examples/HTTPSClient<br>flash,%,examples/HTTPSClient<br>RAM for global variables,%,examples/GetTime<br>flash,%,examples/GetTime<br>RAM for global variables,%,examples/GetLocation<br>flash,%,examples/GetLocation<br>RAM for global variables,%,examples/DeleteSMS<br>flash,%,examples/DeleteSMS<br>RAM for global variables,%,examples/ReceiveSMS<br>flash,%,examples/ReceiveSMS<br>RAM for global variables,%,examples/SendSMS<br>flash,%,examples/SendSMS<br>RAM for global variables,%,examples/ModemTerminal<br>flash,%,examples/ModemTerminal<br>RAM for global variables,%
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,20,0.0,0,0.0,16,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,16,0.0,0,0.0,20,0.0,0,0.0,20,0.0,0,0.0

@maidnl maidnl force-pushed the opta_cellular_dev branch from e436eab to 4606dbf Compare January 23, 2025 14:19
Copy link

Memory usage change @ 4606dbf

Board flash % RAM for global variables %
arduino:mbed_portenta:envie_m7 N/A N/A N/A N/A
arduino:renesas_portenta:portenta_c33 🔺 0 - +20 0.0 - 0.0 0 - 0 0.0 - 0.0
Click for full report table
Board examples/HTTPClient
flash
% examples/HTTPClient
RAM for global variables
% examples/HTTPSClient
flash
% examples/HTTPSClient
RAM for global variables
% examples/GetTime
flash
% examples/GetTime
RAM for global variables
% examples/GetLocation
flash
% examples/GetLocation
RAM for global variables
% examples/DeleteSMS
flash
% examples/DeleteSMS
RAM for global variables
% examples/ReceiveSMS
flash
% examples/ReceiveSMS
RAM for global variables
% examples/SendSMS
flash
% examples/SendSMS
RAM for global variables
% examples/ModemTerminal
flash
% examples/ModemTerminal
RAM for global variables
%
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 20 0.0 0 0.0 16 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 16 0.0 0 0.0 20 0.0 0 0.0 20 0.0 0 0.0
Click for full report CSV
Board,examples/HTTPClient<br>flash,%,examples/HTTPClient<br>RAM for global variables,%,examples/HTTPSClient<br>flash,%,examples/HTTPSClient<br>RAM for global variables,%,examples/GetTime<br>flash,%,examples/GetTime<br>RAM for global variables,%,examples/GetLocation<br>flash,%,examples/GetLocation<br>RAM for global variables,%,examples/DeleteSMS<br>flash,%,examples/DeleteSMS<br>RAM for global variables,%,examples/ReceiveSMS<br>flash,%,examples/ReceiveSMS<br>RAM for global variables,%,examples/SendSMS<br>flash,%,examples/SendSMS<br>RAM for global variables,%,examples/ModemTerminal<br>flash,%,examples/ModemTerminal<br>RAM for global variables,%
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,20,0.0,0,0.0,16,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,16,0.0,0,0.0,20,0.0,0,0.0,20,0.0,0,0.0

@per1234 per1234 added type: enhancement Proposed improvement topic: code Related to content of the project itself labels Feb 10, 2025
Copy link
Contributor

@sebromero sebromero left a comment

Choose a reason for hiding this comment

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

Please see comment

/**
* @brief same as previous, username and password are empty
*/
bool connect(String apn, bool waitForever);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
bool connect(String apn, bool waitForever);
bool connect(String apn, bool waitForever = true);

I'd assign the same default value to the version without credentials.

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.

4 participants