use GEREG for when in LTE networks
cover use GEREG for when in LTE networks
Hi,
Here the first alternative to reading registration status on a LTE network correctly. This is an aswer to the review request for the U-Blox Toby L2 support patches.
The other proposed alternative was to change how the gprs core handles the attach status in LTE. But that needs a more thorough thinking. Until then this would be a decent interim solution.
Thanks,
Dragos
Dragos Tatulea (3):
gprs.h: add api for reading access technology
gprs: add api for reading access technology
atmodem: gprs: do CEREG instead of CGREG for LTE
drivers/atmodem/gprs.c | 42 ++++++++++++++++++++++++++++++++++++++++-- include/gprs.h | 2 ++ src/gprs.c | 5 +++++ 3 files changed, 47 insertions(+), 2 deletions(-)
Signature · 1 line
2.5.0
PATCH 1/3 gprs.h: add api for reading access technology
--- include/gprs.h | 2 ++ 1 file changed, 2 insertions(+)
include/gprs.h +2 -0
@@ -75,6 +75,8 @@ void ofono_gprs_remove(struct ofono_gprs *gprs);void ofono_gprs_set_data (struct ofono_gprs *gprs,void *data);void *ofono_gprs_get_data (struct ofono_gprs *gprs); +int ofono_gprs_get_technology (struct ofono_gprs *gprs); +void ofono_gprs_set_cid_range (struct ofono_gprs *gprs,unsigned int min,unsigned int max); void ofono_gprs_add_context(struct ofono_gprs *gprs,
Signature · 1 line
2.5.0
PATCH 2/3 gprs: add api for reading access technology
In reply to Dragos TatuleaResult forwarded from network.c.
--- src/gprs.c | 5 +++++ 1 file changed, 5 insertions(+)
src/gprs.c +5 -0
@@ -3248,3 +3248,8 @@ void *ofono_gprs_get_data(struct ofono_gprs *gprs) {return gprs->driver_data; } + +int ofono_gprs_get_technology (struct ofono_gprs *gprs) +{ +return ofono_netreg_get_technology (gprs->netreg); +}
Signature · 1 line
2.5.0
PATCH 3/3 atmodem: gprs: do CEREG instead of CGREG for LTE
In reply to Dragos TatuleaIf 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(-)
drivers/atmodem/gprs.c +40 -2
@@ -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);
Signature · 1 line
2.5.0