From 4f55511680c04c89f8288cdf07fc7ad2c5c5b096 Mon Sep 17 00:00:00 2001 From: Aleksander Morgado Date: Mon, 15 Oct 2012 13:34:51 +0200 Subject: [PATCH] pantech: wait up to 5s after SIM unlock before sending new commands Or the modem will get stuck completely. --- plugins/pantech/mm-broadband-modem-pantech.c | 39 ++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/plugins/pantech/mm-broadband-modem-pantech.c b/plugins/pantech/mm-broadband-modem-pantech.c index 72ed0c47..22b50083 100644 --- a/plugins/pantech/mm-broadband-modem-pantech.c +++ b/plugins/pantech/mm-broadband-modem-pantech.c @@ -22,6 +22,7 @@ #include #include "ModemManager.h" +#include "mm-iface-modem.h" #include "mm-log.h" #include "mm-errors-types.h" #include "mm-broadband-modem-pantech.h" @@ -55,6 +56,41 @@ create_sim (MMIfaceModem *self, user_data); } +/*****************************************************************************/ +/* After SIM unlock (Modem interface) */ + +static gboolean +modem_after_sim_unlock_finish (MMIfaceModem *self, + GAsyncResult *res, + GError **error) +{ + return TRUE; +} + +static gboolean +after_sim_unlock_wait_cb (GSimpleAsyncResult *result) +{ + g_simple_async_result_complete (result); + g_object_unref (result); + return FALSE; +} + +static void +modem_after_sim_unlock (MMIfaceModem *self, + GAsyncReadyCallback callback, + gpointer user_data) +{ + GSimpleAsyncResult *result; + + result = g_simple_async_result_new (G_OBJECT (self), + callback, + user_data, + modem_after_sim_unlock); + + /* wait so sim pin is done */ + g_timeout_add_seconds (5, (GSourceFunc)after_sim_unlock_wait_cb, result); +} + /*****************************************************************************/ MMBroadbandModemPantech * @@ -84,6 +120,9 @@ iface_modem_init (MMIfaceModem *iface) /* Create Pantech-specific SIM */ iface->create_sim = create_sim; iface->create_sim_finish = create_sim_finish; + + iface->modem_after_sim_unlock = modem_after_sim_unlock; + iface->modem_after_sim_unlock_finish = modem_after_sim_unlock_finish; } static void