From: Lucas De Marchi <lucas.demarchi@profusion.mobi>
To: ofono@ofono.org
Subject: [PATCH] huawei: fix SIM state notification when locked
Date: Tue, 21 Dec 2010 17:27:10 -0200 [thread overview]
Message-ID: <1292959630-23211-1-git-send-email-lucas.demarchi@profusion.mobi> (raw)
In-Reply-To: <1292881869-13246-2-git-send-email-lucas.demarchi@profusion.mobi>
[-- Attachment #1: Type: text/plain, Size: 1701 bytes --]
When SIM is locked, huawei modem does not send any notification about
SIM state change because it does not differentiate 'invalid' from
'locked'.
In order to be able to unlock the sim, this patch forces a notification
of a valid state after a timeout.
---
plugins/huawei.c | 28 ++++++++++++++++++++++++++++
1 files changed, 28 insertions(+), 0 deletions(-)
diff --git a/plugins/huawei.c b/plugins/huawei.c
index bff1343..de45b03 100644
--- a/plugins/huawei.c
+++ b/plugins/huawei.c
@@ -226,6 +226,30 @@ static gboolean notify_sim_state(struct ofono_modem *modem,
return FALSE;
}
+static void cpin_cb(gboolean ok, GAtResult *result, gpointer user_data)
+{
+ struct ofono_modem *modem = user_data;
+
+ if (!ok)
+ return;
+
+ /* Force notification of SIM ready because it's in a locked state */
+ notify_sim_state(modem, HUAWEI_SIM_STATE_VALID);
+}
+
+static gboolean query_sim_locked(gpointer user_data)
+{
+ struct ofono_modem *modem = user_data;
+ struct huawei_data *data = ofono_modem_get_data(modem);
+
+ data->sim_poll_timeout = 0;
+
+ g_at_chat_send(data->pcui, "AT+CPIN?", NULL,
+ cpin_cb, modem, NULL);
+
+ return FALSE;
+}
+
static void sysinfo_cb(gboolean ok, GAtResult *result, gpointer user_data)
{
struct ofono_modem *modem = user_data;
@@ -264,6 +288,10 @@ static void sysinfo_cb(gboolean ok, GAtResult *result, gpointer user_data)
data->sim_poll_timeout = g_timeout_add_seconds(2,
query_sim_state,
modem);
+ } else if (sim_state == HUAWEI_SIM_STATE_INVALID_OR_LOCKED) {
+ data->sim_poll_timeout = g_timeout_add_seconds(2,
+ query_sim_locked,
+ modem);
}
}
--
1.7.3.4
next prev parent reply other threads:[~2010-12-21 19:27 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-20 21:51 [PATCH 1/2] huawei: cancel poll timeout when going to a valid state Lucas De Marchi
2010-12-20 21:51 ` [PATCH 2/2] huawei: fix SIM state notification when locked Lucas De Marchi
2010-12-21 19:19 ` Lucas De Marchi
2010-12-21 19:27 ` Lucas De Marchi [this message]
2010-12-21 19:37 ` [PATCH] " Denis Kenzior
2010-12-21 23:21 ` [PATCH 1/2] huawei: cancel poll timeout when going to a valid state Denis Kenzior
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1292959630-23211-1-git-send-email-lucas.demarchi@profusion.mobi \
--to=lucas.demarchi@profusion.mobi \
--cc=ofono@ofono.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.