Add methods to return IMEI, MEID, IMSI, ICCID and RSSI.
Fork of ublox-cellular-base by
Revision 6:8fadf1e49487, committed 2017-08-11
- Comitter:
- rob.meades@u-blox.com
- Date:
- Fri Aug 11 14:52:26 2017 +0100
- Parent:
- 5:05fa111c1cf3
- Child:
- 7:c2cf27a981b3
- Commit message:
- Retry getting the IMSI as this can sometimes take a while with Sara-G350 modems if the SIM PIN is requested or the SIM takes a while to initialise itself.
Changed in this revision
| UbloxCellularBase.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/UbloxCellularBase.cpp Thu Aug 10 14:27:24 2017 +0100
+++ b/UbloxCellularBase.cpp Fri Aug 11 14:52:26 2017 +0100
@@ -688,6 +688,7 @@
// Initialise the modem.
bool UbloxCellularBase::init(const char *pin)
{
+ bool gotImsi = false;
MBED_ASSERT(_at != NULL);
if (!_modem_initialised) {
@@ -698,15 +699,25 @@
}
if (initialise_sim_card()) {
if (set_device_identity(&_dev_info.dev) && // Set up device identity
- device_init(_dev_info.dev) && // Initialise this device
- get_iccid() && // Get integrated circuit ID of the SIM
- get_imsi() && // Get international mobile subscriber information
- get_imei() && // Get international mobile equipment identifier
- get_meid() && // Probably the same as the IMEI
- set_sms()) {
-
- // The modem is initialised.
- _modem_initialised = true;
+ device_init(_dev_info.dev)) {// Initialise this device
+ // Get the integrated circuit ID of the SIM
+ if (get_iccid()) {
+ // Try a few times to get the IMSI (since on some modems this can
+ // take a while to be retrieved, especially if a SIM PIN
+ // was set)
+ for (int x = 0; (x < 3) && !(gotImsi = get_imsi()); x++) {
+ wait_ms(1000);
+ }
+
+ if (gotImsi) {
+ if (get_imei() && // Get international mobile equipment identifier
+ get_meid() && // Probably the same as the IMEI
+ set_sms()) { // And set up SMS
+ // The modem is initialised.
+ _modem_initialised = true;
+ }
+ }
+ }
}
}
}
