From aa89c19a506fd0d365e8af79801cc80b28533db1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Richard=20R=C3=B6jfors?= Date: Wed, 11 Dec 2019 20:13:17 +0100 Subject: [PATCH] gprs: Update attach state on context deactivation for LTE To be considered attached on LTE a context should be activated. But in case the context got deactivated we did not update the attached state, it remained attached. That caused the connection manager to try to re-activate the context manually, but for LTE thats done automatically. In the case of ublox it returns errors, which is passed on to the connection manager, which tries again and again, until we get attached again. It looked like this: 12:03:18 ofonod[547]: Aux: < \r\n+CIEV: 2,3\r\n 12:03:23 ofonod[547]: Aux: < \r\n+CIEV: 2,2\r\n Deactivated 12:16:01 ofonod[547]: Aux: < \r\n+CGEV: NW PDN DEACT 4\r\n 12:16:01 ofonod[547]: drivers/ubloxmodem/gprs-context.c:cgev_notify() cid 4, active cid: 4 12:16:01 ofonod[547]: src/gprs.c:ofono_gprs_context_deactivated() 0x1743e50 0x17424a8 4 Connection manager now try to activate, over and over again because Attached remains TRUE 12:16:01 ofonod[547]: drivers/ubloxmodem/gprs-context.c:ublox_gprs_activate_primary() cid 1 12:16:01 ofonod[547]: Aux: > AT+CGDCONT=1,"IP","apn"\r 12:16:01 ofonod[547]: Aux: < \r\nOK\r\n 12:16:01 ofonod[547]: drivers/ubloxmodem/gprs-context.c:cgdcont_cb() ok 1 12:16:01 ofonod[547]: Aux: > AT+CGACT=1,1\r 12:16:01 ofonod[547]: Aux: < \r\n+CME ERROR: 30\r\n 12:16:01 ofonod[547]: drivers/ubloxmodem/gprs-context.c:cgact_enable_cb() ok 0 12:16:01 ofonod[547]: src/gprs.c:pri_activate_callback() 0x17475c0 12:16:01 ofonod[547]: src/gprs.c:pri_activate_callback() Activating context failed with error: No network service 12:16:01 ofonod[547]: drivers/ubloxmodem/gprs-context.c:ublox_gprs_activate_primary() cid 1 12:16:02 ofonod[547]: Aux: > AT+CGDCONT=1,"IP","apn"\r 12:16:02 ofonod[547]: Aux: < \r\nOK\r\n 12:16:02 ofonod[547]: drivers/ubloxmodem/gprs-context.c:cgdcont_cb() ok 1 12:16:02 ofonod[547]: Aux: > AT+CGACT=1,1\r 12:16:02 ofonod[547]: Aux: < \r\n+CME ERROR: 30\r\n 12:16:02 ofonod[547]: drivers/ubloxmodem/gprs-context.c:cgact_enable_cb() ok 0 12:16:02 ofonod[547]: src/gprs.c:pri_activate_callback() 0x17475c0 12:16:02 ofonod[547]: src/gprs.c:pri_activate_callback() Activating context failed with error: No network service . . . 12:16:14 ofonod[547]: drivers/ubloxmodem/gprs-context.c:ublox_gprs_activate_primary() cid 1 12:16:14 ofonod[547]: Aux: > AT+CGDCONT=1,"IP","apn"\r 12:16:14 ofonod[547]: Aux: < \r\nOK\r\n 12:16:14 ofonod[547]: drivers/ubloxmodem/gprs-context.c:cgdcont_cb() ok 1 12:16:14 ofonod[547]: Aux: > AT+CGACT=1,1\r 12:16:14 ofonod[547]: Aux: < \r\n+CME ERROR: 30\r\n 12:16:14 ofonod[547]: drivers/ubloxmodem/gprs-context.c:cgact_enable_cb() ok 0 12:16:14 ofonod[547]: src/gprs.c:pri_activate_callback() 0x17475c0 12:16:14 ofonod[547]: src/gprs.c:pri_activate_callback() Activating context failed with error: No network service 12:16:14 ofonod[547]: drivers/ubloxmodem/gprs-context.c:ublox_gprs_activate_primary() cid 1 12:16:14 ofonod[547]: Aux: > AT+CGDCONT=1,"IP","apn"\r 12:16:14 ofonod[547]: Aux: < \r\nOK\r\n 12:16:14 ofonod[547]: drivers/ubloxmodem/gprs-context.c:cgdcont_cb() ok 1 12:16:14 ofonod[547]: Aux: > AT+CGACT=1,1\r The context got activated again 12:16:14 ofonod[547]: Aux: < \r\n+CGEV: ME PDN ACT 4\r\n\r\n+CIEV: 9,2\r\n\r\n+CTZE: +04,0,"19/12/11,13:17:58"\r\n 12:16:14 ofonod[547]: drivers/ubloxmodem/network-registration.c:ctze_notify() tz +04 dst 0 time 19/12/11,13:17:58 12:16:14 ofonod[547]: src/network.c:ofono_netreg_time_notify() net time 2019-12-11 13:17:58 utcoff 3600 dst 0 12:16:14 ofonod[547]: Aux: < \r\n+CME ERROR: 100\r\n 12:16:14 ofonod[547]: drivers/ubloxmodem/gprs-context.c:cgact_enable_cb() ok 0 12:16:14 ofonod[547]: src/gprs.c:pri_activate_callback() 0x17475c0 12:16:14 ofonod[547]: src/gprs.c:pri_activate_callback() Activating context failed with error: Unknown error --- src/gprs.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/gprs.c b/src/gprs.c index 2593c4ad..daf2611b 100644 --- a/src/gprs.c +++ b/src/gprs.c @@ -2738,14 +2738,15 @@ void ofono_gprs_context_deactivated(struct ofono_gprs_context *gc, unsigned int cid) { DBusConnection *conn = ofono_dbus_get_connection(); + struct ofono_gprs *gprs = gc->gprs; GSList *l; struct pri_context *ctx; dbus_bool_t value; - if (gc->gprs == NULL) + if (gprs == NULL) return; - for (l = gc->gprs->contexts; l; l = l->next) { + for (l = gprs->contexts; l; l = l->next) { ctx = l->data; if (ctx->context.cid != cid) @@ -2767,10 +2768,13 @@ void ofono_gprs_context_deactivated(struct ofono_gprs_context *gc, * If "Attached" property was about to be signalled as TRUE but there * were still active contexts, try again to signal "Attached" property * to registered applications after active contexts have been released. + * + * "Attached" could also change to FALSE in case of LTE and getting + * deactivated */ - if (gc->gprs->flags & GPRS_FLAG_ATTACHED_UPDATE) { - gc->gprs->flags &= ~GPRS_FLAG_ATTACHED_UPDATE; - gprs_attached_update(gc->gprs); + if (on_lte(gprs) || gprs->flags & GPRS_FLAG_ATTACHED_UPDATE) { + gprs->flags &= ~GPRS_FLAG_ATTACHED_UPDATE; + gprs_attached_update(gprs); } }