aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@lanedo.com>2013-04-03 17:45:39 +0200
committerAleksander Morgado <aleksander@lanedo.com>2013-04-04 19:26:51 +0200
commit8c39f2c55157b0304269fa303f5feb2889ec6333 (patch)
tree0e1de758002770e87fe802835a0d67014abaf3c5
parent464f33f77f66738c17c14390d7605167f52f62e5 (diff)
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
-rw-r--r--plugins/sierra/mm-broadband-modem-sierra.c61
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;