Open Source Telephony
 help / color / mirror / Atom feed
From: Denis Kenzior <denkenz@gmail.com>
To: ofono@ofono.org
Subject: Re: [PATCH] telit: signal sim inserted when sim ready.
Date: Mon, 17 Dec 2012 09:50:00 -0600	[thread overview]
Message-ID: <50CF3F28.4080301@gmail.com> (raw)
In-Reply-To: <1355494782-31572-2-git-send-email-christopher.vogl@hale.at>

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

Hi Christopher,

On 12/14/2012 08:19 AM, christopher.vogl(a)hale.at wrote:
> From: Christopher Vogl<christopher.vogl@hale.at>
>
> We need to wait for #QSS: 3 until SIM inserted may be signaled or
> subsequent commands like +CMER will report SIM BUSY which in turn
> leads to a removal of the network registration atom. This has been
> observed with Telit HE910.
>
> In case of #QSS: 1 we need to check if the SIM is locked.
> If the SIM is unlocked we just wait for #QSS: 3,
> if the SIM is not unlocked we signal SIM inserted to be able to
> enter a PIN code.
> ---
>   plugins/telit.c |   43 +++++++++++++++++++++++++++++++++++++++++--
>   1 files changed, 41 insertions(+), 2 deletions(-)
>
> diff --git a/plugins/telit.c b/plugins/telit.c
> index fe2ccd6..cd67ef4 100644
> --- a/plugins/telit.c
> +++ b/plugins/telit.c
> @@ -61,6 +61,7 @@
>   #include "bluetooth.h"
>
>   static const char *none_prefix[] = { NULL };
> +static const char *cpin_prefix[] = { "+CPIN:", NULL };
>   static const char *rsen_prefix[]= { "#RSEN:", NULL };
>
>   struct telit_data {
> @@ -211,6 +212,33 @@ static GAtChat *open_device(struct ofono_modem *modem,
>   	return chat;
>   }
>
> +static void at_cpin_cb(gboolean ok, GAtResult *result, gpointer user_data)
> +{
> +	struct ofono_modem *modem = user_data;
> +	struct telit_data *data = ofono_modem_get_data(modem);
> +	GAtResultIter iter;
> +	const char *pin_required;
> +
> +	if (!ok)
> +		return;
> +
> +	g_at_result_iter_init(&iter, result);
> +
> +	if (!g_at_result_iter_next(&iter, "+CPIN:"))
> +		return;
> +
> +	g_at_result_iter_next_unquoted_string(&iter,&pin_required);
> +
> +	// No PIN required, we can wait for #QSS: 3.

Nitpicking, but we don't use // style comments.

> +	if (strcmp(pin_required, "READY")==0)
> +		return;
> +
> +	if (data->have_sim == FALSE) {
> +		ofono_sim_inserted_notify(data->sim, TRUE);
> +		data->have_sim = TRUE;
> +	}
> +}
> +
>   static void switch_sim_state_status(struct ofono_modem *modem, int status)
>   {
>   	struct telit_data *data = ofono_modem_get_data(modem);
> @@ -226,13 +254,24 @@ static void switch_sim_state_status(struct ofono_modem *modem, int status)
>   		}
>   		break;
>   	case 1:	/* SIM inserted */
> +		/*
> +		 * We want to call ofono_sim_inserted_notify() only if #QSS: 3
> +		 * (SIM READY), as otherwise subsequent commands like +CMER may
> +		 * report SIM BUSY.
> +		 * In case a PIN is required, we have to signal
> +		 * sim inserted on #QSS: 1 and wait in the SIM atom for #QSS: 3
> +		 * after entering the PIN.
> +		 */
> +		g_at_chat_send(data->chat, "AT+CPIN?", cpin_prefix,
> +				at_cpin_cb, modem, NULL);
> +		break;
>   	case 2:	/* SIM inserted and PIN unlocked */
> +		break;
> +	case 3:	/* SIM inserted and READY (SMS&  Phonebook access possible) */
>   		if (data->have_sim == FALSE) {
>   			ofono_sim_inserted_notify(data->sim, TRUE);
>   			data->have_sim = TRUE;
>   		}
> -		break;
> -	case 3:	/* SIM inserted, SMS and phonebook ready */
>   		if (data->sms_phonebook_added == FALSE) {
>   			ofono_phonebook_create(modem, 0, "atmodem", data->chat);
>   			ofono_sms_create(modem, 0, "atmodem", data->chat);

Since we are waiting for QSS:3, should phonebook and sms atom creation 
be moved out of here and simply put into post_sim()?

Regards,
-Denis

  reply	other threads:[~2012-12-17 15:50 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-14 14:19 [PATCH] sim: return from cpin when sim ready for telit christopher.vogl
2012-12-14 14:19 ` [PATCH] telit: signal sim inserted when sim ready christopher.vogl
2012-12-17 15:50   ` Denis Kenzior [this message]
2012-12-17 16:07     ` Christopher Vogl
2012-12-17 16:17       ` Denis Kenzior
2012-12-18  9:47     ` Christopher Vogl
2012-12-17 15:51 ` [PATCH] sim: return from cpin when sim ready for telit 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=50CF3F28.4080301@gmail.com \
    --to=denkenz@gmail.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox