2009/10/25 Denis Kenzior <[email protected]>:
>> > Lets suppose status=registered arrives and we're already attached.  Here
>> > attached will be set to FALSE, Attached property will be set to false and
>> > emitted.  gprs_netreg_update will presumably reset Attached back to True.
>>
>> Now I see it and you're absolutely right to be alerted, I set
>> "attached" to the reverse of what it should be set to.  We're attached
>> when we're either in REGISTERED or ROAMING state.  If I had done it
>> right then the logic would look simple (I suppose):
>
> I still don't believe that it works.  Suppose we're attached and registered.
> Now we get an indication that we're in 'searching' state.  set attach to true,
> compare with stored value (true).  Ah, don't do anything -> not good.

I tried to say that I agree that current code is wrong, but assuming
the variable "attached" was set correctly, this would not happen (see
attached patch).

Now that I think of it if the current status is 'searching' then
possibly there's no point calling driver->set_attached (see second
patch).

> Resetting Powered in the core leads to strange situations where after coming
> from an overseas trip you'd need to reset Powered back to on.  I would find
> that annoying.
>
> The nice thing is I don't think we need to play the attach/detach dance.  We
> can take advantage of the netreg atom's information.  If we're roaming there,
> we will be roaming on GPRS as well.  If we're registered there, then we should
> try to attach.

That's a great idea, I will send a patch separately.

Regards
From 03f9b38d6ae5d98bcfb46c3f636b791e018b6515 Mon Sep 17 00:00:00 2001
From: Andrzej Zaborowski <[email protected]>
Date: Sun, 25 Oct 2009 09:14:54 +0100
Subject: [PATCH 1/2] Fix interpretation of new GPRS registration status signal.

---
 src/gprs.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/gprs.c b/src/gprs.c
index 1827ceb..bcba99c 100644
--- a/src/gprs.c
+++ b/src/gprs.c
@@ -882,8 +882,8 @@ static void set_registration_status(struct ofono_gprs *gprs, int status)
 					"Status", DBUS_TYPE_STRING,
 					&str_status);
 
-	attached = (status != NETWORK_REGISTRATION_STATUS_REGISTERED &&
-			status != NETWORK_REGISTRATION_STATUS_ROAMING);
+	attached = (status == NETWORK_REGISTRATION_STATUS_REGISTERED ||
+			status == NETWORK_REGISTRATION_STATUS_ROAMING);
 	if (gprs->attached != (int) attached &&
 			!(gprs->flags & GPRS_FLAG_ATTACHING)) {
 		gprs->attached = (int) attached;
-- 
1.6.1

From d0f0331ea8d3f8c4df75069cfca082bb99ce0dfa Mon Sep 17 00:00:00 2001
From: Andrzej Zaborowski <[email protected]>
Date: Sun, 25 Oct 2009 09:35:26 +0100
Subject: [PATCH 2/2] Don't ask driver to attach GPRS if modem is already searching for operator.

---
 src/gprs.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/gprs.c b/src/gprs.c
index bcba99c..2769c27 100644
--- a/src/gprs.c
+++ b/src/gprs.c
@@ -543,7 +543,9 @@ static void gprs_netreg_update(struct ofono_gprs *gprs)
 	attach = gprs->powered && operator_ok;
 
 	if (gprs->attached != attach &&
-			!(gprs->flags & GPRS_FLAG_ATTACHING)) {
+			!(gprs->flags & GPRS_FLAG_ATTACHING) &&
+			!(attach && gprs->status !=
+				NETWORK_REGISTRATION_STATUS_SEARCHING)) {
 		gprs->flags |= GPRS_FLAG_ATTACHING;
 
 		gprs->driver->set_attached(gprs, attach, gprs_attach_callback,
@@ -892,9 +894,9 @@ static void set_registration_status(struct ofono_gprs *gprs, int status)
 				DATA_CONNECTION_MANAGER_INTERFACE,
 				"Attached", DBUS_TYPE_BOOLEAN,
 				&attached);
-
-		gprs_netreg_update(gprs);
 	}
+
+	gprs_netreg_update(gprs);
 }
 
 static void set_registration_location(struct ofono_gprs *gprs,
-- 
1.6.1

_______________________________________________
ofono mailing list
[email protected]
http://lists.ofono.org/listinfo/ofono

Reply via email to