qmimodem: ensure the modem is registered by check cs and ps state

The modem tells to early it's registered even it hasn't yet received a location
update complete.
This commit is contained in:
Alexander Couzens 2017-09-12 15:56:07 +02:00 committed by Pau Espin Pedrol
parent 4925c0af99
commit c2c3492f3b
1 changed files with 17 additions and 1 deletions

View File

@ -102,7 +102,23 @@ static bool extract_ss_info(struct qmi_result *result, int *status,
if (!ss)
return false;
*status = ss->status;
/* When connecting to a cell, the modem tells to early it's registered,
* event it hasn't yet received a location update complete */
switch (ss->status) {
case NETWORK_REGISTRATION_STATUS_REGISTERED:
case NETWORK_REGISTRATION_STATUS_ROAMING:
if (ss->cs_state == 0 && ss->ps_state == 0)
*status = NETWORK_REGISTRATION_STATUS_SEARCHING;
else
*status = ss->status;
break;
case NETWORK_REGISTRATION_STATUS_DENIED:
case NETWORK_REGISTRATION_STATUS_NOT_REGISTERED:
case NETWORK_REGISTRATION_STATUS_SEARCHING:
case NETWORK_REGISTRATION_STATUS_UNKNOWN:
*status = ss->status;
break;
}
DBG("serving system status %d", ss->status);