Fork of ublox-cellular-base to add LARA-R2 support
Fork of ublox-cellular-base by
Diff: UbloxCellularBase.cpp
- Revision:
- 6:8fadf1e49487
- Parent:
- 5:05fa111c1cf3
- Child:
- 7:c2cf27a981b3
--- 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; + } + } + } } } }