Hi Caiwen,

On 05/09/2011 03:22 AM, [email protected] wrote:
> 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);
> -

You are changing semantics of attached here.  Attached property is set
to TRUE only when a CGATT=1 has been issued _and_ CGREG goes to
registered or 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;
>  

Regards,
-Denis
_______________________________________________
ofono mailing list
[email protected]
http://lists.ofono.org/listinfo/ofono

Reply via email to