Open Source Telephony
 help / color / mirror / Atom feed
From: Denis Kenzior <denkenz@gmail.com>
To: ofono@ofono.org
Subject: Re: [PATCH_v6 13/14] cdmamodem: add data strength to CDMA netreg atom.
Date: Fri, 05 Aug 2011 10:56:32 -0500	[thread overview]
Message-ID: <4E3C12B0.4090203@gmail.com> (raw)
In-Reply-To: <1312550475-8537-14-git-send-email-bertrand.aygon@intel.com>

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

Hi Bertrand,

On 08/05/2011 08:21 AM, Bertrand Aygon wrote:
> ---
>  src/cdma-netreg.c |   39 +++++++++++++++++++++++++++++++++++++++
>  1 files changed, 39 insertions(+), 0 deletions(-)
> 
> diff --git a/src/cdma-netreg.c b/src/cdma-netreg.c
> index 12ddd23..e57856e 100644
> --- a/src/cdma-netreg.c
> +++ b/src/cdma-netreg.c
> @@ -34,6 +34,7 @@ static GSList *g_drivers;
>  struct ofono_cdma_netreg {
>  	enum cdma_netreg_status status;
>  	int strength;
> +	int data_strength;
>  	const struct ofono_cdma_netreg_driver *driver;
>  	void *driver_data;
>  	struct ofono_atom *atom;
> @@ -82,6 +83,13 @@ static DBusMessage *network_get_properties(DBusConnection *conn,
>  					&strength);
>  	}
>  
> +	if (cdma_netreg->data_strength != -1) {
> +		unsigned char data_strength = cdma_netreg->data_strength;
> +
> +		ofono_dbus_dict_append(&dict, "DataStrength", DBUS_TYPE_BYTE,
> +					&data_strength);
> +	}
> +
>  	dbus_message_iter_close_container(&iter, &dict);
>  
>  	return reply;
> @@ -151,6 +159,36 @@ void ofono_cdma_netreg_strength_notify(struct ofono_cdma_netreg *netreg,
>  	}
>  }
>  
> +void ofono_cdma_netreg_data_strength_notify(struct ofono_cdma_netreg *netreg,
> +					int data_strength)
> +{
> +	if (netreg == NULL)
> +		return;
> +
> +	if (netreg->data_strength == data_strength)
> +		return;
> +
> +	/*
> +	 * Theoretically we can get signal strength even when not registered
> +	 * to any network.  However, what do we do with it in that case?
> +	 */
> +	if (netreg->status == CDMA_NETWORK_REGISTRATION_STATUS_NOT_REGISTERED)
> +		return;
> +
> +	netreg->data_strength = data_strength;
> +
> +	if (data_strength != -1) {
> +		DBusConnection *conn = ofono_dbus_get_connection();
> +		const char *path = __ofono_atom_get_path(netreg->atom);
> +		unsigned char data_strength = netreg->data_strength;
> +
> +		ofono_dbus_signal_property_changed(conn, path,
> +				OFONO_CDMA_NETWORK_REGISTRATION_INTERFACE,
> +				"DataStrength", DBUS_TYPE_BYTE,
> +				&data_strength);
> +	}
> +}
> +

I don't like this, this function is nearly a 100% copy of the
strength_notify function, down to the comment in fact.  Are you sure you
can't refactor the common code into a helper?

>  int ofono_cdma_netreg_driver_register(const struct ofono_cdma_netreg_driver *d)
>  {
>  	DBG("driver: %p, name: %s", d, d->name);
> @@ -216,6 +254,7 @@ struct ofono_cdma_netreg *ofono_cdma_netreg_create(struct ofono_modem *modem,
>  
>  	cdma_netreg->status = CDMA_NETWORK_REGISTRATION_STATUS_NOT_REGISTERED;
>  	cdma_netreg->strength = -1;
> +	cdma_netreg->data_strength = -1;
>  
>  	cdma_netreg->atom = __ofono_modem_add_atom(modem,
>  					OFONO_ATOM_TYPE_CDMA_NETREG,

Regards,
-Denis

  reply	other threads:[~2011-08-05 15:56 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-05 13:21 [PATCH_v6 00/14] Create CDMA netreg atom Bertrand Aygon
2011-08-05 13:21 ` [PATCH_v6 01/14] cdmamodem: define " Bertrand Aygon
2011-08-05 15:50   ` Denis Kenzior
2011-08-05 13:21 ` [PATCH_v6 02/14] cdmamodem: create include file for CDMA netreg Bertrand Aygon
2011-08-05 15:51   ` Denis Kenzior
2011-08-05 13:21 ` [PATCH_v6 03/14] cdmamodem: create the interface " Bertrand Aygon
2011-08-05 15:51   ` Denis Kenzior
2011-08-05 13:21 ` [PATCH_v6 04/14] cdmamodem: define cdma network status Bertrand Aygon
2011-08-05 15:52   ` Denis Kenzior
2011-08-05 13:21 ` [PATCH_v6 05/14] cdmamodem: implement " Bertrand Aygon
2011-08-05 15:52   ` Denis Kenzior
2011-08-05 13:21 ` [PATCH_v6 06/14] huaweicdmamodem: create a huawei cdma driver Bertrand Aygon
2011-08-05 15:54   ` Denis Kenzior
2011-08-05 13:21 ` [PATCH_v6 07/14] huaweicdma: create a dedicated netreg atom Bertrand Aygon
2011-08-05 16:04   ` Denis Kenzior
2011-08-05 13:21 ` [PATCH_v6 08/14] huaweicdma: register to CDMA " Bertrand Aygon
2011-08-05 13:21 ` [PATCH_v6 09/14] cdmamodem: add strength " Bertrand Aygon
2011-08-05 15:54   ` Denis Kenzior
2011-08-05 13:21 ` [PATCH_v6 10/14] " Bertrand Aygon
2011-08-05 15:54   ` Denis Kenzior
2011-08-05 13:21 ` [PATCH_v6 11/14] huaweicdma: register to ^RSSILVL to update signal strength Bertrand Aygon
2011-08-05 13:21 ` [PATCH_v6 12/14] cdmamodem: add data strength to CDMA netreg atom Bertrand Aygon
2011-08-05 15:55   ` Denis Kenzior
2011-08-05 13:21 ` [PATCH_v6 13/14] " Bertrand Aygon
2011-08-05 15:56   ` Denis Kenzior [this message]
2011-08-05 13:21 ` [PATCH_v6 14/14] test: update list-modem to display CDMA DataStrength info Bertrand Aygon
2011-08-05 15:56   ` 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=4E3C12B0.4090203@gmail.com \
    --to=denkenz@gmail.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