Open Source Telephony
 help / color / mirror / Atom feed
* [PATCH v2] fix can't attach GPRS issue
@ 2011-05-10  6:38 Caiwen Zhang
  2011-06-02  7:51 ` Denis Kenzior
  0 siblings, 1 reply; 8+ messages in thread
From: Caiwen Zhang @ 2011-05-10  6:38 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 2897 bytes --]

This patch is to fix the issue that can't attach GPRS after detach it. 

Cause:
  When start detaching GPRS, driver_attched value is set to FALSE, if
device registered to GPRS network during GPRS detaching, driver_attched is set to TURE.
After that, GPRS attaching will always be ignored because driver_attched is always TURE.
It seems the definition of driver_attched is confused.

Scenario:
  When device is unregistered(+CREG: 2), GPRS is detached. During GPRS detaching, device
registered to network again(+CREG: 1, xxx, xxx).

Solution:
  variable attached represents the GPRS attach status, it only be TRUE, when CGATT=1 and 
CGREG is registered or roaming(roaming allowed). variable driver_attached represents CGATT
status of the driver. its value will only be changed after set_attached successfully or 
GPRS detached notified. variable pending_attached represents the pending status of CGATT.


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

diff --git a/src/gprs.c b/src/gprs.c
index deffeb8..e221741 100644
--- a/src/gprs.c
+++ b/src/gprs.c
@@ -74,8 +74,9 @@ enum packet_bearer {
 
 struct ofono_gprs {
 	GSList *contexts;
-	ofono_bool_t attached;
+	ofono_bool_t attached; /*CGATT=1 and CGREG is registered or roaming*/
 	ofono_bool_t driver_attached;
+	ofono_bool_t pending_attached;
 	ofono_bool_t roaming_allowed;
 	ofono_bool_t powered;
 	ofono_bool_t suspended;
@@ -1499,8 +1500,8 @@ static void gprs_attach_callback(const struct ofono_error *error, void *data)
 
 	gprs->flags &= ~GPRS_FLAG_ATTACHING;
 
-	if (error->type != OFONO_ERROR_TYPE_NO_ERROR)
-		gprs->driver_attached = !gprs->driver_attached;
+	if (error->type == OFONO_ERROR_TYPE_NO_ERROR)
+		gprs->driver_attached = gprs->pending_attached;
 
 	if (gprs->driver->attached_status) {
 		gprs->driver->attached_status(gprs, registration_status_cb,
@@ -1539,18 +1540,23 @@ static void gprs_netreg_update(struct ofono_gprs *gprs)
 
 	attach = attach && gprs->powered;
 
-	if (gprs->driver_attached == attach)
-		return;
-
 	if (gprs->flags & GPRS_FLAG_ATTACHING) {
+		if (gprs->pending_attached == attach) {
+			gprs->flags &= ~GPRS_FLAG_RECHECK;
+			return;
+		}
+
 		gprs->flags |= GPRS_FLAG_RECHECK;
 		return;
+	} else {
+		if (gprs->driver_attached == attach)
+			return;
 	}
 
 	gprs->flags |= GPRS_FLAG_ATTACHING;
 
 	gprs->driver->set_attached(gprs, attach, gprs_attach_callback, gprs);
-	gprs->driver_attached = attach;
+	gprs->pending_attached = attach;
 }
 
 static void netreg_status_changed(int status, int lac, int ci, int tech,
@@ -2103,7 +2109,6 @@ void ofono_gprs_status_notify(struct ofono_gprs *gprs, int status)
 			status == NETWORK_REGISTRATION_STATUS_ROAMING)
 		goto detach;
 
-	gprs->driver_attached = TRUE;
 	gprs_attached_update(gprs);
 
 	return;
-- 
1.7.5


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2011-06-07  7:24 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-10  6:38 [PATCH v2] fix can't attach GPRS issue Caiwen Zhang
2011-06-02  7:51 ` Denis Kenzior
2011-06-03  2:15   ` Zhang, Caiwen
2011-06-02  9:13     ` Denis Kenzior
2011-06-03  3:42       ` Zhang, Caiwen
2011-06-02 12:22         ` Denis Kenzior
2011-06-07  7:24           ` Zhang, Caiwen
2011-06-06  2:00             ` Denis Kenzior

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox