Open Source Telephony
 help / color / mirror / Atom feed
From: Denis Kenzior <denkenz@gmail.com>
To: ofono@ofono.org
Subject: Re: [PATCH 7/8] netreg: adapt CMER and CIEV for telit
Date: Mon, 13 Aug 2012 11:25:25 -0500	[thread overview]
Message-ID: <50292A75.3040005@gmail.com> (raw)
In-Reply-To: <1344864218-23167-1-git-send-email-christopher.vogl@hale.at>

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

Hi Christopher,

On 08/13/2012 08:23 AM, Christopher Vogl wrote:
> Telit uses a 2 to enable indicator event reporting and
> indicators in a +CIEV URC are identified by strings, not numbers.

Yikes, can you include a sample AT trace?  It sounds like something is 
going terribly wrong with CIEVs.

> ---
>   drivers/atmodem/network-registration.c |   46 +++++++++++++++++++++++++-------
>   1 files changed, 36 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/atmodem/network-registration.c b/drivers/atmodem/network-registration.c
> index 3d09913..7083efe 100644
> --- a/drivers/atmodem/network-registration.c
> +++ b/drivers/atmodem/network-registration.c
> @@ -54,6 +54,7 @@ struct netreg_data {
>   	GAtChat *chat;
>   	char mcc[OFONO_MAX_MCC_LENGTH + 1];
>   	char mnc[OFONO_MAX_MNC_LENGTH + 1];
> +	const char *signal_identifier;
>   	int signal_index; /* If strength is reported via CIND */
>   	int signal_min; /* min strength reported via CIND */
>   	int signal_max; /* max strength reported via CIND */
> @@ -734,6 +735,7 @@ static void ciev_notify(GAtResult *result, gpointer user_data)
>   	struct ofono_netreg *netreg = user_data;
>   	struct netreg_data *nd = ofono_netreg_get_data(netreg);
>   	int strength, ind;
> +	const char *ind_str;
>   	GAtResultIter iter;
>
>   	g_at_result_iter_init(&iter, result);
> @@ -741,11 +743,23 @@ static void ciev_notify(GAtResult *result, gpointer user_data)
>   	if (!g_at_result_iter_next(&iter, "+CIEV:"))
>   		return;
>
> -	if (!g_at_result_iter_next_number(&iter,&ind))
> -		return;
> +	/*
> +	 * Telit uses strings to identify indicators.
> +	 */
> +	if (nd->vendor == OFONO_VENDOR_TELIT) {
> +		if (!g_at_result_iter_next_unquoted_string(&iter,&ind_str))
> +			return;
>
> -	if (ind != nd->signal_index)
> -		return;
> +		if (!g_str_equal(nd->signal_identifier, ind_str))
> +			return;
> +	}
> +	else {
> +		if (!g_at_result_iter_next_number(&iter,&ind))
> +			return;
> +		
> +		if (ind != nd->signal_index)
> +			return;
> +	}

If Telit is indeed this broken, then likely you can simply create a 
telit version of this function.  Then you can skip storing 
nd->signal_identifier and the like.  It would also make things much more 
readable.

>
>   	if (!g_at_result_iter_next_number(&iter,&strength))
>   		return;
> @@ -754,6 +768,8 @@ static void ciev_notify(GAtResult *result, gpointer user_data)
>   		strength = -1;
>   	else
>   		strength = (strength * 100) / (nd->signal_max - nd->signal_min);
> +	
> +	DBG("Strength: %d", strength);

This might belong in a separate patch.

>
>   	ofono_netreg_strength_notify(netreg, strength);
>   }
> @@ -1401,12 +1417,12 @@ static void cind_support_cb(gboolean ok, GAtResult *result, gpointer user_data)
>   	struct netreg_data *nd = ofono_netreg_get_data(netreg);
>   	GAtResultIter iter;
>   	const char *str;
> -	char *signal_identifier = "signal";
> +	const char *cmd;
>   	int index;
>   	int min = 0;
>   	int max = 0;
>   	int tmp_min, tmp_max, invalid;
> -
> +	
>   	if (!ok)
>   		goto error;
>
> @@ -1422,8 +1438,10 @@ static void cind_support_cb(gboolean ok, GAtResult *result, gpointer user_data)
>   	 */
>   	if (nd->vendor == OFONO_VENDOR_TELIT) {
>   		g_at_result_iter_open_list(&iter);
> -		signal_identifier = "rssi";
> +		nd->signal_identifier = "rssi";
>   	}
> +	else
> +		nd->signal_identifier = "signal";
>
>   	while (g_at_result_iter_open_list(&iter)) {
>   		/* Reset invalid default value for every token */
> @@ -1449,7 +1467,7 @@ static void cind_support_cb(gboolean ok, GAtResult *result, gpointer user_data)
>   		if (!g_at_result_iter_close_list(&iter))
>   			goto error;
>
> -		if (g_str_equal(signal_identifier, str) == TRUE) {
> +		if (g_str_equal(nd->signal_identifier, str) == TRUE) {
>   			nd->signal_index = index;
>   			nd->signal_min = min;
>   			nd->signal_max = max;
> @@ -1464,8 +1482,16 @@ static void cind_support_cb(gboolean ok, GAtResult *result, gpointer user_data)
>
>   	if (nd->signal_index == 0)
>   		goto error;
> -
> -	g_at_chat_send(nd->chat, "AT+CMER=3,0,0,1", NULL,
> +	
> +	/*
> +	 * Telit uses a 2 to enable indicator event reporting, 1 is undefined.
> +	 */
> +	if (nd->vendor == OFONO_VENDOR_TELIT)
> +		cmd = "AT+CMER=3,0,0,2";
> +	else
> +		cmd = "AT+CMER=3,0,0,1";
> +	
> +	g_at_chat_send(nd->chat, cmd, NULL,

This looks fine, but we might be better off with something similar to 
how the CNMI string is being built in drivers/atmodem/sms.c.  E.g. query 
which CMER modes are supported and select these intelligently.

>   			NULL, NULL, NULL);
>   	g_at_chat_register(nd->chat, "+CIEV:",
>   				ciev_notify, FALSE, netreg, NULL);

Regards,
-Denis

  reply	other threads:[~2012-08-13 16:25 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-13 13:23 [PATCH 7/8] netreg: adapt CMER and CIEV for telit Christopher Vogl
2012-08-13 16:25 ` Denis Kenzior [this message]
2012-08-14 14:16   ` Christopher Vogl
2012-08-14  6:46     ` Denis Kenzior
2012-08-16  6:57       ` Christopher Vogl
2012-08-16  5:57         ` Denis Kenzior
2012-09-06  9:25   ` [PATCH 2/2] netreg: Add telit version for ciev notification christopher.vogl
2012-09-06  9:25     ` [PATCH 1/2] netreg: Query and select supported CMER modes christopher.vogl
2012-09-06  9:36   ` [PATCH 2/2] netreg: Add telit version for ciev notification christopher.vogl
2012-09-06  9:49   ` christopher.vogl
2012-09-06  9:49     ` [PATCH 1/2] netreg: Query and select supported CMER modes christopher.vogl
2012-09-12  4:22       ` Denis Kenzior
2012-09-12  4:24     ` [PATCH 2/2] netreg: Add telit version for ciev notification Denis Kenzior
2012-09-12  8:13       ` Christopher Vogl
2012-09-12 13:53         ` Denis Kenzior
2012-09-12 15:07           ` Christopher Vogl

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=50292A75.3040005@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