Skip to contentSkip to conversation

cdmamodem: Add Signal Strength Support

PATCH [email protected] 1 participant 1 message Feb 10, 2011 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

Hi Dara,

Quoted 87 lines

-----Original Message-----
From: Dara Spieker-Doyle [mailto:dara.spiekerdoyle(a)gmail.com]

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 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.

Quoted 23 lines
Quoted 23 lines
(quoted diff) +22 -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;
+     }
+
+     cdma_get_next_number(attr,&strength);
Quoted 9 lines
Quoted 5 lines
(quoted diff) +4 -0
+
+     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

Quoted 10 lines

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 actually not in the same line as the actual response line, so I just 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.

Can you send whats the actual result of AT+CSQ from the modem ? If the last line is going to be only one number value, then you can use some utility function to convert that string to a numeric value, rather than duplicating g_at_result_iter_next_number() logic.

BR,
Rajesh