Skip to contentSkip to conversation

gprs: deattach driver when gprs status indicates unregistered

PATCH Applied [email protected] 2 participants 3 messages Sep 17, 2019 – Sep 20, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gprs: deattach driver when gprs status indicates unregistered

From: Richard Röjfors <[email protected]>

In the same way as we consider the driver attached when the gprs status indicates we are registered, we should consider it deattached when the status indicates unregistration.

If we don't, then we would not always recover from the case when deattaching the driver fails. We would just revert back the driver attached status to true, and "ignore" if the status indicates the opposite when we check the registration status afterwards.

---
 src/gprs.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
src/gprs.c +6 -6
index de172979..c7b181f5 100644
@@ -2568,12 +2568,6 @@ void ofono_gprs_status_notify(struct ofono_gprs *gprs, int status)
 
 	gprs->status = status;
 
-	if (status != NETWORK_REGISTRATION_STATUS_REGISTERED &&
-			status != NETWORK_REGISTRATION_STATUS_ROAMING) {
-		gprs_attached_update(gprs);
-		return;
-	}
-
 	/*
 	 * If we're already taking action, e.g. attaching or detaching, then
 	 * ignore this notification for now, we will take appropriate action
@@ -2582,6 +2576,12 @@ void ofono_gprs_status_notify(struct ofono_gprs *gprs, int status)
 	if (gprs->flags & GPRS_FLAG_ATTACHING)
 		return;
 
+	if (status != NETWORK_REGISTRATION_STATUS_REGISTERED &&
+			status != NETWORK_REGISTRATION_STATUS_ROAMING) {
+		ofono_gprs_detached_notify(gprs);
+		return;
+	}
+
 	/* We registered without being powered */
 	if (gprs->powered == FALSE)
 		goto detach;
Signature · 1 line
2.20.1
#1 lore raw

...and a log for this:

Got deregistered

Sep 17 20:02:22 daemon.info: Aux: < \r\n+CREG: 0\r\n
Sep 17 20:02:22 daemon.debug:
../git/src/network.c:ofono_netreg_status_notify() /ublox_0 status 0 tech -1
lac -1 ci -1
Sep 17 20:02:22 daemon.debug:
../git/src/network.c:current_operator_callback() 0x1bb4360, 0x1bb6ae0
Sep 17 20:02:22 daemon.debug: ../git/src/gprs.c:netreg_status_changed() 0
(unregistered)
Sep 17 20:02:22 daemon.debug: ../git/src/gprs.c:gprs_netreg_update()
attach: 0, driver_attached: 1
Sep 17 20:02:22 daemon.debug: ../git/src/gprs.c:netreg_status_changed() 0
(unregistered)
Sep 17 20:02:22 daemon.debug: ../git/src/gprs.c:gprs_netreg_update()
attach: 0, driver_attached: 0
Sep 17 20:02:22 daemon.info: Aux: > AT\r
Sep 17 20:02:22 daemon.info: Aux: < \r\n+CIEV: 7,0\r\n
Sep 17 20:02:22 daemon.info: Aux: < \r\nOK\r\n
Sep 17 20:02:22 daemon.info: Aux: Finally woke up the modem
Sep 17 20:02:22 daemon.info: Aux: > AT+CGATT=0\r
Sep 17 20:02:22 daemon.info: Aux: < \r\n+CME ERROR: 148\r\n

Detach failed - driver_attached is set to 1 again

Sep 17 20:02:22 daemon.debug: ../git/src/gprs.c:gprs_attach_callback()
/ublox_0 error = 1
Sep 17 20:02:22 daemon.info: Aux: > AT+CGREG?\r
Sep 17 20:02:22 daemon.info: Aux: < \r\n+CGREG: 4\r\n
Sep 17 20:02:22 daemon.info: Aux: < \r\n+UREG: 0\r\n
Sep 17 20:02:22 daemon.info: Aux: < \r\n+CIEV: 9,1\r\n
Sep 17 20:02:22 daemon.info: Aux: < \r\n+CGREG: 2,4\r\n
Sep 17 20:02:22 daemon.info: Aux: < \r\nOK\r\n
Sep 17 20:02:22 daemon.debug: ../git/src/gprs.c:registration_status_cb()

/ublox_0 error 0 status 4

We read back the registration status, but does not set the driver_attached to 0

Sep 17 20:02:22 daemon.debug: ../git/src/gprs.c:ofono_gprs_status_notify()
/ublox_0 status unknown (4)
Sep 17 20:02:22 daemon.debug:
../git/src/gprs.c:gprs_set_attached_property() 0x1bb1500 1 -> 0
Sep 17 20:02:33 daemon.info: Aux: < \r\n+CREG: 0\r\n
Sep 17 20:02:33 daemon.debug:
../git/src/network.c:ofono_netreg_status_notify() /ublox_0 status 0 tech -1
lac -1 ci -1
Sep 17 20:02:33 daemon.debug:
../git/src/network.c:current_operator_callback() 0x1bb4360, (nil)
Sep 17 20:02:33 daemon.debug: ../git/src/gprs.c:netreg_status_changed() 0
(unregistered)
Sep 17 20:02:33 daemon.debug: ../git/src/gprs.c:gprs_netreg_update()

attach: 0, driver_attached: 1

We still believe the driver is attached, trying to detach again

Sep 17 20:02:33 daemon.info: Aux: > AT\r
Sep 17 20:02:33 daemon.info: Aux: < \r\nOK\r\n
Sep 17 20:02:33 daemon.info: Aux: Finally woke up the modem
Sep 17 20:02:33 daemon.info: Aux: > AT+CGATT=0\r
Sep 17 20:05:33 daemon.info: Aux: < \r\n+CME ERROR: 2000\r\n

Detach failed again, setting back driver_attached to 1

Sep 17 20:05:33 daemon.debug: ../git/src/gprs.c:gprs_attach_callback()
/ublox_0 error = 1
Sep 17 20:05:33 daemon.info: Aux: > AT\r
Sep 17 20:05:33 daemon.info: Aux: < \r\nOK\r\n
Sep 17 20:05:33 daemon.info: Aux: Finally woke up the modem
Sep 17 20:05:33 daemon.info: Aux: > AT+CGREG?\r
Sep 17 20:05:33 daemon.info: Aux: < \r\n+CGREG: 2,4\r\n
Sep 17 20:05:33 daemon.info: Aux: < \r\nOK\r\n
Sep 17 20:05:33 daemon.debug: ../git/src/gprs.c:registration_status_cb()

/ublox_0 error 0 status 4

We still do not set driver_attached to 0, even CREG says unknown status

Sep 17 20:05:33 daemon.debug: ../git/src/gprs.c:ofono_gprs_status_notify()
/ublox_0 status unknown (4)
Sep 17 20:05:33 daemon.info: Aux: < \r\n+CTZE: +08,1,"19/09/17,22:02:36"\r\n
Sep 17 20:05:33 daemon.info: Aux: < \r\n+CREG: 5,"0000","00000010",2\r\n
Sep 17 20:05:33 daemon.debug:
../git/drivers/ubloxmodem/network-registration.c:ctze_notify() tz +08 dst 1
time 19/09/17,22:02:36
Sep 17 20:05:33 daemon.debug:
../git/src/network.c:ofono_netreg_time_notify() net time 2019-09-17
22:02:36 utcoff 7200 dst 1
Sep 17 20:05:33 daemon.debug:
../git/src/network.c:ofono_netreg_status_notify() /ublox_0 status 5 tech 2
lac 0 ci 16
Sep 17 20:05:33 daemon.debug: ../git/src/gprs.c:netreg_status_changed() 5
(roaming)
Sep 17 20:05:33 daemon.debug: ../git/src/gprs.c:gprs_netreg_update()

attach: 1, driver_attached: 1

We now got registered, but we believe the driver is attached, so no action is taken and the driver will not be attached...
and the Attached D-Bus property will remain False.

--Richard

Den tis 17 sep. 2019 kl 23:48 skrev <[email protected]>:

Quoted 53 lines

From: Richard Röjfors <[email protected]>

In the same way as we consider the driver attached when the gprs status indicates we are registered, we should consider it deattached when the status indicates unregistration.

If we don't, then we would not always recover from the case when deattaching the driver fails. We would just revert back the driver attached status to true, and "ignore" if the status indicates the opposite when we check the registration status afterwards.

---
 src/gprs.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
src/gprs.c +0 -6
index de172979..c7b181f5 100644
@@ -2568,12 +2568,6 @@ void ofono_gprs_status_notify(struct ofono_gprs
 *gprs, int status)
 
        gprs->status = status;
 
-       if (status != NETWORK_REGISTRATION_STATUS_REGISTERED &&
-                       status != NETWORK_REGISTRATION_STATUS_ROAMING) {
-               gprs_attached_update(gprs);
-               return;
-       }
-
        /*
         * If we're already taking action, e.g. attaching or detaching,

then
* ignore this notification for now, we will take appropriate
action

src/gprs.c +6 -0
@@ -2582,6 +2576,12 @@ void ofono_gprs_status_notify(struct ofono_gprs
 *gprs, int status)
        if (gprs->flags & GPRS_FLAG_ATTACHING)
                return;
 
+       if (status != NETWORK_REGISTRATION_STATUS_REGISTERED &&
+                       status != NETWORK_REGISTRATION_STATUS_ROAMING) {
+               ofono_gprs_detached_notify(gprs);
+               return;
+       }
+
        /* We registered without being powered */
        if (gprs->powered == FALSE)
                goto detach;

--
2.20.1

#2 lore raw
In reply to [email protected]

Hi Richard,

Quoted 6 lines · richard.rojfors(a)gmail.com

From: Richard Röjfors <[email protected]>

In the same way as we consider the driver attached when the gprs status indicates we are registered, we should consider it deattached when the status indicates unregistration.

Quoted 9 lines

If we don't, then we would not always recover from the case when deattaching the driver fails. We would just revert back the driver attached status to true, and "ignore" if the status indicates the opposite when we check the registration status afterwards.

---
  src/gprs.c | 12 ++++++------
  1 file changed, 6 insertions(+), 6 deletions(-)

Applied, thanks.

Regards,
-Denis