Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 883beab

Browse files
authoredApr 3, 2022
Add files via upload
1 parent f06ae26 commit 883beab

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed
 

‎src/SparkFun_u-blox_SARA-R5_Arduino_Library.cpp

+39
Original file line numberDiff line numberDiff line change
@@ -1615,6 +1615,45 @@ SARA_R5_error_t SARA_R5::getAPN(int cid, String *apn, IPAddress *ip)
16151615
return err;
16161616
}
16171617

1618+
SARA_R5_error_t SARA_R5::getSimStatus(String* code)
1619+
{
1620+
SARA_R5_error_t err;
1621+
char *command;
1622+
char *response;
1623+
command = sara_r5_calloc_char(strlen(SARA_R5_COMMAND_SIMPIN) + 2);
1624+
if (command == NULL)
1625+
return SARA_R5_ERROR_OUT_OF_MEMORY;
1626+
sprintf(command, "%s?", SARA_R5_COMMAND_SIMPIN);
1627+
response = sara_r5_calloc_char(minimumResponseAllocation);
1628+
if (response == NULL)
1629+
{
1630+
free(command);
1631+
return SARA_R5_ERROR_OUT_OF_MEMORY;
1632+
}
1633+
err = sendCommandWithResponse(command, SARA_R5_RESPONSE_OK_OR_ERROR,
1634+
response, SARA_R5_STANDARD_RESPONSE_TIMEOUT);
1635+
1636+
if (err == SARA_R5_ERROR_SUCCESS)
1637+
{
1638+
int scanned = 0;
1639+
char c[16];
1640+
char *searchPtr = strstr(response, "+CPIN: ");
1641+
if (searchPtr != NULL)
1642+
scanned = sscanf(searchPtr, "+CPIN: %s\r\n", c);
1643+
if (scanned == 1)
1644+
{
1645+
*code = c;
1646+
}
1647+
else
1648+
err = SARA_R5_ERROR_UNEXPECTED_RESPONSE;
1649+
}
1650+
1651+
free(command);
1652+
free(response);
1653+
1654+
return err;
1655+
}
1656+
16181657
SARA_R5_error_t SARA_R5::setSimPin(String pin)
16191658
{
16201659
SARA_R5_error_t err;

‎src/SparkFun_u-blox_SARA-R5_Arduino_Library.h

+2
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,9 @@ class SARA_R5 : public Print
677677
SARA_R5_error_t setAPN(String apn, uint8_t cid = 1, SARA_R5_pdp_type pdpType = PDP_TYPE_IP); // Set the Access Point Name
678678
SARA_R5_error_t getAPN(int cid, String *apn, IPAddress *ip); // Return the apn and IP address for the chosen context identifier
679679

680+
SARA_R5_error_t getSimStatus(String* code);
680681
SARA_R5_error_t setSimPin(String pin);
682+
681683
// SIM
682684
// Status report Mode:
683685
// Bit States reported

0 commit comments

Comments
 (0)
Please sign in to comment.