All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lucas De Marchi <lucas.demarchi@profusion.mobi>
To: ofono@ofono.org
Subject: Re: [PATCH 2/2] huawei: fix SIM state notification when locked
Date: Tue, 21 Dec 2010 17:19:37 -0200	[thread overview]
Message-ID: <AANLkTikWxKSr2F8ejvcCL6jNoKr_rpyeNRHq9kxiGCDp@mail.gmail.com> (raw)
In-Reply-To: <1292881869-13246-2-git-send-email-lucas.demarchi@profusion.mobi>

[-- Attachment #1: Type: text/plain, Size: 2095 bytes --]

On Mon, Dec 20, 2010 at 7:51 PM, Lucas De Marchi
<lucas.demarchi@profusion.mobi> wrote:
> 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 |   40 ++++++++++++++++++++++++++++++++++++++++
>  1 files changed, 40 insertions(+), 0 deletions(-)
>
> diff --git a/plugins/huawei.c b/plugins/huawei.c
> index bff1343..7934956 100644
> --- a/plugins/huawei.c
> +++ b/plugins/huawei.c
> @@ -56,6 +56,7 @@
>  #include <drivers/atmodem/vendor.h>
>
>  static const char *none_prefix[] = { NULL };
> +static const char *cpin_prefix[] = { "+CPIN:", NULL };
>  static const char *sysinfo_prefix[] = { "^SYSINFO:", NULL };
>  static const char *ussdmode_prefix[] = { "^USSDMODE:", NULL };
>  static const char *cvoice_prefix[] = { "^CVOICE:", NULL };
> @@ -226,6 +227,41 @@ 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;
> +       const char *value;
> +       GAtResultIter iter;
> +
> +       if (!ok)
> +               return;
> +
> +       g_at_result_iter_init(&iter, result);
> +
> +       if (!g_at_result_iter_next(&iter, "+CPIN:"))
> +               return;
> +
> +       if (!g_at_result_iter_next_unquoted_string(&iter, &value))
> +               return;
> +
> +       /* Force notification of SIM ready because it's in a locked state */
> +       if (g_str_has_prefix(value, "SIM"))
> +               notify_sim_state(modem, HUAWEI_SIM_STATE_VALID);
> +}

As I talked to Denis through IRC, this can be simplified. We can cheat
here, not doing all this parsing and only relying on "ok" value. I
tested it with Huawei E220. I'll send  another patch.


Lucas De Marchi

  reply	other threads:[~2010-12-21 19:19 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 [this message]
2010-12-21 19:27   ` [PATCH] " Lucas De Marchi
2010-12-21 19:37     ` 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=AANLkTikWxKSr2F8ejvcCL6jNoKr_rpyeNRHq9kxiGCDp@mail.gmail.com \
    --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.