diff options
-rw-r--r-- | plugins/sierra/mm-broadband-modem-sierra.c | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/plugins/sierra/mm-broadband-modem-sierra.c b/plugins/sierra/mm-broadband-modem-sierra.c index e70d4b02..5c894f64 100644 --- a/plugins/sierra/mm-broadband-modem-sierra.c +++ b/plugins/sierra/mm-broadband-modem-sierra.c @@ -59,6 +59,65 @@ struct _MMBroadbandModemSierraPrivate { }; /*****************************************************************************/ +/* 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 */ typedef enum { @@ -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; |