Open Source Telephony
 help / color / mirror / Atom feed
From: Dragos Tatulea <dragos@endocode.com>
To: ofono@ofono.org
Subject: [PATCH 3/3] atmodem: gprs: do CEREG instead of CGREG for LTE
Date: Sat, 12 Mar 2016 15:51:32 +0100	[thread overview]
Message-ID: <1457794292-21184-4-git-send-email-dragos@endocode.com> (raw)
In-Reply-To: <1457794292-21184-1-git-send-email-dragos@endocode.com>

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

If we do CGREG in LTE we might get a bad registration status. That is
it will return unknown/out of coverage because it's registered on
on LTE.
---
 drivers/atmodem/gprs.c | 42 ++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 40 insertions(+), 2 deletions(-)

diff --git a/drivers/atmodem/gprs.c b/drivers/atmodem/gprs.c
index 0165253..ba0c802 100644
--- a/drivers/atmodem/gprs.c
+++ b/drivers/atmodem/gprs.c
@@ -39,10 +39,12 @@
 #include "gatchat.h"
 #include "gatresult.h"
 
+#include "common.h"
 #include "atmodem.h"
 #include "vendor.h"
 
 static const char *cgreg_prefix[] = { "+CGREG:", NULL };
+static const char *cereg_prefix[] = { "+CEREG:", NULL };
 static const char *cgdcont_prefix[] = { "+CGDCONT:", NULL };
 static const char *none_prefix[] = { NULL };
 
@@ -104,12 +106,38 @@ static void at_cgreg_cb(gboolean ok, GAtResult *result, gpointer user_data)
 	cb(&error, status, cbd->data);
 }
 
+static void at_cereg_cb(gboolean ok, GAtResult *result, gpointer user_data)
+{
+	struct cb_data *cbd = user_data;
+	ofono_gprs_status_cb_t cb = cbd->cb;
+	struct ofono_error error;
+	int status;
+	struct gprs_data *gd = cbd->user;
+
+	decode_at_error(&error, g_at_result_final_response(result));
+
+	if (!ok) {
+		cb(&error, -1, cbd->data);
+		return;
+	}
+
+	if (at_util_parse_reg(result, "+CEREG:", NULL, &status,
+				NULL, NULL, NULL, gd->vendor) == FALSE) {
+		CALLBACK_WITH_FAILURE(cb, -1, cbd->data);
+		return;
+	}
+
+	cb(&error, status, cbd->data);
+
+}
+
 static void at_gprs_registration_status(struct ofono_gprs *gprs,
 					ofono_gprs_status_cb_t cb,
 					void *data)
 {
 	struct gprs_data *gd = ofono_gprs_get_data(gprs);
 	struct cb_data *cbd = cb_data_new(cb, data);
+	int ret;
 
 	cbd->user = gd;
 
@@ -132,8 +160,18 @@ static void at_gprs_registration_status(struct ofono_gprs *gprs,
 		break;
 	}
 
-	if (g_at_chat_send(gd->chat, "AT+CGREG?", cgreg_prefix,
-				at_cgreg_cb, cbd, g_free) > 0)
+	switch (ofono_gprs_get_technology(gprs)) {
+	case ACCESS_TECHNOLOGY_EUTRAN:
+		ret = g_at_chat_send(gd->chat, "AT+CEREG?", cereg_prefix,
+					at_cereg_cb, cbd, g_free);
+		break;
+	default:
+		ret = g_at_chat_send(gd->chat, "AT+CGREG?", cgreg_prefix,
+					at_cgreg_cb, cbd, g_free);
+		break;
+	}
+
+	if (ret > 0)
 		return;
 
 	g_free(cbd);
-- 
2.5.0


      parent reply	other threads:[~2016-03-12 14:51 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-12 14:51 [RFC v0 0/3] use GEREG for when in LTE networks Dragos Tatulea
2016-03-12 14:51 ` [PATCH 1/3] gprs.h: add api for reading access technology Dragos Tatulea
2016-03-12 14:51 ` [PATCH 2/3] gprs: " Dragos Tatulea
2016-03-12 14:51 ` Dragos Tatulea [this message]

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=1457794292-21184-4-git-send-email-dragos@endocode.com \
    --to=dragos@endocode.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox