From 41050ef7b12f704fb01f8226e5991000adbea7be Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Wed, 18 Nov 2009 10:34:23 -0600 Subject: Implement CGREG query Some modems do not properly send CGREG notifications when the context is attached / detached. We manually query the registration state of GPRS to make sure that if the modem is indeed attached, the state is reflected properly --- src/gprs.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/gprs.c b/src/gprs.c index 488f6d75..6b88fcbb 100644 --- a/src/gprs.c +++ b/src/gprs.c @@ -360,6 +360,8 @@ static void pri_activate_callback(const struct ofono_error *error, DBusConnection *conn = ofono_dbus_get_connection(); dbus_bool_t value; + DBG("%p %s", ctx, interface); + if (error->type != OFONO_ERROR_TYPE_NO_ERROR) { ofono_debug("Activating context failed with error: %s", telephony_error_to_str(error)); @@ -866,16 +868,34 @@ static void gprs_attached_update(struct ofono_gprs *gprs) "Attached", DBUS_TYPE_BOOLEAN, &value); } -static void gprs_attach_callback(const struct ofono_error *error, void *data) +static void registration_status_cb(const struct ofono_error *error, + int status, int lac, int ci, int tech, + void *data) { struct ofono_gprs *gprs = data; + if (error->type == OFONO_ERROR_TYPE_NO_ERROR) + ofono_gprs_status_notify(gprs, status, lac, ci, tech); + gprs->flags &= ~GPRS_FLAG_ATTACHING; +} + +static void gprs_attach_callback(const struct ofono_error *error, void *data) +{ + struct ofono_gprs *gprs = data; if (error->type == OFONO_ERROR_TYPE_NO_ERROR) { gprs->driver_attached = !gprs->driver_attached; gprs_attached_update(gprs); } + + if (gprs->driver->registration_status) { + gprs->driver->registration_status(gprs, registration_status_cb, + gprs); + return; + } + + gprs->flags &= ~GPRS_FLAG_ATTACHING; } static void gprs_netreg_update(struct ofono_gprs *gprs) -- cgit v1.2.3