All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 1/4] network-registration.c: add telit support
@ 2011-06-08 15:18 Bernhard.Guillon
  2011-06-06 22:52 ` Denis Kenzior
                   ` (3 more replies)
  0 siblings, 4 replies; 17+ messages in thread
From: Bernhard.Guillon @ 2011-06-08 15:18 UTC (permalink / raw)
  To: ofono

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

From: Bernhard Guillon <Bernhard.Guillon@hale.at>

*add support for CIND=? tokens like ("signal",(0-7,99))
*add telit quirk for token encapsulation e.g.
    (("one",(0-7,99)),("two",(0-7,99)))
---
 drivers/atmodem/network-registration.c |   41 ++++++++++++++++++++++++++++----
 1 files changed, 36 insertions(+), 5 deletions(-)

diff --git a/drivers/atmodem/network-registration.c b/drivers/atmodem/network-registration.c
index b3aa511..7c86fec 100644
--- a/drivers/atmodem/network-registration.c
+++ b/drivers/atmodem/network-registration.c
@@ -56,6 +56,7 @@ struct netreg_data {
 	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 */
+	int signal_invalid; /* invalid strength reported via CIND */
 	int tech;
 	struct ofono_network_time time;
 	guint nitz_timeout;
@@ -666,7 +667,11 @@ static void ciev_notify(GAtResult *result, gpointer user_data)
 	if (!g_at_result_iter_next_number(&iter, &strength))
 		return;
 
-	strength = (strength * 100) / (nd->signal_max - nd->signal_min);
+	if (strength == nd->signal_invalid)
+		strength = -1;
+	else
+		strength = (strength * 100) / (nd->signal_max - nd->signal_min);
+
 	ofono_netreg_strength_notify(netreg, strength);
 }
 
@@ -798,7 +803,10 @@ static void cind_cb(gboolean ok, GAtResult *result, gpointer user_data)
 
 	g_at_result_iter_next_number(&iter, &strength);
 
-	strength = (strength * 100) / (nd->signal_max - nd->signal_min);
+	if (strength == nd->signal_invalid)
+		strength = -1;
+	else
+		strength = (strength * 100) / (nd->signal_max - nd->signal_min);
 
 	cb(&error, strength, cbd->data);
 }
@@ -1133,7 +1141,9 @@ static void cind_support_cb(gboolean ok, GAtResult *result, gpointer user_data)
 	GAtResultIter iter;
 	const char *str;
 	int index;
-	int min, max;
+	int min = 0;
+	int max = 0;
+	int tmp_min, tmp_max, invalid;
 
 	if (!ok)
 		goto error;
@@ -1144,15 +1154,32 @@ static void cind_support_cb(gboolean ok, GAtResult *result, gpointer user_data)
 
 	index = 1;
 
+	/*
+	 * Telit encapsulates the CIND=? tokens with braces
+	 * so we need to skip them
+	 */
+	if (nd->vendor == OFONO_VENDOR_TELIT)
+		g_at_result_iter_open_list(&iter);
+
 	while (g_at_result_iter_open_list(&iter)) {
+		/* Reset invalid default value for every token*/
+		invalid = 99;
+
 		if (!g_at_result_iter_next_string(&iter, &str))
 			goto error;
 
 		if (!g_at_result_iter_open_list(&iter))
 			goto error;
 
-		while (g_at_result_iter_next_range(&iter, &min, &max))
-			;
+		while (g_at_result_iter_next_range(&iter, &tmp_min, &tmp_max)) {
+
+			if (tmp_min != tmp_max) {
+				min = tmp_min;
+				max = tmp_max;
+			} else
+				invalid = tmp_min;
+
+		}
 
 		if (!g_at_result_iter_close_list(&iter))
 			goto error;
@@ -1164,11 +1191,15 @@ static void cind_support_cb(gboolean ok, GAtResult *result, gpointer user_data)
 			nd->signal_index = index;
 			nd->signal_min = min;
 			nd->signal_max = max;
+			nd->signal_invalid = invalid;
 		}
 
 		index += 1;
 	}
 
+	if (nd->vendor == OFONO_VENDOR_TELIT)
+		g_at_result_iter_close_list(&iter);
+
 	if (nd->signal_index == 0)
 		goto error;
 
-- 
1.7.0.4



--
Scanned by MailScanner.


^ permalink raw reply related	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2011-06-15  9:12 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-08 15:18 [PATCH v4 1/4] network-registration.c: add telit support Bernhard.Guillon
2011-06-06 22:52 ` Denis Kenzior
2011-06-08 15:18 ` [PATCH v4 2/4] Add basic Telit UC864-G support: Bernhard.Guillon
2011-06-08  9:29   ` Denis Kenzior
2011-06-14  8:42     ` Bernhard Guillon
2011-06-09 10:26   ` Marcel Holtmann
2011-06-08 15:18 ` [PATCH v4 3/4] atmodem/vendor.h: add OFONO_VENDOR_TELIT Bernhard.Guillon
2011-06-06 22:51   ` Denis Kenzior
2011-06-08 15:18 ` [PATCH v4 4/4] udev: add Telit UC864-G and update udev rules Bernhard.Guillon
2011-06-08 15:32   ` Bernhard Guillon
2011-06-06 23:25     ` Denis Kenzior
2011-06-10  8:32       ` Bernhard Guillon
2011-06-08  8:32         ` Denis Kenzior
2011-06-14  8:34           ` Bernhard Guillon
2011-06-13  9:28             ` Denis Kenzior
2011-06-15  9:12               ` Bernhard Guillon
2011-06-13  9:04   ` Denis Kenzior

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.