cdmamodem: Add Signal Strength Support
Hi Rajesh
Quoted 33 lines · ext Rajesh.Nagaiah(a)elektrobit.com
Hi Dara,
Quoted 31 lines
-----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){(quoted diff) +21
-0+ 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)
Quoted 8 lines
Review
Quoted 5 lines
(quoted diff) +5
-0+ *number = value; + + return TRUE; +} +This is a duplicate of
g_at_result_iter_next_number(). Why cant use this function instead ofcdma_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.
Quoted 22 lines
Quoted 22 lines
(quoted diff) +21
-0+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; + } +
Quoted 9 lines
Quoted 6 lines
(quoted diff) +5
-0+ 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