Open Source Telephony
 help / color / mirror / Atom feed
From: Guillaume Zajac <guillaume.zajac@linux.intel.com>
To: ofono@ofono.org
Subject: Re: [PATCH 2/2] cdma-connman: Add cdma-netreg status watch to activate data call
Date: Mon, 31 Oct 2011 16:27:27 +0100	[thread overview]
Message-ID: <4EAEBE5F.7080208@linux.intel.com> (raw)
In-Reply-To: <4EACF9CC.9010101@gmail.com>

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

Hi Denis,

On 30/10/2011 08:16, Denis Kenzior wrote:
> Hi Guillaume,
>
> On 10/20/2011 10:41 AM, Guillaume Zajac wrote:
>> ---
>>   src/cdma-connman.c |   74 ++++++++++++++++++++++++++++++++++++++++++++++++++-
>>   1 files changed, 72 insertions(+), 2 deletions(-)
>>
>> diff --git a/src/cdma-connman.c b/src/cdma-connman.c
>> index db8f6c5..edd71b5 100644
>> --- a/src/cdma-connman.c
>> +++ b/src/cdma-connman.c
>> @@ -52,6 +52,11 @@ struct cdma_connman_settings {
>>   struct ofono_cdma_connman {
>>   	ofono_bool_t powered;
>>   	ofono_bool_t dormant;
>> +	ofono_bool_t attached;
>> +	int cdma_netreg_status;
>> +	struct ofono_cdma_netreg *cdma_netreg;
>> +	unsigned int cdma_netreg_watch;
>> +	unsigned int cdma_status_watch;
>>   	struct cdma_connman_settings *settings;
>>   	DBusMessage *pending;
>>   	const struct ofono_cdma_connman_driver *driver;
>> @@ -465,7 +470,9 @@ static DBusMessage *cdma_connman_set_property(DBusConnection *conn,
>>
>>   		cm->pending = dbus_message_ref(msg);
>>
>> -		/* TODO: add logic to support CDMA Network Registration */
>> +		if (value&&  !cm->attached)
>> +			return __ofono_error_not_attached(msg);
>> +
> There is no concept of attachment in CDMA, so I'd prefer we not do it
> this way.  Can't we simply check the current netreg atom status here?

Fine for me. Then we should also create a new D-Bus error message like:
__ofono_error_not_registered().

>>   		if (value)
>>   			cm->driver->activate(cm, cm->username, cm->password,
>>   						activate_callback, cm);
>> @@ -531,9 +538,23 @@ static void cdma_connman_unregister(struct ofono_atom *atom)
>>   	DBusConnection *conn = ofono_dbus_get_connection();
>>   	struct ofono_modem *modem = __ofono_atom_get_modem(atom);
>>   	const char *path = __ofono_atom_get_path(atom);
>> +	struct ofono_cdma_connman *cm = __ofono_atom_get_data(atom);
>>
>>   	DBG("");
>>
>> +	if (cm->cdma_netreg_watch) {
>> +		if (cm->cdma_status_watch) {
>> +			__ofono_cdma_netreg_remove_status_watch(
>> +							cm->cdma_netreg,
>> +							cm->cdma_status_watch);
>> +			cm->cdma_status_watch = 0;
>> +		}
>> +
>> +		__ofono_modem_remove_atom_watch(modem, cm->cdma_netreg_watch);
>> +		cm->cdma_netreg_watch = 0;
>> +		cm->cdma_netreg = NULL;
>> +	}
>> +
>>   	g_dbus_unregister_interface(conn, path,
>>   				OFONO_CDMA_CONNECTION_MANAGER_INTERFACE);
>>   	ofono_modem_remove_interface(modem,
>> @@ -593,6 +614,53 @@ struct ofono_cdma_connman *ofono_cdma_connman_create(
>>   	return cm;
>>   }
>>
>> +static void cdma_connman_netreg_update(struct ofono_cdma_connman *cm)
>> +{
>> +	ofono_bool_t attach;
>> +
>> +	attach = cm->cdma_netreg_status ==
>> +			NETWORK_REGISTRATION_STATUS_REGISTERED;
>> +
>> +	/* TODO: Manager roaming case */
>> +
>> +	cm->attached = attach;
>> +}
>> +
>> +static void cdma_netreg_status_changed(int status, void *data)
>> +{
>> +	struct ofono_cdma_connman *cm = data;
>> +
>> +	DBG("%d", status);
>> +
>> +	if (cm->cdma_netreg_status == status)
>> +		return;
>> +
>> +	cm->cdma_netreg_status = status;
>> +
>> +	cdma_connman_netreg_update(cm);
>> +}
>> +
>> +static void cdma_netreg_watch(struct ofono_atom *atom,
>> +				enum ofono_atom_watch_condition cond,
>> +				void *data)
>> +{
>> +	struct ofono_cdma_connman *cm = data;
>> +
>> +	if (cond == OFONO_ATOM_WATCH_CONDITION_UNREGISTERED) {
>> +		cm->cdma_netreg_status =
>> +				NETWORK_REGISTRATION_STATUS_NOT_REGISTERED;
>> +		return;
>> +	}
>> +
>> +	cm->cdma_netreg = __ofono_atom_get_data(atom);
>> +	cm->cdma_netreg_status = ofono_cdma_netreg_get_status(cm->cdma_netreg);
>> +	cm->cdma_status_watch =
>> +			__ofono_cdma_netreg_add_status_watch(cm->cdma_netreg,
>> +					cdma_netreg_status_changed, cm, NULL);
>> +
>> +	cdma_connman_netreg_update(cm);
>> +}
>> +
>>   void ofono_cdma_connman_register(struct ofono_cdma_connman *cm)
>>   {
>>   	DBusConnection *conn = ofono_dbus_get_connection();
>> @@ -613,7 +681,9 @@ void ofono_cdma_connman_register(struct ofono_cdma_connman *cm)
>>   	ofono_modem_add_interface(modem,
>>   				OFONO_CDMA_CONNECTION_MANAGER_INTERFACE);
>>
>> -	/* TODO: add watch to support CDMA Network Registration atom */
>> +	cm->cdma_netreg_watch = __ofono_modem_add_atom_watch(modem,
>> +					OFONO_ATOM_TYPE_CDMA_NETREG,
>> +					cdma_netreg_watch, cm, NULL);
>>
>>   	__ofono_atom_register(cm->atom, cdma_connman_unregister);
>>   }
> It seems to me that this is way too complicated.  All you want is to
> check the netreg status before trying to set powered.  If we lose netreg
> when the connection is active, then the regular cdma-connman
> notification procedures would apply.

Once we lost netreg, what are we supposed to do?
cdma-netreg atom will signal "Status" property has changed.
Is that up to ConnMan to deactivate the data call in checking the 
cdma-netreg "Status" property equal to "unregistered"?

Kind regards,
Guillaume

  reply	other threads:[~2011-10-31 15:27 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-20 15:41 [PATCH 0/2] CDMA network registration Guillaume Zajac
2011-10-20 15:41 ` [PATCH 1/2] cdma-netreg: Add various cdma-netreg watches Guillaume Zajac
2011-10-30  7:18   ` Denis Kenzior
2011-10-31 14:55     ` Guillaume Zajac
2011-10-20 15:41 ` [PATCH 2/2] cdma-connman: Add cdma-netreg status watch to activate data call Guillaume Zajac
2011-10-30  7:16   ` Denis Kenzior
2011-10-31 15:27     ` Guillaume Zajac [this message]
2011-10-30  8:27       ` Denis Kenzior

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4EAEBE5F.7080208@linux.intel.com \
    --to=guillaume.zajac@linux.intel.com \
    --cc=ofono@ofono.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox