Skip to content

Avoid to unlock the Sim if already unlocked #26

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 1 commit into from
Feb 26, 2025

Conversation

maidnl
Copy link
Contributor

@maidnl maidnl commented Jan 28, 2025

This PR avoid to try to unlock the SIM if the SIM is already unlocked.
If the SIM is unlocked and there is an attempt to unlock it (this happens in Arduino_ConnectionHandler in update_handleInit() function) the modem return an error (at least in Opta Cellular device) and this prevent the connection to the network.
So it seems sensible to avoid to unlock the SIM if the SIM is READY.
Also this PR introduces a change in the function getSimStatus() in order to avoid to call multiple time modem.getSimStatus() that involves useless communication with modem.

Copy link

Memory usage change @ 4d615ac

Board flash % RAM for global variables %
arduino:mbed_portenta:envie_m7 N/A N/A N/A N/A
arduino:renesas_portenta:portenta_c33 💚 -8 - 0 -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 -4 -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 -8 -0.0 0 0.0 -4 -0.0 0 0.0 -4 -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,-4,-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,-8,-0.0,0,0.0,-4,-0.0,0,0.0,-4,-0.0,0,0.0

@per1234 per1234 added type: imperfection Perceived defect in any part of project topic: code Related to content of the project itself labels Jan 29, 2025
return SimStatus::SIM_ANTITHEFT_LOCKED;
} else {
return SimStatus::SIM_ERROR;
}
}

bool ArduinoCellular::unlockSIM(String pin){
if(this->debugStream != nullptr){
this->debugStream->println("Unlocking SIM...");
int simStatus = modem.getSimStatus();

Choose a reason for hiding this comment

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

isn't this shadowing the global simStatus ?

Choose a reason for hiding this comment

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

Sorry, I had an issue with visualization, everything is ok 🙂

return SimStatus::SIM_ANTITHEFT_LOCKED;
} else {
return SimStatus::SIM_ERROR;
}
}

bool ArduinoCellular::unlockSIM(String pin){
if(this->debugStream != nullptr){
this->debugStream->println("Unlocking SIM...");
int simStatus = modem.getSimStatus();

Choose a reason for hiding this comment

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

Sorry, I had an issue with visualization, everything is ok 🙂

@sebromero sebromero merged commit 5610df2 into arduino-libraries:main Feb 26, 2025
5 of 6 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: imperfection Perceived defect in any part of project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants