All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dara Spieker-Doyle <dara.spiekerdoyle@gmail.com>
To: ofono@ofono.org
Subject: Re: [PATCH 5/7] cdmamodem: Add Signal Strength Support
Date: Wed, 09 Feb 2011 18:54:46 -0800	[thread overview]
Message-ID: <4D535376.6090300@gmail.com> (raw)

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

Hi Rajesh

On 02/09/2011 02:58 PM, ext Rajesh.Nagaiah(a)elektrobit.com wrote:

> Hi Dara,
>
>> -----Original Message-----
>> From: ofono-bounces(a)ofono.org
>> [mailto:ofono-bounces(a)ofono.org] On Behalf Of Dara Spieker-Doyle
>> Sent: 08 February 2011 13:05
>> To: ofono(a)ofono.org
>> Subject: [PATCH 5/7] cdmamodem: Add Signal Strength Support
>>
>
>> +static gboolean cdma_get_next_number(const char *line, gint
>> *number) {
>> +     int pos;
>> +     int end;
>> +     int len;
>> +     int value = 0;
>> +
>> +     len = strlen(line);
>> +
>> +     pos = 0;
>> +     end = pos;
>> +
>> +     while (line[end]>= '0'&&  line[end]<= '9') {
>> +             value = value * 10 + (int)(line[end] - '0');
>> +             end += 1;
>> +     }
>> +
>> +     if (pos == end)
>> +             return FALSE;
>> +
>> +     pos = skip_to_next_field(line, end, len);
>> +
>> +     if (number)
>> +             *number = value;
>> +
>> +     return TRUE;
>> +}
>> +
>
> This is a duplicate of g_at_result_iter_next_number().
> Why cant use this function instead of cdma_get_next_number() ?

This is different from g_at_result_iter_next_number() in that it takes a 
raw response line to parse rather than the result iterator. The AT
syntax format of the response from this CDMA device does not follow the
GSM standard AT syntax format.

>
>> +static void cdma_csq_cb(gboolean ok, GAtResult *result, gpointer
>> +user_data) {
>> +     struct cb_data *cbd = user_data;
>> +     ofono_cdma_netreg_strength_cb_t cb = cbd->cb;
>> +     const char *prefix = cbd->user;
>> +     struct ofono_error error;
>> +     const char *attr;
>> +     int strength = -1;
>> +
>> +     decode_at_error(&error, g_at_result_final_response(result));
>> +
>> +     if (!ok) {
>> +             cb(&error, -1, cbd->data);
>> +             return;
>> +     }
>> +
>> +     if (at_util_parse_attr(result, prefix,&attr) == FALSE) {
>> +             CALLBACK_WITH_FAILURE(cb, -1, cbd->data);
>> +             return;
>> +     }
>> +
>> +     cdma_get_next_number(attr,&strength);
>> +
>> +     DBG("csq_cb: %d", strength);
>> +
>> +     cb(&error, at_util_convert_signal_strength(strength),
>> cbd->data); }
>
> Refer csq_cb() implementation in /drivers/atmodem/network-registration.c
>

If you are referring to the AT result iterator use in the atmodem csq
callback:- we cannot use that here due to the response format of this
CDMA device not being the same as the GSM standard.
The prefix in this case is not in the same line as the actual response 
line, so I opted to use the same algorithm as attr_cb() in 
/drivers/cdmamodem/devinfo for now and re-use at_util_parse_attr(), 
taking the last line as the response.
This could well need to be extended for alternative CDMA AT devices
added in the future, as the CDMA AT syntax is not standardised.

Cheers
Dara




             reply	other threads:[~2011-02-10  2:54 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-10  2:54 Dara Spieker-Doyle [this message]
     [not found] <4D535000.1000301@gmail.com>
2011-02-10  4:16 ` [PATCH 5/7] cdmamodem: Add Signal Strength Support Rajesh.Nagaiah
  -- strict thread matches above, loose matches on Subject: below --
2011-02-08 21:04 Dara Spieker-Doyle
2011-02-09 22:58 ` Rajesh.Nagaiah

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=4D535376.6090300@gmail.com \
    --to=dara.spiekerdoyle@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 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.