Hi Dragos, On 03/09/2016 09:44 AM, Dragos Tatulea wrote: > Don't use CGREG for network notifications. It will return > 4 both when registered in LTE and in unknown state. > > For the CGREG? query, interpret 4 as registered. > --- > drivers/atmodem/gprs.c | 24 +++++++++++++++++++++--- > 1 file changed, 21 insertions(+), 3 deletions(-) > > diff --git a/drivers/atmodem/gprs.c b/drivers/atmodem/gprs.c > index 4505477..0b4bce8 100644 > --- a/drivers/atmodem/gprs.c > +++ b/drivers/atmodem/gprs.c > @@ -101,6 +101,17 @@ static void at_cgreg_cb(gboolean ok, GAtResult *result, gpointer user_data) > return; > } > > + if (gd->vendor == OFONO_VENDOR_UBLOX_TOBY_L2 && status == 4) { > + /* > + * UBX-13002752-R33 says: > + * If the module is registered to E-UTRAN the parameter is 4. > + * So this means we are actually registered. > + * It could also mean that state is unknown, but if we are > + * here we know we already registered. > + */ > + status = 1; > + } > + Does ublox support AT+UREG? ? Perhaps that would be easier than making this hack. The core polls gprs_driver->attached_status in various cases, so assuming that 4==1 here seems unsafe. > cb(&error, status, cbd->data); > } > > @@ -342,16 +353,23 @@ static void gprs_initialized(gboolean ok, GAtResult *result, gpointer user_data) > struct gprs_data *gd = ofono_gprs_get_data(gprs); > > g_at_chat_register(gd->chat, "+CGEV:", cgev_notify, FALSE, gprs, NULL); > - g_at_chat_register(gd->chat, "+CGREG:", cgreg_notify, > - FALSE, gprs, NULL); > + > + /* > + * You really don't want to get CGREG notifications on Toby l2. > + * It sends 4 when BOTH for unknown state and for registered in LTE. > + * +UREG usage is recommended by them. > + */ > + if (gd->vendor != OFONO_VENDOR_UBLOX_TOBY_L2) > + g_at_chat_register(gd->chat, "+CGREG:", cgreg_notify, > + FALSE, gprs, NULL); > > switch (gd->vendor) { > case OFONO_VENDOR_HUAWEI: > g_at_chat_register(gd->chat, "^MODE:", huawei_mode_notify, > FALSE, gprs, NULL); > break; > - case OFONO_VENDOR_UBLOX: > case OFONO_VENDOR_UBLOX_TOBY_L2: > + case OFONO_VENDOR_UBLOX: > g_at_chat_register(gd->chat, "+UREG:", ublox_ureg_notify, > FALSE, gprs, NULL); > g_at_chat_send(gd->chat, "AT+UREG=1", none_prefix, > Regards, -Denis