All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 7/8] netreg: adapt CMER and CIEV for telit
@ 2012-08-13 13:23 Christopher Vogl
  2012-08-13 16:25 ` Denis Kenzior
  0 siblings, 1 reply; 16+ messages in thread
From: Christopher Vogl @ 2012-08-13 13:23 UTC (permalink / raw)
  To: ofono

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

Telit uses a 2 to enable indicator event reporting and
indicators in a +CIEV URC are identified by strings, not numbers.
---
 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 (!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);
 
 	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,
 			NULL, NULL, NULL);
 	g_at_chat_register(nd->chat, "+CIEV:",
 				ciev_notify, FALSE, netreg, NULL);
-- 
1.7.7.6


--
Scanned by MailScanner.


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

end of thread, other threads:[~2012-09-12 15:07 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-13 13:23 [PATCH 7/8] netreg: adapt CMER and CIEV for telit Christopher Vogl
2012-08-13 16:25 ` Denis Kenzior
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

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.