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