All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH_v6 00/14] Create CDMA netreg atom
@ 2011-08-05 13:21 Bertrand Aygon
  2011-08-05 13:21 ` [PATCH_v6 01/14] cdmamodem: define " Bertrand Aygon
                   ` (13 more replies)
  0 siblings, 14 replies; 27+ messages in thread
From: Bertrand Aygon @ 2011-08-05 13:21 UTC (permalink / raw)
  To: ofono

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

Create an org.ofono.cdma.NetworkRegistration interface
Create first the skeleton
Then add status information.
Create a Huawei CDMA network.
Add a netreg atom for this driver.
Modify Huawei CDMA plugin to use this atom.
Add signal strength support.
And data signal strength support.

Bertrand Aygon (14):
  cdmamodem: define CDMA netreg atom.
  cdmamodem: create include file for CDMA netreg.
  cdmamodem: create the interface for CDMA netreg.
  cdmamodem: define cdma network status.
  cdmamodem: implement cdma network status.
  huaweicdmamodem: create a huawei cdma driver.
  huaweicdma: create a dedicated netreg atom.
  huaweicdma: register to CDMA netreg atom.
  cdmamodem: add strength to CDMA netreg atom
  cdmamodem: add strength to CDMA netreg atom.
  huaweicdma: register to ^RSSILVL to update signal strength.
  cdmamodem: add data strength to CDMA netreg atom.
  cdmamodem: add data strength to CDMA netreg atom.
  test: update list-modem to display CDMA DataStrength info.

 Makefile.am                                    |   10 +-
 drivers/huaweicdmamodem/huaweicdmamodem.c      |   45 ++++
 drivers/huaweicdmamodem/huaweicdmamodem.h      |   23 ++
 drivers/huaweicdmamodem/network-registration.c |  198 +++++++++++++++
 include/cdma-netreg.h                          |   76 ++++++
 plugins/huaweicdma.c                           |    3 +
 src/cdma-netreg.c                              |  315 ++++++++++++++++++++++++
 src/ofono.h                                    |    2 +
 test/list-modems                               |    3 +-
 9 files changed, 672 insertions(+), 3 deletions(-)
 create mode 100644 drivers/huaweicdmamodem/huaweicdmamodem.c
 create mode 100644 drivers/huaweicdmamodem/huaweicdmamodem.h
 create mode 100644 drivers/huaweicdmamodem/network-registration.c
 create mode 100644 include/cdma-netreg.h
 create mode 100644 src/cdma-netreg.c

-- 
1.7.4.1

---------------------------------------------------------------------
Intel Corporation SAS (French simplified joint stock company)
Registered headquarters: "Les Montalets"- 2, rue de Paris, 
92196 Meudon Cedex, France
Registration Number:  302 456 199 R.C.S. NANTERRE
Capital: 4,572,000 Euros

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.

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

* [PATCH_v6 01/14] cdmamodem: define CDMA netreg atom.
  2011-08-05 13:21 [PATCH_v6 00/14] Create CDMA netreg atom Bertrand Aygon
@ 2011-08-05 13:21 ` 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
                   ` (12 subsequent siblings)
  13 siblings, 1 reply; 27+ messages in thread
From: Bertrand Aygon @ 2011-08-05 13:21 UTC (permalink / raw)
  To: ofono

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

---
 src/ofono.h |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/src/ofono.h b/src/ofono.h
index 808a8f1..ef5e77d 100644
--- a/src/ofono.h
+++ b/src/ofono.h
@@ -135,6 +135,7 @@ enum ofono_atom_type {
 	OFONO_ATOM_TYPE_LOCATION_REPORTING,
 	OFONO_ATOM_TYPE_GNSS,
 	OFONO_ATOM_TYPE_CDMA_SMS,
+	OFONO_ATOM_TYPE_CDMA_NETREG,
 };
 
 enum ofono_atom_watch_condition {
-- 
1.7.4.1

---------------------------------------------------------------------
Intel Corporation SAS (French simplified joint stock company)
Registered headquarters: "Les Montalets"- 2, rue de Paris, 
92196 Meudon Cedex, France
Registration Number:  302 456 199 R.C.S. NANTERRE
Capital: 4,572,000 Euros

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.

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

* [PATCH_v6 02/14] cdmamodem: create include file for CDMA netreg.
  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 13:21 ` Bertrand Aygon
  2011-08-05 15:51   ` Denis Kenzior
  2011-08-05 13:21 ` [PATCH_v6 03/14] cdmamodem: create the interface " Bertrand Aygon
                   ` (11 subsequent siblings)
  13 siblings, 1 reply; 27+ messages in thread
From: Bertrand Aygon @ 2011-08-05 13:21 UTC (permalink / raw)
  To: ofono

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

---
 Makefile.am           |    2 +-
 include/cdma-netreg.h |   63 +++++++++++++++++++++++++++++++++++++++++++++++++
 src/ofono.h           |    1 +
 3 files changed, 65 insertions(+), 1 deletions(-)
 create mode 100644 include/cdma-netreg.h

diff --git a/Makefile.am b/Makefile.am
index 9c56711..95188a9 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -17,7 +17,7 @@ pkginclude_HEADERS = include/log.h include/plugin.h include/history.h \
 			include/gprs-provision.h include/emulator.h \
 			include/location-reporting.h \
 			include/cdma-connman.h include/gnss.h \
-			include/private-network.h
+			include/private-network.h include/cdma-netreg.h
 
 nodist_pkginclude_HEADERS = include/version.h
 
diff --git a/include/cdma-netreg.h b/include/cdma-netreg.h
new file mode 100644
index 0000000..8ee7737
--- /dev/null
+++ b/include/cdma-netreg.h
@@ -0,0 +1,63 @@
+/*
+ *
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2008-2011  Intel Corporation. All rights reserved.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#ifndef __OFONO_CDMA_NETREG_H
+#define __OFONO_CDMA_NETREG_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <ofono/types.h>
+
+struct ofono_cdma_netreg;
+
+struct ofono_cdma_netreg_driver {
+	const char *name;
+	int (*probe)(struct ofono_cdma_netreg *cdma_netreg,
+				unsigned int vendor,
+				void *data);
+	void (*remove)(struct ofono_cdma_netreg *cdma_netreg);
+};
+
+int ofono_cdma_netreg_driver_register(
+				const struct ofono_cdma_netreg_driver *d);
+void ofono_cdma_netreg_driver_unregister(
+				const struct ofono_cdma_netreg_driver *d);
+
+struct ofono_cdma_netreg *ofono_cdma_netreg_create(
+				struct ofono_modem *modem,
+				unsigned int vendor,
+				const char *driver,
+				void *data);
+
+void ofono_cdma_netreg_register(struct ofono_cdma_netreg *cdma_netreg);
+void ofono_cdma_netreg_remove(struct ofono_cdma_netreg *cdma_netreg);
+
+void ofono_cdma_netreg_set_data(struct ofono_cdma_netreg *cdma_netreg,
+				void *data);
+void *ofono_cdma_netreg_get_data(struct ofono_cdma_netreg *cdma_netreg);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __OFONO_CDMA_NETREG_H */
diff --git a/src/ofono.h b/src/ofono.h
index ef5e77d..5e3a6b5 100644
--- a/src/ofono.h
+++ b/src/ofono.h
@@ -481,6 +481,7 @@ void __ofono_gprs_provision_free_settings(
 #include <ofono/emulator.h>
 #include <ofono/gnss.h>
 #include <ofono/cdma-sms.h>
+#include <ofono/cdma-netreg.h>
 #include <ofono/private-network.h>
 
 void __ofono_private_network_release(int id);
-- 
1.7.4.1

---------------------------------------------------------------------
Intel Corporation SAS (French simplified joint stock company)
Registered headquarters: "Les Montalets"- 2, rue de Paris, 
92196 Meudon Cedex, France
Registration Number:  302 456 199 R.C.S. NANTERRE
Capital: 4,572,000 Euros

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.

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

* [PATCH_v6 03/14] cdmamodem: create the interface for CDMA netreg.
  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 13:21 ` [PATCH_v6 02/14] cdmamodem: create include file for CDMA netreg Bertrand Aygon
@ 2011-08-05 13:21 ` 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
                   ` (10 subsequent siblings)
  13 siblings, 1 reply; 27+ messages in thread
From: Bertrand Aygon @ 2011-08-05 13:21 UTC (permalink / raw)
  To: ofono

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

---
 Makefile.am       |    2 +-
 src/cdma-netreg.c |  190 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 191 insertions(+), 1 deletions(-)
 create mode 100644 src/cdma-netreg.c

diff --git a/Makefile.am b/Makefile.am
index 95188a9..238771c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -417,7 +417,7 @@ src_ofonod_SOURCES = $(gdbus_sources) $(builtin_sources) src/ofono.ver \
 			src/cdma-connman.c src/gnss.c \
 			src/gnssagent.c src/gnssagent.h \
 			src/cdma-smsutil.h src/cdma-smsutil.c \
-			src/cdma-sms.c src/private-network.c
+			src/cdma-sms.c src/private-network.c src/cdma-netreg.c
 
 src_ofonod_LDADD = $(builtin_libadd) @GLIB_LIBS@ @DBUS_LIBS@ @CAPNG_LIBS@ -ldl
 
diff --git a/src/cdma-netreg.c b/src/cdma-netreg.c
new file mode 100644
index 0000000..927af52
--- /dev/null
+++ b/src/cdma-netreg.c
@@ -0,0 +1,190 @@
+/*
+ *
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2008-2011  Intel Corporation. All rights reserved.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <errno.h>
+
+#include <gdbus.h>
+
+#include "ofono.h"
+
+static GSList *g_drivers;
+
+struct ofono_cdma_netreg {
+	const struct ofono_cdma_netreg_driver *driver;
+	void *driver_data;
+	struct ofono_atom *atom;
+};
+
+static DBusMessage *network_get_properties(DBusConnection *conn,
+						DBusMessage *msg, void *data)
+{
+	DBusMessage *reply;
+	DBusMessageIter iter;
+	DBusMessageIter dict;
+
+	reply = dbus_message_new_method_return(msg);
+	if (reply == NULL)
+		return NULL;
+
+	dbus_message_iter_init_append(reply, &iter);
+
+	dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
+					OFONO_PROPERTIES_ARRAY_SIGNATURE,
+					&dict);
+
+	dbus_message_iter_close_container(&iter, &dict);
+
+	return reply;
+}
+
+static GDBusMethodTable cdma_netreg_manager_methods[] = {
+	{ "GetProperties",  "",  "a{sv}",	network_get_properties },
+	{ }
+};
+
+static GDBusSignalTable cdma_netreg_manager_signals[] = {
+	{ }
+};
+
+int ofono_cdma_netreg_driver_register(const struct ofono_cdma_netreg_driver *d)
+{
+	DBG("driver: %p, name: %s", d, d->name);
+
+	if (d->probe == NULL)
+		return -EINVAL;
+
+	g_drivers = g_slist_prepend(g_drivers, (void *)d);
+
+	return 0;
+}
+
+void ofono_cdma_netreg_driver_unregister(
+				const struct ofono_cdma_netreg_driver *d)
+{
+	DBG("driver: %p, name: %s", d, d->name);
+
+	g_drivers = g_slist_remove(g_drivers, (void *)d);
+}
+
+static void cdma_netreg_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);
+
+	g_dbus_unregister_interface(conn, path,
+				OFONO_CDMA_NETWORK_REGISTRATION_INTERFACE);
+
+	ofono_modem_remove_interface(modem,
+				OFONO_CDMA_NETWORK_REGISTRATION_INTERFACE);
+}
+
+static void cdma_netreg_remove(struct ofono_atom *atom)
+{
+	struct ofono_cdma_netreg *cdma_netreg = __ofono_atom_get_data(atom);
+
+	DBG("atom: %p", atom);
+
+	if (cdma_netreg == NULL)
+		return;
+
+	if (cdma_netreg->driver && cdma_netreg->driver->remove)
+		cdma_netreg->driver->remove(cdma_netreg);
+
+	g_free(cdma_netreg);
+}
+
+struct ofono_cdma_netreg *ofono_cdma_netreg_create(struct ofono_modem *modem,
+						unsigned int vendor,
+						const char *driver,
+						void *data)
+{
+	struct ofono_cdma_netreg *cdma_netreg;
+	GSList *l;
+
+	if (driver == NULL)
+		return NULL;
+
+	cdma_netreg = g_try_new0(struct ofono_cdma_netreg, 1);
+	if (cdma_netreg == NULL)
+		return NULL;
+
+	cdma_netreg->atom = __ofono_modem_add_atom(modem,
+					OFONO_ATOM_TYPE_CDMA_NETREG,
+					cdma_netreg_remove, cdma_netreg);
+
+	for (l = g_drivers; l; l = l->next) {
+		const struct ofono_cdma_netreg_driver *drv = l->data;
+
+		if (g_strcmp0(drv->name, driver))
+			continue;
+
+		if (drv->probe(cdma_netreg, vendor, data) < 0)
+			continue;
+
+		cdma_netreg->driver = drv;
+		break;
+	}
+
+	return cdma_netreg;
+}
+
+void ofono_cdma_netreg_register(struct ofono_cdma_netreg *cdma_netreg)
+{
+	DBusConnection *conn = ofono_dbus_get_connection();
+	struct ofono_modem *modem = __ofono_atom_get_modem(cdma_netreg->atom);
+	const char *path = __ofono_atom_get_path(cdma_netreg->atom);
+
+	if (!g_dbus_register_interface(conn, path,
+				OFONO_CDMA_NETWORK_REGISTRATION_INTERFACE,
+				cdma_netreg_manager_methods,
+				cdma_netreg_manager_signals,
+				NULL, cdma_netreg, NULL)) {
+		ofono_error("Could not create %s interface",
+				OFONO_CDMA_NETWORK_REGISTRATION_INTERFACE);
+		return;
+	}
+
+	ofono_modem_add_interface(modem,
+				OFONO_CDMA_NETWORK_REGISTRATION_INTERFACE);
+
+	__ofono_atom_register(cdma_netreg->atom, cdma_netreg_unregister);
+}
+
+void ofono_cdma_netreg_remove(struct ofono_cdma_netreg *cdma_netreg)
+{
+	__ofono_atom_free(cdma_netreg->atom);
+}
+
+void ofono_cdma_netreg_set_data(struct ofono_cdma_netreg *cdma_netreg,
+					void *data)
+{
+	cdma_netreg->driver_data = data;
+}
+
+void *ofono_cdma_netreg_get_data(struct ofono_cdma_netreg *cdma_netreg)
+{
+	return cdma_netreg->driver_data;
+}
-- 
1.7.4.1

---------------------------------------------------------------------
Intel Corporation SAS (French simplified joint stock company)
Registered headquarters: "Les Montalets"- 2, rue de Paris, 
92196 Meudon Cedex, France
Registration Number:  302 456 199 R.C.S. NANTERRE
Capital: 4,572,000 Euros

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.

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

* [PATCH_v6 04/14] cdmamodem: define cdma network status.
  2011-08-05 13:21 [PATCH_v6 00/14] Create CDMA netreg atom Bertrand Aygon
                   ` (2 preceding siblings ...)
  2011-08-05 13:21 ` [PATCH_v6 03/14] cdmamodem: create the interface " Bertrand Aygon
@ 2011-08-05 13:21 ` Bertrand Aygon
  2011-08-05 15:52   ` Denis Kenzior
  2011-08-05 13:21 ` [PATCH_v6 05/14] cdmamodem: implement " Bertrand Aygon
                   ` (9 subsequent siblings)
  13 siblings, 1 reply; 27+ messages in thread
From: Bertrand Aygon @ 2011-08-05 13:21 UTC (permalink / raw)
  To: ofono

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

---
 include/cdma-netreg.h |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/include/cdma-netreg.h b/include/cdma-netreg.h
index 8ee7737..126a5a5 100644
--- a/include/cdma-netreg.h
+++ b/include/cdma-netreg.h
@@ -28,6 +28,12 @@ extern "C" {
 
 #include <ofono/types.h>
 
+enum cdma_netreg_status {
+	CDMA_NETWORK_REGISTRATION_STATUS_NOT_REGISTERED =	0,
+	CDMA_NETWORK_REGISTRATION_STATUS_REGISTERED =		1,
+	CDMA_NETWORK_REGISTRATION_STATUS_ROAMING =		2,
+};
+
 struct ofono_cdma_netreg;
 
 struct ofono_cdma_netreg_driver {
@@ -38,6 +44,9 @@ struct ofono_cdma_netreg_driver {
 	void (*remove)(struct ofono_cdma_netreg *cdma_netreg);
 };
 
+void ofono_cdma_netreg_status_notify(struct ofono_cdma_netreg *netreg,
+				enum cdma_netreg_status status);
+
 int ofono_cdma_netreg_driver_register(
 				const struct ofono_cdma_netreg_driver *d);
 void ofono_cdma_netreg_driver_unregister(
-- 
1.7.4.1

---------------------------------------------------------------------
Intel Corporation SAS (French simplified joint stock company)
Registered headquarters: "Les Montalets"- 2, rue de Paris, 
92196 Meudon Cedex, France
Registration Number:  302 456 199 R.C.S. NANTERRE
Capital: 4,572,000 Euros

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.

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

* [PATCH_v6 05/14] cdmamodem: implement cdma network status.
  2011-08-05 13:21 [PATCH_v6 00/14] Create CDMA netreg atom Bertrand Aygon
                   ` (3 preceding siblings ...)
  2011-08-05 13:21 ` [PATCH_v6 04/14] cdmamodem: define cdma network status Bertrand Aygon
@ 2011-08-05 13:21 ` 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
                   ` (8 subsequent siblings)
  13 siblings, 1 reply; 27+ messages in thread
From: Bertrand Aygon @ 2011-08-05 13:21 UTC (permalink / raw)
  To: ofono

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

---
 src/cdma-netreg.c |   47 +++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 47 insertions(+), 0 deletions(-)

diff --git a/src/cdma-netreg.c b/src/cdma-netreg.c
index 927af52..ec6b315 100644
--- a/src/cdma-netreg.c
+++ b/src/cdma-netreg.c
@@ -32,18 +32,36 @@
 static GSList *g_drivers;
 
 struct ofono_cdma_netreg {
+	enum cdma_netreg_status status;
 	const struct ofono_cdma_netreg_driver *driver;
 	void *driver_data;
 	struct ofono_atom *atom;
 };
 
+static const char *cdma_netreg_status_to_string(enum cdma_netreg_status status)
+{
+	switch (status) {
+	case CDMA_NETWORK_REGISTRATION_STATUS_NOT_REGISTERED:
+		return "unregistered";
+	case CDMA_NETWORK_REGISTRATION_STATUS_REGISTERED:
+		return "registered";
+	case CDMA_NETWORK_REGISTRATION_STATUS_ROAMING:
+		return "roaming";
+	}
+
+	return "";
+}
+
 static DBusMessage *network_get_properties(DBusConnection *conn,
 						DBusMessage *msg, void *data)
 {
+	struct ofono_cdma_netreg *cdma_netreg = data;
 	DBusMessage *reply;
 	DBusMessageIter iter;
 	DBusMessageIter dict;
 
+	const char *status = cdma_netreg_status_to_string(cdma_netreg->status);
+
 	reply = dbus_message_new_method_return(msg);
 	if (reply == NULL)
 		return NULL;
@@ -54,6 +72,8 @@ static DBusMessage *network_get_properties(DBusConnection *conn,
 					OFONO_PROPERTIES_ARRAY_SIGNATURE,
 					&dict);
 
+	ofono_dbus_dict_append(&dict, "Status", DBUS_TYPE_STRING, &status);
+
 	dbus_message_iter_close_container(&iter, &dict);
 
 	return reply;
@@ -68,6 +88,31 @@ static GDBusSignalTable cdma_netreg_manager_signals[] = {
 	{ }
 };
 
+static void set_registration_status(struct ofono_cdma_netreg *cdma_netreg,
+						enum cdma_netreg_status status)
+{
+	const char *str_status = cdma_netreg_status_to_string(status);
+	const char *path = __ofono_atom_get_path(cdma_netreg->atom);
+	DBusConnection *conn = ofono_dbus_get_connection();
+
+	cdma_netreg->status = status;
+
+	ofono_dbus_signal_property_changed(conn, path,
+				OFONO_CDMA_NETWORK_REGISTRATION_INTERFACE,
+				"Status", DBUS_TYPE_STRING,
+				&str_status);
+}
+
+void ofono_cdma_netreg_status_notify(struct ofono_cdma_netreg *cdma_netreg,
+					enum cdma_netreg_status status)
+{
+	if (cdma_netreg == NULL)
+		return;
+
+	if (cdma_netreg->status != status)
+		set_registration_status(cdma_netreg, status);
+}
+
 int ofono_cdma_netreg_driver_register(const struct ofono_cdma_netreg_driver *d)
 {
 	DBG("driver: %p, name: %s", d, d->name);
@@ -131,6 +176,8 @@ struct ofono_cdma_netreg *ofono_cdma_netreg_create(struct ofono_modem *modem,
 	if (cdma_netreg == NULL)
 		return NULL;
 
+	cdma_netreg->status = CDMA_NETWORK_REGISTRATION_STATUS_NOT_REGISTERED;
+
 	cdma_netreg->atom = __ofono_modem_add_atom(modem,
 					OFONO_ATOM_TYPE_CDMA_NETREG,
 					cdma_netreg_remove, cdma_netreg);
-- 
1.7.4.1

---------------------------------------------------------------------
Intel Corporation SAS (French simplified joint stock company)
Registered headquarters: "Les Montalets"- 2, rue de Paris, 
92196 Meudon Cedex, France
Registration Number:  302 456 199 R.C.S. NANTERRE
Capital: 4,572,000 Euros

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.

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

* [PATCH_v6 06/14] huaweicdmamodem: create a huawei cdma driver.
  2011-08-05 13:21 [PATCH_v6 00/14] Create CDMA netreg atom Bertrand Aygon
                   ` (4 preceding siblings ...)
  2011-08-05 13:21 ` [PATCH_v6 05/14] cdmamodem: implement " Bertrand Aygon
@ 2011-08-05 13:21 ` 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
                   ` (7 subsequent siblings)
  13 siblings, 1 reply; 27+ messages in thread
From: Bertrand Aygon @ 2011-08-05 13:21 UTC (permalink / raw)
  To: ofono

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

---
 Makefile.am                               |    5 +++
 drivers/huaweicdmamodem/huaweicdmamodem.c |   42 +++++++++++++++++++++++++++++
 drivers/huaweicdmamodem/huaweicdmamodem.h |   21 ++++++++++++++
 3 files changed, 68 insertions(+), 0 deletions(-)
 create mode 100644 drivers/huaweicdmamodem/huaweicdmamodem.c
 create mode 100644 drivers/huaweicdmamodem/huaweicdmamodem.h

diff --git a/Makefile.am b/Makefile.am
index 238771c..1c424ca 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -277,6 +277,11 @@ builtin_sources += drivers/cdmamodem/cdmamodem.h \
 			drivers/cdmamodem/voicecall.c \
 			drivers/cdmamodem/devinfo.c \
 			drivers/cdmamodem/connman.c
+
+builtin_modules += huaweicdmamodem
+builtin_sources += drivers/huaweicdmamodem/huaweicdmamodem.h \
+			drivers/huaweicdmamodem/huaweicdmamodem.c
+
 endif
 
 builtin_modules += g1
diff --git a/drivers/huaweicdmamodem/huaweicdmamodem.c b/drivers/huaweicdmamodem/huaweicdmamodem.c
new file mode 100644
index 0000000..d9e7943
--- /dev/null
+++ b/drivers/huaweicdmamodem/huaweicdmamodem.c
@@ -0,0 +1,42 @@
+/*
+ *
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2008-2011  Intel Corporation. All rights reserved.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#define OFONO_API_SUBJECT_TO_CHANGE
+#include <ofono/plugin.h>
+
+#include "huaweicdmamodem.h"
+
+static int huaweicdmamodem_init(void)
+{
+	return 0;
+}
+
+static void huaweicdmamodem_exit(void)
+{
+}
+
+OFONO_PLUGIN_DEFINE(huaweicdmamodem, "Huawei CDMA modem driver", VERSION,
+			OFONO_PLUGIN_PRIORITY_DEFAULT,
+			huaweicdmamodem_init, huaweicdmamodem_exit)
diff --git a/drivers/huaweicdmamodem/huaweicdmamodem.h b/drivers/huaweicdmamodem/huaweicdmamodem.h
new file mode 100644
index 0000000..018747f
--- /dev/null
+++ b/drivers/huaweicdmamodem/huaweicdmamodem.h
@@ -0,0 +1,21 @@
+/*
+ *
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2008-2011  Intel Corporation. All rights reserved.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
-- 
1.7.4.1

---------------------------------------------------------------------
Intel Corporation SAS (French simplified joint stock company)
Registered headquarters: "Les Montalets"- 2, rue de Paris, 
92196 Meudon Cedex, France
Registration Number:  302 456 199 R.C.S. NANTERRE
Capital: 4,572,000 Euros

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.

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

* [PATCH_v6 07/14] huaweicdma: create a dedicated netreg atom.
  2011-08-05 13:21 [PATCH_v6 00/14] Create CDMA netreg atom Bertrand Aygon
                   ` (5 preceding siblings ...)
  2011-08-05 13:21 ` [PATCH_v6 06/14] huaweicdmamodem: create a huawei cdma driver Bertrand Aygon
@ 2011-08-05 13:21 ` Bertrand Aygon
  2011-08-05 16:04   ` Denis Kenzior
  2011-08-05 13:21 ` [PATCH_v6 08/14] huaweicdma: register to CDMA " Bertrand Aygon
                   ` (6 subsequent siblings)
  13 siblings, 1 reply; 27+ messages in thread
From: Bertrand Aygon @ 2011-08-05 13:21 UTC (permalink / raw)
  To: ofono

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

---
 Makefile.am                                    |    3 +-
 drivers/huaweicdmamodem/huaweicdmamodem.c      |    3 +
 drivers/huaweicdmamodem/huaweicdmamodem.h      |    2 +
 drivers/huaweicdmamodem/network-registration.c |  175 ++++++++++++++++++++++++
 4 files changed, 182 insertions(+), 1 deletions(-)
 create mode 100644 drivers/huaweicdmamodem/network-registration.c

diff --git a/Makefile.am b/Makefile.am
index 1c424ca..da4e238 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -280,7 +280,8 @@ builtin_sources += drivers/cdmamodem/cdmamodem.h \
 
 builtin_modules += huaweicdmamodem
 builtin_sources += drivers/huaweicdmamodem/huaweicdmamodem.h \
-			drivers/huaweicdmamodem/huaweicdmamodem.c
+			drivers/huaweicdmamodem/huaweicdmamodem.c \
+			drivers/huaweicdmamodem/network-registration.c
 
 endif
 
diff --git a/drivers/huaweicdmamodem/huaweicdmamodem.c b/drivers/huaweicdmamodem/huaweicdmamodem.c
index d9e7943..4e9c400 100644
--- a/drivers/huaweicdmamodem/huaweicdmamodem.c
+++ b/drivers/huaweicdmamodem/huaweicdmamodem.c
@@ -30,11 +30,14 @@
 
 static int huaweicdmamodem_init(void)
 {
+	huaweicdma_netreg_init();
+
 	return 0;
 }
 
 static void huaweicdmamodem_exit(void)
 {
+	huaweicdma_netreg_exit();
 }
 
 OFONO_PLUGIN_DEFINE(huaweicdmamodem, "Huawei CDMA modem driver", VERSION,
diff --git a/drivers/huaweicdmamodem/huaweicdmamodem.h b/drivers/huaweicdmamodem/huaweicdmamodem.h
index 018747f..799d3a8 100644
--- a/drivers/huaweicdmamodem/huaweicdmamodem.h
+++ b/drivers/huaweicdmamodem/huaweicdmamodem.h
@@ -19,3 +19,5 @@
  *
  */
 
+extern void huaweicdma_netreg_init(void);
+extern void huaweicdma_netreg_exit(void);
diff --git a/drivers/huaweicdmamodem/network-registration.c b/drivers/huaweicdmamodem/network-registration.c
new file mode 100644
index 0000000..db91882
--- /dev/null
+++ b/drivers/huaweicdmamodem/network-registration.c
@@ -0,0 +1,175 @@
+/*
+ *
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2008-2011  Intel Corporation. All rights reserved.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#define _GNU_SOURCE
+#include <glib.h>
+#include <errno.h>
+
+#include <ofono/log.h>
+#include <ofono/modem.h>
+#include <ofono/cdma-netreg.h>
+
+#include "gatchat.h"
+
+#include "huaweicdmamodem.h"
+
+static const char *sysinfo_prefix[] = { "^SYSINFO:", NULL };
+
+struct huaweicdma_netreg_data {
+	GAtChat *chat;
+};
+
+static void parse_sysinfo(GAtResult *result, gint *status)
+{
+	GAtResultIter iter;
+	gint srv_status;
+	gint srv_domain;
+	gint roaming_status;
+
+	g_at_result_iter_init(&iter, result);
+
+	if (!g_at_result_iter_next(&iter, "^SYSINFO:"))
+		return;
+
+	if (!g_at_result_iter_next_number(&iter, &srv_status))
+		return;
+
+	if (!g_at_result_iter_next_number(&iter, &srv_domain))
+		return;
+
+	if (!g_at_result_iter_next_number(&iter, &roaming_status))
+		return;
+
+	DBG("%d, %d, %d", srv_status, srv_domain, roaming_status);
+
+	switch (srv_status) {
+	case 1:	/* Restricted service */
+	case 2:	/* Service valid */
+	case 3:	/* Restricted region service */
+		if (roaming_status)
+			*status = CDMA_NETWORK_REGISTRATION_STATUS_ROAMING;
+		else
+			*status = CDMA_NETWORK_REGISTRATION_STATUS_REGISTERED;
+		break;
+	case 0:	/* No service */
+	case 4:	/* Not registered */
+	default:
+		*status = CDMA_NETWORK_REGISTRATION_STATUS_NOT_REGISTERED;
+		break;
+	}
+
+	switch (srv_domain) {
+	case 0: /* No service */
+	case 255: /* CDMA not supported */
+		*status = CDMA_NETWORK_REGISTRATION_STATUS_NOT_REGISTERED;
+		break;
+	case 1: /* Only CS */
+	case 2: /* Only PS */
+	case 3: /* CS + PS */
+	case 4: /* CS registered, PS in searching state */
+		break;
+	}
+}
+
+static void sysinfo_cb(gboolean ok, GAtResult *result, gpointer user_data)
+{
+	struct ofono_cdma_netreg *netreg = user_data;
+	int status;
+
+	if (!ok)
+		return;
+
+	parse_sysinfo(result, &status);
+
+	ofono_cdma_netreg_status_notify(netreg, status);
+}
+
+static void mode_notify(GAtResult *result, gpointer user_data)
+{
+	struct ofono_cdma_netreg *netreg = user_data;
+	struct huaweicdma_netreg_data *nd = ofono_cdma_netreg_get_data(netreg);
+
+	g_at_chat_send(nd->chat, "AT^SYSINFO", sysinfo_prefix,
+				sysinfo_cb, netreg, NULL);
+}
+
+static void probe_cb(gboolean ok, GAtResult *result, gpointer user_data)
+{
+	struct ofono_cdma_netreg *netreg = user_data;
+
+	if (!ok)
+		return;
+
+	ofono_cdma_netreg_register(netreg);
+}
+
+static int huaweicdma_netreg_probe(struct ofono_cdma_netreg *netreg,
+				unsigned int vendor, void *data)
+{
+	GAtChat *chat = data;
+	struct huaweicdma_netreg_data *nd;
+
+	nd = g_try_new0(struct huaweicdma_netreg_data, 1);
+	if (nd == NULL)
+		return -ENOMEM;
+
+	nd->chat = g_at_chat_clone(chat);
+
+	ofono_cdma_netreg_set_data(netreg, nd);
+
+	g_at_chat_register(nd->chat, "^MODE:",
+				mode_notify, FALSE, netreg, NULL);
+
+	g_at_chat_send(nd->chat, "AT^SYSINFO", sysinfo_prefix,
+				probe_cb, netreg, NULL);
+
+	return 0;
+}
+
+static void huaweicdma_netreg_remove(struct ofono_cdma_netreg *netreg)
+{
+	struct huaweicdma_netreg_data *nd = ofono_cdma_netreg_get_data(netreg);
+
+	ofono_cdma_netreg_set_data(netreg, NULL);
+
+	g_at_chat_unref(nd->chat);
+	g_free(nd);
+}
+
+static struct ofono_cdma_netreg_driver driver = {
+	.name	= "huaweicdmamodem",
+	.probe	= huaweicdma_netreg_probe,
+	.remove	= huaweicdma_netreg_remove,
+};
+
+void huaweicdma_netreg_init(void)
+{
+	ofono_cdma_netreg_driver_register(&driver);
+}
+
+void huaweicdma_netreg_exit(void)
+{
+	ofono_cdma_netreg_driver_unregister(&driver);
+}
-- 
1.7.4.1

---------------------------------------------------------------------
Intel Corporation SAS (French simplified joint stock company)
Registered headquarters: "Les Montalets"- 2, rue de Paris, 
92196 Meudon Cedex, France
Registration Number:  302 456 199 R.C.S. NANTERRE
Capital: 4,572,000 Euros

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.

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

* [PATCH_v6 08/14] huaweicdma: register to CDMA netreg atom.
  2011-08-05 13:21 [PATCH_v6 00/14] Create CDMA netreg atom Bertrand Aygon
                   ` (6 preceding siblings ...)
  2011-08-05 13:21 ` [PATCH_v6 07/14] huaweicdma: create a dedicated netreg atom Bertrand Aygon
@ 2011-08-05 13:21 ` Bertrand Aygon
  2011-08-05 13:21 ` [PATCH_v6 09/14] cdmamodem: add strength " Bertrand Aygon
                   ` (5 subsequent siblings)
  13 siblings, 0 replies; 27+ messages in thread
From: Bertrand Aygon @ 2011-08-05 13:21 UTC (permalink / raw)
  To: ofono

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

---
 plugins/huaweicdma.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/plugins/huaweicdma.c b/plugins/huaweicdma.c
index 75aacb2..4c83114 100644
--- a/plugins/huaweicdma.c
+++ b/plugins/huaweicdma.c
@@ -34,6 +34,7 @@
 #include <ofono/plugin.h>
 #include <ofono/modem.h>
 #include <ofono/devinfo.h>
+#include <ofono/cdma-netreg.h>
 #include <ofono/cdma-connman.h>
 #include <ofono/log.h>
 
@@ -210,6 +211,8 @@ static void huaweicdma_post_online(struct ofono_modem *modem)
 
 	DBG("%p", modem);
 
+	ofono_cdma_netreg_create(modem, 0, "huaweicdmamodem", data->modem);
+
 	ofono_cdma_connman_create(modem, 0, "cdmamodem", data->modem);
 }
 
-- 
1.7.4.1

---------------------------------------------------------------------
Intel Corporation SAS (French simplified joint stock company)
Registered headquarters: "Les Montalets"- 2, rue de Paris, 
92196 Meudon Cedex, France
Registration Number:  302 456 199 R.C.S. NANTERRE
Capital: 4,572,000 Euros

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.

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

* [PATCH_v6 09/14] cdmamodem: add strength to CDMA netreg atom
  2011-08-05 13:21 [PATCH_v6 00/14] Create CDMA netreg atom Bertrand Aygon
                   ` (7 preceding siblings ...)
  2011-08-05 13:21 ` [PATCH_v6 08/14] huaweicdma: register to CDMA " Bertrand Aygon
@ 2011-08-05 13:21 ` Bertrand Aygon
  2011-08-05 15:54   ` Denis Kenzior
  2011-08-05 13:21 ` [PATCH_v6 10/14] " Bertrand Aygon
                   ` (4 subsequent siblings)
  13 siblings, 1 reply; 27+ messages in thread
From: Bertrand Aygon @ 2011-08-05 13:21 UTC (permalink / raw)
  To: ofono

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

---
 include/cdma-netreg.h |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/include/cdma-netreg.h b/include/cdma-netreg.h
index 126a5a5..80b0047 100644
--- a/include/cdma-netreg.h
+++ b/include/cdma-netreg.h
@@ -46,6 +46,8 @@ struct ofono_cdma_netreg_driver {
 
 void ofono_cdma_netreg_status_notify(struct ofono_cdma_netreg *netreg,
 				enum cdma_netreg_status status);
+void ofono_cdma_netreg_strength_notify(struct ofono_cdma_netreg *netreg,
+				int strength);
 
 int ofono_cdma_netreg_driver_register(
 				const struct ofono_cdma_netreg_driver *d);
-- 
1.7.4.1

---------------------------------------------------------------------
Intel Corporation SAS (French simplified joint stock company)
Registered headquarters: "Les Montalets"- 2, rue de Paris, 
92196 Meudon Cedex, France
Registration Number:  302 456 199 R.C.S. NANTERRE
Capital: 4,572,000 Euros

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.

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

* [PATCH_v6 10/14] cdmamodem: add strength to CDMA netreg atom.
  2011-08-05 13:21 [PATCH_v6 00/14] Create CDMA netreg atom Bertrand Aygon
                   ` (8 preceding siblings ...)
  2011-08-05 13:21 ` [PATCH_v6 09/14] cdmamodem: add strength " Bertrand Aygon
@ 2011-08-05 13:21 ` 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
                   ` (3 subsequent siblings)
  13 siblings, 1 reply; 27+ messages in thread
From: Bertrand Aygon @ 2011-08-05 13:21 UTC (permalink / raw)
  To: ofono

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

---
 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 ec6b315..12ddd23 100644
--- a/src/cdma-netreg.c
+++ b/src/cdma-netreg.c
@@ -33,6 +33,7 @@ static GSList *g_drivers;
 
 struct ofono_cdma_netreg {
 	enum cdma_netreg_status status;
+	int strength;
 	const struct ofono_cdma_netreg_driver *driver;
 	void *driver_data;
 	struct ofono_atom *atom;
@@ -74,6 +75,13 @@ static DBusMessage *network_get_properties(DBusConnection *conn,
 
 	ofono_dbus_dict_append(&dict, "Status", DBUS_TYPE_STRING, &status);
 
+	if (cdma_netreg->strength != -1) {
+		unsigned char strength = cdma_netreg->strength;
+
+		ofono_dbus_dict_append(&dict, "Strength", DBUS_TYPE_BYTE,
+					&strength);
+	}
+
 	dbus_message_iter_close_container(&iter, &dict);
 
 	return reply;
@@ -113,6 +121,36 @@ void ofono_cdma_netreg_status_notify(struct ofono_cdma_netreg *cdma_netreg,
 		set_registration_status(cdma_netreg, status);
 }
 
+void ofono_cdma_netreg_strength_notify(struct ofono_cdma_netreg *netreg,
+					int strength)
+{
+	if (netreg == NULL)
+		return;
+
+	if (netreg->strength == 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->strength = strength;
+
+	if (strength != -1) {
+		DBusConnection *conn = ofono_dbus_get_connection();
+		const char *path = __ofono_atom_get_path(netreg->atom);
+		unsigned char strength = netreg->strength;
+
+		ofono_dbus_signal_property_changed(conn, path,
+				OFONO_CDMA_NETWORK_REGISTRATION_INTERFACE,
+				"Strength", DBUS_TYPE_BYTE,
+				&strength);
+	}
+}
+
 int ofono_cdma_netreg_driver_register(const struct ofono_cdma_netreg_driver *d)
 {
 	DBG("driver: %p, name: %s", d, d->name);
@@ -177,6 +215,7 @@ struct ofono_cdma_netreg *ofono_cdma_netreg_create(struct ofono_modem *modem,
 		return NULL;
 
 	cdma_netreg->status = CDMA_NETWORK_REGISTRATION_STATUS_NOT_REGISTERED;
+	cdma_netreg->strength = -1;
 
 	cdma_netreg->atom = __ofono_modem_add_atom(modem,
 					OFONO_ATOM_TYPE_CDMA_NETREG,
-- 
1.7.4.1

---------------------------------------------------------------------
Intel Corporation SAS (French simplified joint stock company)
Registered headquarters: "Les Montalets"- 2, rue de Paris, 
92196 Meudon Cedex, France
Registration Number:  302 456 199 R.C.S. NANTERRE
Capital: 4,572,000 Euros

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.

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

* [PATCH_v6 11/14] huaweicdma: register to ^RSSILVL to update signal strength.
  2011-08-05 13:21 [PATCH_v6 00/14] Create CDMA netreg atom Bertrand Aygon
                   ` (9 preceding siblings ...)
  2011-08-05 13:21 ` [PATCH_v6 10/14] " Bertrand Aygon
@ 2011-08-05 13:21 ` Bertrand Aygon
  2011-08-05 13:21 ` [PATCH_v6 12/14] cdmamodem: add data strength to CDMA netreg atom Bertrand Aygon
                   ` (2 subsequent siblings)
  13 siblings, 0 replies; 27+ messages in thread
From: Bertrand Aygon @ 2011-08-05 13:21 UTC (permalink / raw)
  To: ofono

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

---
 drivers/huaweicdmamodem/network-registration.c |   23 +++++++++++++++++++++++
 1 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/drivers/huaweicdmamodem/network-registration.c b/drivers/huaweicdmamodem/network-registration.c
index db91882..b82919a 100644
--- a/drivers/huaweicdmamodem/network-registration.c
+++ b/drivers/huaweicdmamodem/network-registration.c
@@ -115,6 +115,26 @@ static void mode_notify(GAtResult *result, gpointer user_data)
 				sysinfo_cb, netreg, NULL);
 }
 
+static void rssilvl_notify(GAtResult *result, gpointer user_data)
+{
+	struct ofono_cdma_netreg *netreg = user_data;
+	int strength;
+	GAtResultIter iter;
+
+	g_at_result_iter_init(&iter, result);
+
+	if (!g_at_result_iter_next(&iter, "^RSSILVL:"))
+		return;
+
+	if (!g_at_result_iter_next_number(&iter, &strength))
+		return;
+
+	if (strength == 99)
+		strength = 100;
+
+	ofono_cdma_netreg_strength_notify(netreg, strength);
+}
+
 static void probe_cb(gboolean ok, GAtResult *result, gpointer user_data)
 {
 	struct ofono_cdma_netreg *netreg = user_data;
@@ -142,6 +162,9 @@ static int huaweicdma_netreg_probe(struct ofono_cdma_netreg *netreg,
 	g_at_chat_register(nd->chat, "^MODE:",
 				mode_notify, FALSE, netreg, NULL);
 
+	g_at_chat_register(nd->chat, "^RSSILVL:",
+				rssilvl_notify, FALSE, netreg, NULL);
+
 	g_at_chat_send(nd->chat, "AT^SYSINFO", sysinfo_prefix,
 				probe_cb, netreg, NULL);
 
-- 
1.7.4.1

---------------------------------------------------------------------
Intel Corporation SAS (French simplified joint stock company)
Registered headquarters: "Les Montalets"- 2, rue de Paris, 
92196 Meudon Cedex, France
Registration Number:  302 456 199 R.C.S. NANTERRE
Capital: 4,572,000 Euros

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.

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

* [PATCH_v6 12/14] cdmamodem: add data strength to CDMA netreg atom.
  2011-08-05 13:21 [PATCH_v6 00/14] Create CDMA netreg atom Bertrand Aygon
                   ` (10 preceding siblings ...)
  2011-08-05 13:21 ` [PATCH_v6 11/14] huaweicdma: register to ^RSSILVL to update signal strength Bertrand Aygon
@ 2011-08-05 13:21 ` Bertrand Aygon
  2011-08-05 15:55   ` Denis Kenzior
  2011-08-05 13:21 ` [PATCH_v6 13/14] " Bertrand Aygon
  2011-08-05 13:21 ` [PATCH_v6 14/14] test: update list-modem to display CDMA DataStrength info Bertrand Aygon
  13 siblings, 1 reply; 27+ messages in thread
From: Bertrand Aygon @ 2011-08-05 13:21 UTC (permalink / raw)
  To: ofono

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

---
 include/cdma-netreg.h |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/include/cdma-netreg.h b/include/cdma-netreg.h
index 80b0047..5687a24 100644
--- a/include/cdma-netreg.h
+++ b/include/cdma-netreg.h
@@ -48,6 +48,8 @@ void ofono_cdma_netreg_status_notify(struct ofono_cdma_netreg *netreg,
 				enum cdma_netreg_status status);
 void ofono_cdma_netreg_strength_notify(struct ofono_cdma_netreg *netreg,
 				int strength);
+void ofono_cdma_netreg_data_strength_notify(struct ofono_cdma_netreg *netreg,
+				int data_strength);
 
 int ofono_cdma_netreg_driver_register(
 				const struct ofono_cdma_netreg_driver *d);
-- 
1.7.4.1

---------------------------------------------------------------------
Intel Corporation SAS (French simplified joint stock company)
Registered headquarters: "Les Montalets"- 2, rue de Paris, 
92196 Meudon Cedex, France
Registration Number:  302 456 199 R.C.S. NANTERRE
Capital: 4,572,000 Euros

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.

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

* [PATCH_v6 13/14] cdmamodem: add data strength to CDMA netreg atom.
  2011-08-05 13:21 [PATCH_v6 00/14] Create CDMA netreg atom Bertrand Aygon
                   ` (11 preceding siblings ...)
  2011-08-05 13:21 ` [PATCH_v6 12/14] cdmamodem: add data strength to CDMA netreg atom Bertrand Aygon
@ 2011-08-05 13:21 ` Bertrand Aygon
  2011-08-05 15:56   ` Denis Kenzior
  2011-08-05 13:21 ` [PATCH_v6 14/14] test: update list-modem to display CDMA DataStrength info Bertrand Aygon
  13 siblings, 1 reply; 27+ messages in thread
From: Bertrand Aygon @ 2011-08-05 13:21 UTC (permalink / raw)
  To: ofono

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

---
 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);
+	}
+}
+
 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,
-- 
1.7.4.1

---------------------------------------------------------------------
Intel Corporation SAS (French simplified joint stock company)
Registered headquarters: "Les Montalets"- 2, rue de Paris, 
92196 Meudon Cedex, France
Registration Number:  302 456 199 R.C.S. NANTERRE
Capital: 4,572,000 Euros

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.

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

* [PATCH_v6 14/14] test: update list-modem to display CDMA DataStrength info.
  2011-08-05 13:21 [PATCH_v6 00/14] Create CDMA netreg atom Bertrand Aygon
                   ` (12 preceding siblings ...)
  2011-08-05 13:21 ` [PATCH_v6 13/14] " Bertrand Aygon
@ 2011-08-05 13:21 ` Bertrand Aygon
  2011-08-05 15:56   ` Denis Kenzior
  13 siblings, 1 reply; 27+ messages in thread
From: Bertrand Aygon @ 2011-08-05 13:21 UTC (permalink / raw)
  To: ofono

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

---
 test/list-modems |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/test/list-modems b/test/list-modems
index 662a3c7..09949b7 100755
--- a/test/list-modems
+++ b/test/list-modems
@@ -52,7 +52,8 @@ for path, properties in modems:
 						"VoicemailMessageCount",
 						"MicrophoneVolume",
 						"SpeakerVolume",
-						"Strength"]:
+						"Strength",
+						"DataStrength"]:
 				val = int(properties[key])
 			elif key in ["MainMenu"]:
 				val = ", ".join([ text + " (" + str(int(icon)) +
-- 
1.7.4.1

---------------------------------------------------------------------
Intel Corporation SAS (French simplified joint stock company)
Registered headquarters: "Les Montalets"- 2, rue de Paris, 
92196 Meudon Cedex, France
Registration Number:  302 456 199 R.C.S. NANTERRE
Capital: 4,572,000 Euros

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.

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

* Re: [PATCH_v6 01/14] cdmamodem: define CDMA netreg atom.
  2011-08-05 13:21 ` [PATCH_v6 01/14] cdmamodem: define " Bertrand Aygon
@ 2011-08-05 15:50   ` Denis Kenzior
  0 siblings, 0 replies; 27+ messages in thread
From: Denis Kenzior @ 2011-08-05 15:50 UTC (permalink / raw)
  To: ofono

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

Hi Bertrand,

On 08/05/2011 08:21 AM, Bertrand Aygon wrote:
> ---
>  src/ofono.h |    1 +
>  1 files changed, 1 insertions(+), 0 deletions(-)

I applied this patch, but it was re-organized into commit a8bf6e96

Regards,
-Denis

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

* Re: [PATCH_v6 02/14] cdmamodem: create include file for CDMA netreg.
  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
  0 siblings, 0 replies; 27+ messages in thread
From: Denis Kenzior @ 2011-08-05 15:51 UTC (permalink / raw)
  To: ofono

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

Hi Bertrand,

On 08/05/2011 08:21 AM, Bertrand Aygon wrote:
> ---
>  Makefile.am           |    2 +-
>  include/cdma-netreg.h |   63 +++++++++++++++++++++++++++++++++++++++++++++++++
>  src/ofono.h           |    1 +
>  3 files changed, 65 insertions(+), 1 deletions(-)
>  create mode 100644 include/cdma-netreg.h

Patch has been applied, however I reorganized this one into a8bf6e96 and
b7e85709.

Regards,
-Denis

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

* Re: [PATCH_v6 03/14] cdmamodem: create the interface for CDMA netreg.
  2011-08-05 13:21 ` [PATCH_v6 03/14] cdmamodem: create the interface " Bertrand Aygon
@ 2011-08-05 15:51   ` Denis Kenzior
  0 siblings, 0 replies; 27+ messages in thread
From: Denis Kenzior @ 2011-08-05 15:51 UTC (permalink / raw)
  To: ofono

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

Hi Bertrand,

On 08/05/2011 08:21 AM, Bertrand Aygon wrote:
> ---
>  Makefile.am       |    2 +-
>  src/cdma-netreg.c |  190 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 191 insertions(+), 1 deletions(-)
>  create mode 100644 src/cdma-netreg.c
> 

Patch has been applied, thanks.

Regards,
-Denis

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

* Re: [PATCH_v6 04/14] cdmamodem: define cdma network status.
  2011-08-05 13:21 ` [PATCH_v6 04/14] cdmamodem: define cdma network status Bertrand Aygon
@ 2011-08-05 15:52   ` Denis Kenzior
  0 siblings, 0 replies; 27+ messages in thread
From: Denis Kenzior @ 2011-08-05 15:52 UTC (permalink / raw)
  To: ofono

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

Hi Bertrand,

On 08/05/2011 08:21 AM, Bertrand Aygon wrote:
> ---
>  include/cdma-netreg.h |    9 +++++++++
>  1 files changed, 9 insertions(+), 0 deletions(-)
> 

Patch has been applied with a modified commit message.

Regards,
-Denis

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

* Re: [PATCH_v6 05/14] cdmamodem: implement cdma network status.
  2011-08-05 13:21 ` [PATCH_v6 05/14] cdmamodem: implement " Bertrand Aygon
@ 2011-08-05 15:52   ` Denis Kenzior
  0 siblings, 0 replies; 27+ messages in thread
From: Denis Kenzior @ 2011-08-05 15:52 UTC (permalink / raw)
  To: ofono

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

Hi Bertrand,

On 08/05/2011 08:21 AM, Bertrand Aygon wrote:
> ---
>  src/cdma-netreg.c |   47 +++++++++++++++++++++++++++++++++++++++++++++++
>  1 files changed, 47 insertions(+), 0 deletions(-)
> 

Patch has been applied with a modified commit message.

Regards,
-Denis

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

* Re: [PATCH_v6 06/14] huaweicdmamodem: create a huawei cdma driver.
  2011-08-05 13:21 ` [PATCH_v6 06/14] huaweicdmamodem: create a huawei cdma driver Bertrand Aygon
@ 2011-08-05 15:54   ` Denis Kenzior
  0 siblings, 0 replies; 27+ messages in thread
From: Denis Kenzior @ 2011-08-05 15:54 UTC (permalink / raw)
  To: ofono

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

Hi Bertrand,

On 08/05/2011 08:21 AM, Bertrand Aygon wrote:
> ---
>  Makefile.am                               |    5 +++
>  drivers/huaweicdmamodem/huaweicdmamodem.c |   42 +++++++++++++++++++++++++++++
>  drivers/huaweicdmamodem/huaweicdmamodem.h |   21 ++++++++++++++
>  3 files changed, 68 insertions(+), 0 deletions(-)
>  create mode 100644 drivers/huaweicdmamodem/huaweicdmamodem.c
>  create mode 100644 drivers/huaweicdmamodem/huaweicdmamodem.h
> 

Patch has been applied, however:

<snip>

> diff --git a/drivers/huaweicdmamodem/huaweicdmamodem.h b/drivers/huaweicdmamodem/huaweicdmamodem.h
> new file mode 100644
> index 0000000..018747f
> --- /dev/null
> +++ b/drivers/huaweicdmamodem/huaweicdmamodem.h
> @@ -0,0 +1,21 @@
> +/*
> + *
> + *  oFono - Open Source Telephony
> + *
> + *  Copyright (C) 2008-2011  Intel Corporation. All rights reserved.
> + *
> + *  This program is free software; you can redistribute it and/or modify
> + *  it under the terms of the GNU General Public License version 2 as
> + *  published by the Free Software Foundation.
> + *
> + *  This program is distributed in the hope that it will be useful,
> + *  but WITHOUT ANY WARRANTY; without even the implied warranty of
> + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + *  GNU General Public License for more details.
> + *
> + *  You should have received a copy of the GNU General Public License
> + *  along with this program; if not, write to the Free Software
> + *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
> + *
> + */
> +

I had to take out this empty line otherwise git am complained.  This
causes git am of patches 7, 8, 11 to fail.  So please resubmit these.

Regards,
-Denis

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

* Re: [PATCH_v6 09/14] cdmamodem: add strength to CDMA netreg atom
  2011-08-05 13:21 ` [PATCH_v6 09/14] cdmamodem: add strength " Bertrand Aygon
@ 2011-08-05 15:54   ` Denis Kenzior
  0 siblings, 0 replies; 27+ messages in thread
From: Denis Kenzior @ 2011-08-05 15:54 UTC (permalink / raw)
  To: ofono

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

Hi Bertrand,

On 08/05/2011 08:21 AM, Bertrand Aygon wrote:
> ---
>  include/cdma-netreg.h |    2 ++
>  1 files changed, 2 insertions(+), 0 deletions(-)
> 

Patch has been applied with a modified commit message.

Regards,
-Denis

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

* Re: [PATCH_v6 10/14] cdmamodem: add strength to CDMA netreg atom.
  2011-08-05 13:21 ` [PATCH_v6 10/14] " Bertrand Aygon
@ 2011-08-05 15:54   ` Denis Kenzior
  0 siblings, 0 replies; 27+ messages in thread
From: Denis Kenzior @ 2011-08-05 15:54 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 252 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(-)
> 

Patch has been applied, thanks.

Regards,
-Denis

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

* Re: [PATCH_v6 12/14] cdmamodem: add data strength to CDMA netreg atom.
  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
  0 siblings, 0 replies; 27+ messages in thread
From: Denis Kenzior @ 2011-08-05 15:55 UTC (permalink / raw)
  To: ofono

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

Hi Bertrand,

On 08/05/2011 08:21 AM, Bertrand Aygon wrote:
> ---
>  include/cdma-netreg.h |    2 ++
>  1 files changed, 2 insertions(+), 0 deletions(-)
> 

Patch has been applied, thanks.

Regards,
-Denis

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

* Re: [PATCH_v6 13/14] cdmamodem: add data strength to CDMA netreg atom.
  2011-08-05 13:21 ` [PATCH_v6 13/14] " Bertrand Aygon
@ 2011-08-05 15:56   ` Denis Kenzior
  0 siblings, 0 replies; 27+ messages in thread
From: Denis Kenzior @ 2011-08-05 15:56 UTC (permalink / raw)
  To: ofono

[-- 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

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

* Re: [PATCH_v6 14/14] test: update list-modem to display CDMA DataStrength info.
  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
  0 siblings, 0 replies; 27+ messages in thread
From: Denis Kenzior @ 2011-08-05 15:56 UTC (permalink / raw)
  To: ofono

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

Hi Bertrand,

On 08/05/2011 08:21 AM, Bertrand Aygon wrote:
> ---
>  test/list-modems |    3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)
> 

Patch has been applied, thanks.

Regards,
-Denis

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

* Re: [PATCH_v6 07/14] huaweicdma: create a dedicated netreg atom.
  2011-08-05 13:21 ` [PATCH_v6 07/14] huaweicdma: create a dedicated netreg atom Bertrand Aygon
@ 2011-08-05 16:04   ` Denis Kenzior
  0 siblings, 0 replies; 27+ messages in thread
From: Denis Kenzior @ 2011-08-05 16:04 UTC (permalink / raw)
  To: ofono

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

Hi Bertrand,

On 08/05/2011 08:21 AM, Bertrand Aygon wrote:
> ---
>  Makefile.am                                    |    3 +-
>  drivers/huaweicdmamodem/huaweicdmamodem.c      |    3 +
>  drivers/huaweicdmamodem/huaweicdmamodem.h      |    2 +
>  drivers/huaweicdmamodem/network-registration.c |  175 ++++++++++++++++++++++++
>  4 files changed, 182 insertions(+), 1 deletions(-)
>  create mode 100644 drivers/huaweicdmamodem/network-registration.c
> 

<snip>

> +
> +struct huaweicdma_netreg_data {
> +	GAtChat *chat;
> +};
> +

I know other drivers do this, but in general I don't like this form.
I'd rather you set the chat directly into the cdma_netreg data and
simplify things a bit.

Unless you can definitely predict that you will have additional data
members here in the future.

> +static void parse_sysinfo(GAtResult *result, gint *status)
> +{
> +	GAtResultIter iter;
> +	gint srv_status;
> +	gint srv_domain;
> +	gint roaming_status;
> +
> +	g_at_result_iter_init(&iter, result);
> +
> +	if (!g_at_result_iter_next(&iter, "^SYSINFO:"))
> +		return;
> +
> +	if (!g_at_result_iter_next_number(&iter, &srv_status))
> +		return;
> +
> +	if (!g_at_result_iter_next_number(&iter, &srv_domain))
> +		return;
> +
> +	if (!g_at_result_iter_next_number(&iter, &roaming_status))
> +		return;
> +

You can't simply return here, otherwise you end up giving bogus values
to the core.

> +	DBG("%d, %d, %d", srv_status, srv_domain, roaming_status);
> +
> +	switch (srv_status) {
> +	case 1:	/* Restricted service */
> +	case 2:	/* Service valid */
> +	case 3:	/* Restricted region service */
> +		if (roaming_status)
> +			*status = CDMA_NETWORK_REGISTRATION_STATUS_ROAMING;
> +		else
> +			*status = CDMA_NETWORK_REGISTRATION_STATUS_REGISTERED;
> +		break;
> +	case 0:	/* No service */
> +	case 4:	/* Not registered */
> +	default:
> +		*status = CDMA_NETWORK_REGISTRATION_STATUS_NOT_REGISTERED;
> +		break;
> +	}
> +
> +	switch (srv_domain) {
> +	case 0: /* No service */
> +	case 255: /* CDMA not supported */
> +		*status = CDMA_NETWORK_REGISTRATION_STATUS_NOT_REGISTERED;
> +		break;
> +	case 1: /* Only CS */
> +	case 2: /* Only PS */
> +	case 3: /* CS + PS */
> +	case 4: /* CS registered, PS in searching state */
> +		break;
> +	}
> +}
> +
> +static void sysinfo_cb(gboolean ok, GAtResult *result, gpointer user_data)
> +{
> +	struct ofono_cdma_netreg *netreg = user_data;
> +	int status;
> +
> +	if (!ok)
> +		return;
> +
> +	parse_sysinfo(result, &status);

Printing some sort of an error and defaulting to not registered might be
helpful here in case parsing of sysinfo fails.  And remember, "Be more
paranoid"


> +
> +	ofono_cdma_netreg_status_notify(netreg, status);
> +}
> +
> +static void mode_notify(GAtResult *result, gpointer user_data)
> +{
> +	struct ofono_cdma_netreg *netreg = user_data;
> +	struct huaweicdma_netreg_data *nd = ofono_cdma_netreg_get_data(netreg);
> +
> +	g_at_chat_send(nd->chat, "AT^SYSINFO", sysinfo_prefix,
> +				sysinfo_cb, netreg, NULL);
> +}
> +
> +static void probe_cb(gboolean ok, GAtResult *result, gpointer user_data)
> +{
> +	struct ofono_cdma_netreg *netreg = user_data;
> +
> +	if (!ok)
> +		return;

If the driver fails its probe, you should remove the atom, not simply
leave it in a zombie state consuming resources.

> +
> +	ofono_cdma_netreg_register(netreg);
> +}
> +
> +static int huaweicdma_netreg_probe(struct ofono_cdma_netreg *netreg,
> +				unsigned int vendor, void *data)
> +{
> +	GAtChat *chat = data;
> +	struct huaweicdma_netreg_data *nd;
> +
> +	nd = g_try_new0(struct huaweicdma_netreg_data, 1);
> +	if (nd == NULL)
> +		return -ENOMEM;
> +
> +	nd->chat = g_at_chat_clone(chat);
> +
> +	ofono_cdma_netreg_set_data(netreg, nd);
> +
> +	g_at_chat_register(nd->chat, "^MODE:",
> +				mode_notify, FALSE, netreg, NULL);
> +

Shouldn't you do this after you know that SYSINFO is supported?

> +	g_at_chat_send(nd->chat, "AT^SYSINFO", sysinfo_prefix,
> +				probe_cb, netreg, NULL);
> +
> +	return 0;
> +}
> +
> +static void huaweicdma_netreg_remove(struct ofono_cdma_netreg *netreg)
> +{
> +	struct huaweicdma_netreg_data *nd = ofono_cdma_netreg_get_data(netreg);
> +
> +	ofono_cdma_netreg_set_data(netreg, NULL);
> +
> +	g_at_chat_unref(nd->chat);
> +	g_free(nd);
> +}
> +
> +static struct ofono_cdma_netreg_driver driver = {
> +	.name	= "huaweicdmamodem",
> +	.probe	= huaweicdma_netreg_probe,
> +	.remove	= huaweicdma_netreg_remove,
> +};
> +
> +void huaweicdma_netreg_init(void)
> +{
> +	ofono_cdma_netreg_driver_register(&driver);
> +}
> +
> +void huaweicdma_netreg_exit(void)
> +{
> +	ofono_cdma_netreg_driver_unregister(&driver);
> +}


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

end of thread, other threads:[~2011-08-05 16:04 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.