aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2012-07-19 13:02:10 -0500
committerAleksander Morgado <aleksander@lanedo.com>2012-08-06 20:07:26 +0200
commit6f3a83534cfd1e6ff6bd3aeff5b338a7d71db9eb (patch)
tree6ea765666258b5edda74afcfb8672fd04ffff632
parent4e92b849affb87ceecf3f902449cef8b275932fd (diff)
longcheer: implement unlock retries checking
-rw-r--r--TODO4
-rw-r--r--plugins/longcheer/mm-broadband-modem-longcheer.c78
2 files changed, 78 insertions, 4 deletions
diff --git a/TODO b/TODO
index bff29ef7..64a9ebfe 100644
--- a/TODO
+++ b/TODO
@@ -125,10 +125,6 @@ example to update the signal quality value or check registration status.
> 'AT+CNMI=2,1,2,1,0'
+CMS ERROR: 303'
- ** Longcheer plugin: Load PIN/PUK retries left, with the following format:
- > AT+CPNNUM
- PIN1=3; PUK1=10; PIN2=0; PUK2=10
-
** Pantech plugin: The UMW190 needs some time to settle down after sending the
PIN, or it will end up stuck if we ask too many PIN-related stuff one after
the other.
diff --git a/plugins/longcheer/mm-broadband-modem-longcheer.c b/plugins/longcheer/mm-broadband-modem-longcheer.c
index a78466f2..d32c36a0 100644
--- a/plugins/longcheer/mm-broadband-modem-longcheer.c
+++ b/plugins/longcheer/mm-broadband-modem-longcheer.c
@@ -233,6 +233,82 @@ load_access_technologies (MMIfaceModem *self,
}
/*****************************************************************************/
+/* Load unlock retries (Modem interface) */
+
+static MMUnlockRetries *
+load_unlock_retries_finish (MMIfaceModem *self,
+ GAsyncResult *res,
+ GError **error)
+{
+ if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error))
+ return NULL;
+ return (MMUnlockRetries *) g_object_ref (g_simple_async_result_get_op_res_gpointer (
+ G_SIMPLE_ASYNC_RESULT (res)));
+}
+
+static void
+load_unlock_retries_ready (MMBaseModem *self,
+ GAsyncResult *res,
+ GSimpleAsyncResult *operation_result)
+{
+ const gchar *response;
+ GError *error;
+ int pin1, puk1, pin2, puk2;
+
+ response = mm_base_modem_at_command_finish (MM_BASE_MODEM (self), res, &error);
+ if (!response) {
+ mm_dbg ("Couldn't query unlock retries: '%s'", error->message);
+ g_simple_async_result_take_error (operation_result, error);
+ g_simple_async_result_complete (operation_result);
+ g_object_unref (operation_result);
+ return;
+ }
+
+ /* That's right; no +CPNNUM: prefix, it looks like this:
+ *
+ * AT+CPNNUM
+ * PIN1=3; PUK1=10; PIN2=3; PUK2=10
+ * OK
+ */
+ if (sscanf (response, "PIN1=%d; PUK1=%d; PIN2=%d; PUK2=%d", &pin1, &puk1, &pin2, &puk2) == 4) {
+ MMUnlockRetries *retries;
+ retries = mm_unlock_retries_new ();
+ mm_unlock_retries_set (retries, MM_MODEM_LOCK_SIM_PIN, pin1);
+ mm_unlock_retries_set (retries, MM_MODEM_LOCK_SIM_PUK, puk1);
+ mm_unlock_retries_set (retries, MM_MODEM_LOCK_SIM_PIN2, pin2);
+ mm_unlock_retries_set (retries, MM_MODEM_LOCK_SIM_PUK2, puk2);
+ g_simple_async_result_set_op_res_gpointer (operation_result,
+ retries,
+ (GDestroyNotify)g_object_unref);
+ } else {
+ g_simple_async_result_set_error (operation_result,
+ MM_CORE_ERROR,
+ MM_CORE_ERROR_FAILED,
+ "Invalid unlock retries response: '%s'",
+ response);
+ }
+ g_simple_async_result_complete (operation_result);
+ g_object_unref (operation_result);
+}
+
+static void
+load_unlock_retries (MMIfaceModem *self,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ mm_base_modem_at_command (
+ MM_BASE_MODEM (self),
+ "+CPNNUM",
+ 3,
+ FALSE,
+ (GAsyncReadyCallback)load_unlock_retries_ready,
+ g_simple_async_result_new (G_OBJECT (self),
+ callback,
+ user_data,
+ load_unlock_retries));
+}
+
+/*****************************************************************************/
MMBroadbandModemLongcheer *
mm_broadband_modem_longcheer_new (const gchar *device,
@@ -264,6 +340,8 @@ iface_modem_init (MMIfaceModem *iface)
iface->load_allowed_modes_finish = load_allowed_modes_finish;
iface->set_allowed_modes = set_allowed_modes;
iface->set_allowed_modes_finish = set_allowed_modes_finish;
+ iface->load_unlock_retries = load_unlock_retries;
+ iface->load_unlock_retries_finish = load_unlock_retries_finish;
}
static void