All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bernhard.Guillon@hale.at
To: ofono@ofono.org
Subject: [RFC PATCH 2/2] network-registration.c: implement CIND for Telit UC864-G
Date: Thu, 19 May 2011 12:40:24 +0200	[thread overview]
Message-ID: <1305801624-3410-2-git-send-email-Bernhard.Guillon@hale.at> (raw)
In-Reply-To: <1305801624-3410-1-git-send-email-Bernhard.Guillon@hale.at>

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

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

*UC864 has a incompatible CIND
*use specific constants for a KISS callback function
*add a Telit specific check for "not measurable" strength

Co-authored-by: Christopher Vogl <Christopher.Vogl@hale.at>
Signed-off-by: Bernhard Guillon <Bernhard.Guillon@hale.at>
---
 drivers/atmodem/network-registration.c |   38 +++++++++++++++++++++++++++++--
 1 files changed, 35 insertions(+), 3 deletions(-)

diff --git a/drivers/atmodem/network-registration.c b/drivers/atmodem/network-registration.c
index b3aa511..616faa2 100644
--- a/drivers/atmodem/network-registration.c
+++ b/drivers/atmodem/network-registration.c
@@ -48,6 +48,10 @@ static const char *cops_prefix[] = { "+COPS:", NULL };
 static const char *csq_prefix[] = { "+CSQ:", NULL };
 static const char *cind_prefix[] = { "+CIND:", NULL };
 static const char *option_tech_prefix[] = { "_OCTI:", "_OUWCTI:", NULL };
+static const int telit_signal_not_measurable = 99;
+static const int telit_signal_index = 9;
+static const int telit_signal_min = 0;
+static const int telit_signal_max = 5;
 
 struct netreg_data {
 	GAtChat *chat;
@@ -666,7 +670,16 @@ 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);
+	switch (nd->vendor) {
+		case OFONO_VENDOR_TELIT:
+			if (strength == telit_signal_not_measurable)
+				strength = 0;
+			else
+				strength = (strength * 100) / (nd->signal_max - nd->signal_min);
+			break;
+		default:
+			strength = (strength * 100) / (nd->signal_max - nd->signal_min);
+	}
 	ofono_netreg_strength_notify(netreg, strength);
 }
 
@@ -798,8 +811,16 @@ 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);
-
+	switch (nd->vendor) {
+		case OFONO_VENDOR_TELIT:
+			if (strength == telit_signal_not_measurable)
+				strength = 0;
+			else
+				strength = (strength * 100) / (nd->signal_max - nd->signal_min);
+			break;
+		default:
+			strength = (strength * 100) / (nd->signal_max - nd->signal_min);
+	}
 	cb(&error, strength, cbd->data);
 }
 
@@ -1302,6 +1323,17 @@ static void at_creg_set_cb(gboolean ok, GAtResult *result, gpointer user_data)
 	case OFONO_VENDOR_NOKIA:
 		/* Signal strength reporting via CIND is not supported */
 		break;
+	case OFONO_VENDOR_TELIT:
+		// FIXME: We use RSSI instead of signal.
+		// FIXME: Consider reading signal index from modem.
+		nd->signal_index = telit_signal_index;
+		nd->signal_min = telit_signal_min;
+		nd->signal_max = telit_signal_max;
+		g_at_chat_send(nd->chat, "AT+CIND=1", cind_prefix,
+								NULL, NULL, NULL);
+		g_at_chat_register(nd->chat, "+CIEV:",
+						ciev_notify, FALSE, netreg, NULL);
+		break;
 	default:
 		g_at_chat_send(nd->chat, "AT+CIND=?", cind_prefix,
 				cind_support_cb, netreg, NULL);
-- 
1.7.0.4



--
Scanned by MailScanner.


  reply	other threads:[~2011-05-19 10:40 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-19 10:40 [RFC PATCH 1/2] Add basic Telit UC864-G support: Bernhard.Guillon
2011-05-19 10:40 ` Bernhard.Guillon [this message]
2011-05-19 17:51   ` [RFC PATCH 2/2] network-registration.c: implement CIND for Telit UC864-G Marcel Holtmann
2011-05-19 17:48 ` [RFC PATCH 1/2] Add basic Telit UC864-G support: Marcel Holtmann
2011-05-25 13:01   ` Bernhard Guillon
2011-05-25 16:12     ` Marcel Holtmann

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=1305801624-3410-2-git-send-email-Bernhard.Guillon@hale.at \
    --to=bernhard.guillon@hale.at \
    --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.