sierra: implement PIN/PUK retry count loading
Not all Sierra modems support it, but those which do reply like this:
AT+CPINC=?
OK
AT+CPINC?
+CPINC: 3,3,10,10
This commit is contained in:
@@ -58,6 +58,65 @@ struct _MMBroadbandModemSierraPrivate {
|
||||
TimeMethod time_method;
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Load unlock retries (Modem interface) */
|
||||
|
||||
static MMUnlockRetries *
|
||||
load_unlock_retries_finish (MMIfaceModem *self,
|
||||
GAsyncResult *res,
|
||||
GError **error)
|
||||
{
|
||||
MMUnlockRetries *unlock_retries;
|
||||
const gchar *response;
|
||||
gint matched;
|
||||
guint a, b, c ,d;
|
||||
|
||||
response = mm_base_modem_at_command_finish (MM_BASE_MODEM (self), res, error);
|
||||
if (!response)
|
||||
return NULL;
|
||||
|
||||
matched = sscanf (response, "+CPINC: %d,%d,%d,%d",
|
||||
&a, &b, &c, &d);
|
||||
if (matched != 4) {
|
||||
g_set_error (error,
|
||||
MM_CORE_ERROR,
|
||||
MM_CORE_ERROR_FAILED,
|
||||
"Could not parse PIN retries results: '%s'",
|
||||
response);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (a > 998) {
|
||||
g_set_error (error,
|
||||
MM_CORE_ERROR,
|
||||
MM_CORE_ERROR_FAILED,
|
||||
"Invalid PIN attempts left: '%u'",
|
||||
a);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
unlock_retries = mm_unlock_retries_new ();
|
||||
mm_unlock_retries_set (unlock_retries, MM_MODEM_LOCK_SIM_PIN, a);
|
||||
mm_unlock_retries_set (unlock_retries, MM_MODEM_LOCK_SIM_PIN2, b);
|
||||
mm_unlock_retries_set (unlock_retries, MM_MODEM_LOCK_SIM_PUK, c);
|
||||
mm_unlock_retries_set (unlock_retries, MM_MODEM_LOCK_SIM_PUK2, d);
|
||||
return unlock_retries;
|
||||
}
|
||||
|
||||
static void
|
||||
load_unlock_retries (MMIfaceModem *self,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
mm_dbg ("loading unlock retries (sierra)...");
|
||||
mm_base_modem_at_command (MM_BASE_MODEM (self),
|
||||
"+CPINC?",
|
||||
3,
|
||||
FALSE,
|
||||
callback,
|
||||
user_data);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Generic AT!STATUS parsing */
|
||||
|
||||
@@ -1515,6 +1574,8 @@ iface_modem_init (MMIfaceModem *iface)
|
||||
iface->modem_power_down_finish = modem_power_down_finish;
|
||||
iface->create_sim = mm_common_sierra_create_sim;
|
||||
iface->create_sim_finish = mm_common_sierra_create_sim_finish;
|
||||
iface->load_unlock_retries = load_unlock_retries;
|
||||
iface->load_unlock_retries_finish = load_unlock_retries_finish;
|
||||
iface->modem_after_sim_unlock = modem_after_sim_unlock;
|
||||
iface->modem_after_sim_unlock_finish = modem_after_sim_unlock_finish;
|
||||
iface->create_bearer = modem_create_bearer;
|
||||
|
||||
Reference in New Issue
Block a user