Hi,
I find there may be some issues about GPRS state, please help check them.
(1) gprs->driver_attached is set to TURE just according to GPRS registration
state.
It may cause the following issue.
1 ofonod[619]: PCUI: < \r\n^SRVST:1\r\n\r\n+CREG: 2\r\n\r\n+CGREG:
2\r\n\r\n^SRVST:2\r\n\r\n+CREG: 1, A807, A72B71\r\n\r\n+CGREG: 0\r\n
2 ofonod[619]: src/network.c:current_operator_callback() 0xa046ea0, 0xa0476e8
3 ofonod[619]: src/gprs.c:netreg_status_changed() 2
#driver_attached = FALSE
4 ofonod[619]: src/cbs.c:cbs_location_changed() 2, -1, -1, -1, (null)(null)
5 ofonod[619]: src/cbs.c:cbs_location_changed() 1, 0, 0
6 ofonod[619]: src/gprs.c:netreg_status_changed() 2
7 ofonod[619]: src/cbs.c:cbs_location_changed() 2, -1, -1, -1, (null)(null)
8 ofonod[619]: src/gprs.c:ofono_gprs_status_notify() /huawei0 status 2
9 ofonod[619]: src/gprs.c:netreg_status_changed() 1
10 ofonod[619]: src/cbs.c:cbs_location_changed() 1, 43015, 10955633, -1,
(null)(null)
11 ofonod[619]: src/gprs.c:ofono_gprs_status_notify() /huawei0 status 0
12 ofonod[619]: PCUI: > AT+CSCB=0,"0,25,38,50,100,136,256,4352-4356"\r
13 ofonod[619]: PCUI: < \r\nOK\r\n
14 ofonod[619]: PCUI: > AT+CRSM=192,28437,0,0,255\r
15 ofonod[619]: PCUI: < \r\n+CREG: 1, A807, A72B71\r\n\r\n+CGREG: 1, A807,
A72B71\r\n
16 ofonod[619]: src/gprs.c:netreg_status_changed() 1
17 ofonod[619]: src/cbs.c:cbs_location_changed() 1, 43015, 10955633, -1,
(null)(null)
18 ofonod[619]: src/gprs.c:ofono_gprs_status_notify() /huawei0 status 1
#driver_attached = TRUE
19 ofonod[619]: PCUI: < \r\n+CRSM: 106,130,""\r\n\r\nOK\r\n
20 ofonod[619]: PCUI: > AT+CGATT=0\r
21 ofonod[619]: PCUI: < \r\n+CREG: 1, A807, A72B71\r\n\r\n+CGREG:
0\r\n\r\nOK\r\n
22 ofonod[619]: src/gprs.c:netreg_status_changed() 1
23 ofonod[619]: src/cbs.c:cbs_location_changed() 1, 43015, 10955633, -1,
(null)(null)
24 ofonod[619]: src/gprs.c:ofono_gprs_status_notify() /huawei0 status 0
25 ofonod[619]: src/gprs.c:gprs_attach_callback() /huawei0 error = 0
At line 3 gprs_netreg_update() is called, driver_attached is set to FALSE. Due
to there
are some AT command in the queue, AT+CGATT=0 is not sent out immediately(till
at line 20).
At line 18, driver_attached is set to TRUE. In fact after line 21, GPRS is
detached.
In src/gprs.c there is only one place to attach GPRS, it is in
gprs_netreg_update().
due to driver_attached is TRUE, gprs_netreg_update() will always return before
gprs->driver->set_attached() invoked.
For this issue I have submit two patches, please see attached.
(2) After receive "NW DETACH"/"ME DETACH" unsolicited message, GPRS is not
re-attached. It will
cause can not connect GPRS connection any more.
(3) In AT modem GPRS driver, the attach status query function(.attached_status)
is implememted
as query the GPRS registration status. Is it by mistake or intended? It is very
confusable.
Thanks!
Caiwen
--- Begin Message ---
From: Caiwen Zhang <[email protected]>
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.
Scenario:
When device is unregistered(+CREG: 2), GPRS is detached. During GPRS
detaching, device
registered to network again(+CREG: 1, xxx, xxx).
Log:
ofonod[619]: PCUI: < \r\n^SRVST:1\r\n\r\n+CREG: 2\r\n\r\n+CGREG:
2\r\n\r\n^SRVST:2\r\n\r\n+CREG: 1, A807, A72B71\r\n\r\n+CGREG: 0\r\n
ofonod[619]: src/network.c:current_operator_callback() 0xa046ea0, 0xa0476e8
ofonod[619]: src/gprs.c:netreg_status_changed() 2 //driver_attched = FALSE
ofonod[619]: src/cbs.c:cbs_location_changed() 2, -1, -1, -1, (null)(null)
ofonod[619]: src/cbs.c:cbs_location_changed() 1, 0, 0
ofonod[619]: src/gprs.c:netreg_status_changed() 2
ofonod[619]: src/cbs.c:cbs_location_changed() 2, -1, -1, -1, (null)(null)
ofonod[619]: src/gprs.c:ofono_gprs_status_notify() /huawei0 status 2
ofonod[619]: src/gprs.c:netreg_status_changed() 1
ofonod[619]: src/cbs.c:cbs_location_changed() 1, 43015, 10955633, -1,
(null)(null)
ofonod[619]: src/gprs.c:ofono_gprs_status_notify() /huawei0 status 0
ofonod[619]: PCUI: > AT+CSCB=0,"0,25,38,50,100,136,256,4352-4356"\r
ofonod[619]: PCUI: < \r\nOK\r\n
ofonod[619]: PCUI: > AT+CRSM=192,28437,0,0,255\r
ofonod[619]: PCUI: < \r\n+CREG: 1, A807, A72B71\r\n\r\n+CGREG: 1, A807,
A72B71\r\n
ofonod[619]: src/gprs.c:netreg_status_changed() 1
ofonod[619]: src/cbs.c:cbs_location_changed() 1, 43015, 10955633, -1,
(null)(null)
ofonod[619]: src/gprs.c:ofono_gprs_status_notify() /huawei0 status 1
//driver_attched = TRUE
ofonod[619]: PCUI: < \r\n+CRSM: 106,130,""\r\n\r\nOK\r\n
ofonod[619]: PCUI: > AT+CGATT=0\r
---
src/gprs.c | 19 +++++++------------
1 files changed, 7 insertions(+), 12 deletions(-)
diff --git a/src/gprs.c b/src/gprs.c
index deffeb8..d80e7ab 100644
--- a/src/gprs.c
+++ b/src/gprs.c
@@ -1429,17 +1429,12 @@ void ofono_gprs_resume_notify(struct ofono_gprs *gprs)
update_suspended_property(gprs, FALSE);
}
-static void gprs_attached_update(struct ofono_gprs *gprs)
+static void gprs_attached_update(struct ofono_gprs *gprs, ofono_bool_t
attached)
{
DBusConnection *conn = ofono_dbus_get_connection();
const char *path;
- ofono_bool_t attached;
dbus_bool_t value;
- attached = gprs->driver_attached &&
- (gprs->status == NETWORK_REGISTRATION_STATUS_REGISTERED ||
- gprs->status == NETWORK_REGISTRATION_STATUS_ROAMING);
-
if (attached == gprs->attached)
return;
@@ -1508,7 +1503,7 @@ static void gprs_attach_callback(const struct ofono_error
*error, void *data)
return;
}
- gprs_attached_update(gprs);
+ gprs_attached_update(gprs, gprs->driver_attached);
if (gprs->flags & GPRS_FLAG_RECHECK) {
gprs->flags &= ~GPRS_FLAG_RECHECK;
@@ -1525,7 +1520,7 @@ static void gprs_netreg_removed(struct ofono_gprs *gprs)
gprs->netreg_status = NETWORK_REGISTRATION_STATUS_NOT_REGISTERED;
gprs->driver_attached = FALSE;
- gprs_attached_update(gprs);
+ gprs_attached_update(gprs, FALSE);
}
static void gprs_netreg_update(struct ofono_gprs *gprs)
@@ -2074,7 +2069,8 @@ void ofono_gprs_detached_notify(struct ofono_gprs *gprs)
DBG("%s", __ofono_atom_get_path(gprs->atom));
gprs->driver_attached = FALSE;
- gprs_attached_update(gprs);
+
+ gprs_attached_update(gprs, FALSE);
/*
* TODO: The network forced a detach, we should wait for some time
@@ -2091,7 +2087,7 @@ void ofono_gprs_status_notify(struct ofono_gprs *gprs,
int status)
if (status != NETWORK_REGISTRATION_STATUS_REGISTERED &&
status != NETWORK_REGISTRATION_STATUS_ROAMING) {
- gprs_attached_update(gprs);
+ gprs_attached_update(gprs, FALSE);
return;
}
@@ -2103,8 +2099,7 @@ 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);
+ gprs_attached_update(gprs, TRUE);
return;
--
1.7.0.4
--- End Message ---
--- Begin Message ---
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
--- End Message ---
_______________________________________________
ofono mailing list
[email protected]
http://lists.ofono.org/listinfo/ofono