All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/8] Add GPS atom
@ 2010-12-16 20:30 Rafael Ignacio Zurita
  2010-12-16 20:30 ` [PATCH 1/8] gps: define new dbus interface Rafael Ignacio Zurita
                   ` (7 more replies)
  0 siblings, 8 replies; 14+ messages in thread
From: Rafael Ignacio Zurita @ 2010-12-16 20:30 UTC (permalink / raw)
  To: ofono

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

These patches add GPS atom to ofono, and implement it for mbm modem.

Rafael Ignacio Zurita (8):
  gps: define new dbus interface
  gps: add new interface to feature map
  gps: add public header
  gps: implement interface/atom
  mbmmodem: add gps atom
  plugins: add gps atom to mbm
  plugins/udev.c: add gps comparison for add_mbm registered modem
  gps: add documentation

 Makefile.am                 |   10 +-
 doc/gps-api.txt             |   41 ++++++
 drivers/mbmmodem/gps.c      |  185 ++++++++++++++++++++++++
 drivers/mbmmodem/mbmmodem.c |    2 +
 drivers/mbmmodem/mbmmodem.h |    3 +
 include/dbus.h              |    1 +
 include/gps.h               |   65 +++++++++
 plugins/mbm.c               |   30 ++++-
 plugins/udev.c              |    5 +-
 src/gps.c                   |  333 +++++++++++++++++++++++++++++++++++++++++++
 src/modem.c                 |    1 +
 src/ofono.h                 |    2 +
 12 files changed, 670 insertions(+), 8 deletions(-)
 create mode 100644 doc/gps-api.txt
 create mode 100644 drivers/mbmmodem/gps.c
 create mode 100644 include/gps.h
 create mode 100644 src/gps.c

-- 
1.7.2.3


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

* [PATCH 1/8] gps: define new dbus interface
  2010-12-16 20:30 [PATCH 0/8] Add GPS atom Rafael Ignacio Zurita
@ 2010-12-16 20:30 ` Rafael Ignacio Zurita
  2010-12-22 21:45   ` Denis Kenzior
  2010-12-16 20:30 ` [PATCH 2/8] gps: add new interface to feature map Rafael Ignacio Zurita
                   ` (6 subsequent siblings)
  7 siblings, 1 reply; 14+ messages in thread
From: Rafael Ignacio Zurita @ 2010-12-16 20:30 UTC (permalink / raw)
  To: ofono

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

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

diff --git a/include/dbus.h b/include/dbus.h
index 9e29afb..48e8ac4 100644
--- a/include/dbus.h
+++ b/include/dbus.h
@@ -54,6 +54,7 @@ extern "C" {
 #define OFONO_VOICECALL_MANAGER_INTERFACE "org.ofono.VoiceCallManager"
 #define OFONO_STK_INTERFACE OFONO_SERVICE ".SimToolkit"
 #define OFONO_SIM_APP_INTERFACE OFONO_SERVICE ".SimToolkitAgent"
+#define OFONO_GPS_INTERFACE OFONO_SERVICE ".Gps"
 
 /* Essentially a{sv} */
 #define OFONO_PROPERTIES_ARRAY_SIGNATURE DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING \
-- 
1.7.2.3


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

* [PATCH 2/8] gps: add new interface to feature map
  2010-12-16 20:30 [PATCH 0/8] Add GPS atom Rafael Ignacio Zurita
  2010-12-16 20:30 ` [PATCH 1/8] gps: define new dbus interface Rafael Ignacio Zurita
@ 2010-12-16 20:30 ` Rafael Ignacio Zurita
  2010-12-16 20:30 ` [PATCH 3/8] gps: add public header Rafael Ignacio Zurita
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 14+ messages in thread
From: Rafael Ignacio Zurita @ 2010-12-16 20:30 UTC (permalink / raw)
  To: ofono

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

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

diff --git a/src/modem.c b/src/modem.c
index 2f9387c..6d7b10e 100644
--- a/src/modem.c
+++ b/src/modem.c
@@ -906,6 +906,7 @@ static const struct {
 	{ OFONO_STK_INTERFACE,				"stk"	},
 	{ OFONO_CONNECTION_MANAGER_INTERFACE,		"gprs"	},
 	{ OFONO_TEXT_TELEPHONY_INTERFACE,		"tty"	},
+	{ OFONO_GPS_INTERFACE,				"gps"	},
 	{ },
 };
 
-- 
1.7.2.3


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

* [PATCH 3/8] gps: add public header
  2010-12-16 20:30 [PATCH 0/8] Add GPS atom Rafael Ignacio Zurita
  2010-12-16 20:30 ` [PATCH 1/8] gps: define new dbus interface Rafael Ignacio Zurita
  2010-12-16 20:30 ` [PATCH 2/8] gps: add new interface to feature map Rafael Ignacio Zurita
@ 2010-12-16 20:30 ` Rafael Ignacio Zurita
  2010-12-22 21:53   ` Denis Kenzior
  2010-12-16 20:30 ` [PATCH 4/8] gps: implement interface/atom Rafael Ignacio Zurita
                   ` (4 subsequent siblings)
  7 siblings, 1 reply; 14+ messages in thread
From: Rafael Ignacio Zurita @ 2010-12-16 20:30 UTC (permalink / raw)
  To: ofono

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

---
 Makefile.am   |    2 +-
 include/gps.h |   65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 66 insertions(+), 1 deletions(-)
 create mode 100644 include/gps.h

diff --git a/Makefile.am b/Makefile.am
index 12b3c33..370f63e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -14,7 +14,7 @@ include_HEADERS = include/log.h include/plugin.h include/history.h \
 			include/gprs.h include/gprs-context.h \
 			include/radio-settings.h include/stk.h \
 			include/audio-settings.h include/nettime.h \
-			include/ctm.h
+			include/ctm.h include/gps.h
 
 nodist_include_HEADERS = include/version.h
 
diff --git a/include/gps.h b/include/gps.h
new file mode 100644
index 0000000..31210a4
--- /dev/null
+++ b/include/gps.h
@@ -0,0 +1,65 @@
+/*
+ *
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ *  Copyright (C) 2010 ProFUSION embedded systems.
+ *
+ *  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_GPS_H
+#define __OFONO_GPS_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <ofono/types.h>
+
+struct ofono_gps;
+
+typedef void (*ofono_gps_set_cb_t)(const struct ofono_error *error, void *data);
+typedef void (*ofono_gps_query_cb_t)(const struct ofono_error *error,
+					ofono_bool_t enable, void *data);
+
+struct ofono_gps_driver {
+	const char *name;
+	int (*probe)(struct ofono_gps *gps, unsigned int vendor, void *data);
+	void (*remove)(struct ofono_gps *gps);
+	void (*set_gps)(struct ofono_gps *gps, ofono_bool_t enable,
+				ofono_gps_set_cb_t, void *data);
+	void (*query_gps)(struct ofono_gps *gps, ofono_gps_query_cb_t cb,
+				void *data);
+};
+
+int ofono_gps_driver_register(const struct ofono_gps_driver *d);
+void ofono_gps_driver_unregister(const struct ofono_gps_driver *d);
+
+struct ofono_gps *ofono_gps_create(struct ofono_modem *modem,
+					unsigned int vendor, const char *driver,
+					void *data);
+
+void ofono_gps_register(struct ofono_gps *gps);
+void ofono_gps_remove(struct ofono_gps *gps);
+
+void ofono_gps_set_data(struct ofono_gps *gps, void *data);
+void *ofono_gps_get_data(struct ofono_gps *gps);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __OFONO_GPS_H */
-- 
1.7.2.3


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

* [PATCH 4/8] gps: implement interface/atom
  2010-12-16 20:30 [PATCH 0/8] Add GPS atom Rafael Ignacio Zurita
                   ` (2 preceding siblings ...)
  2010-12-16 20:30 ` [PATCH 3/8] gps: add public header Rafael Ignacio Zurita
@ 2010-12-16 20:30 ` Rafael Ignacio Zurita
  2010-12-16 20:30 ` [PATCH 5/8] mbmmodem: add gps atom Rafael Ignacio Zurita
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 14+ messages in thread
From: Rafael Ignacio Zurita @ 2010-12-16 20:30 UTC (permalink / raw)
  To: ofono

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

---
 Makefile.am |    2 +-
 src/gps.c   |  333 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/ofono.h |    2 +
 3 files changed, 336 insertions(+), 1 deletions(-)
 create mode 100644 src/gps.c

diff --git a/Makefile.am b/Makefile.am
index 370f63e..45f1ba3 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -319,7 +319,7 @@ src_ofonod_SOURCES = $(gdbus_sources) $(builtin_sources) src/ofono.ver \
 			src/radio-settings.c src/stkutil.h src/stkutil.c \
 			src/nettime.c src/stkagent.c src/stkagent.h \
 			src/simfs.c src/simfs.h src/audio-settings.c \
-			src/smsagent.c src/smsagent.h src/ctm.c
+			src/smsagent.c src/smsagent.h src/ctm.c src/gps.c
 
 src_ofonod_LDADD = $(builtin_libadd) @GLIB_LIBS@ @DBUS_LIBS@ @CAPNG_LIBS@ -ldl
 
diff --git a/src/gps.c b/src/gps.c
new file mode 100644
index 0000000..09c448e
--- /dev/null
+++ b/src/gps.c
@@ -0,0 +1,333 @@
+/*
+ *
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ *  Copyright (C) 2010  Intel Corporation. All rights reserved.
+ *  Copyright (C) 2010 ProFUSION embedded systems.
+ *
+ *  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 <string.h>
+#include <stdio.h>
+#include <errno.h>
+
+#include <glib.h>
+#include <gdbus.h>
+
+#include "ofono.h"
+#include "common.h"
+
+#define GPS_FLAG_CACHED 0x1
+
+static GSList *g_drivers = NULL;
+
+struct ofono_gps {
+	DBusMessage *pending;
+	int flags;
+	ofono_bool_t powered;
+	const struct ofono_gps_driver *driver;
+	void *driver_data;
+	struct ofono_atom *atom;
+};
+
+static DBusMessage *gps_get_properties_reply(DBusMessage *msg,
+						struct ofono_gps *gps)
+{
+	DBusMessage *reply;
+	DBusMessageIter iter;
+	DBusMessageIter dict;
+	dbus_bool_t value;
+
+	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);
+
+	value = gps->powered;
+	ofono_dbus_dict_append(&dict, "Powered", DBUS_TYPE_BOOLEAN, &value);
+	dbus_message_iter_close_container(&iter, &dict);
+
+	return reply;
+}
+
+static void gps_signal_powered(struct ofono_gps *gps)
+{
+	DBusConnection *conn = ofono_dbus_get_connection();
+	const char *path = __ofono_atom_get_path(gps->atom);
+	ofono_bool_t value = gps->powered;
+
+	ofono_dbus_signal_property_changed(conn, path,
+						OFONO_GPS_INTERFACE,
+						"Powered",
+						DBUS_TYPE_BOOLEAN, &value);
+}
+
+static void gps_set_powered_callback(const struct ofono_error *error,
+					void *data)
+{
+	struct ofono_gps *gps = data;
+	DBusMessage *reply;
+
+	if (error->type != OFONO_ERROR_TYPE_NO_ERROR) {
+		ofono_error("Error setting gps powered property");
+
+		reply = __ofono_error_failed(gps->pending);
+		__ofono_dbus_pending_reply(&gps->pending, reply);
+
+		return;
+	}
+
+	gps->powered = !gps->powered;
+
+	reply = dbus_message_new_method_return(gps->pending);
+	__ofono_dbus_pending_reply(&gps->pending, reply);
+
+	gps_signal_powered(gps);
+}
+
+
+static void gps_query_powered_callback(const struct ofono_error *error,
+					ofono_bool_t powered, void *data)
+{
+	struct ofono_gps *gps = data;
+	DBusMessage *reply;
+	ofono_bool_t powered_old;
+
+	if (error->type != OFONO_ERROR_TYPE_NO_ERROR) {
+		ofono_error("Error during gps power query");
+
+		reply = __ofono_error_failed(gps->pending);
+		__ofono_dbus_pending_reply(&gps->pending, reply);
+
+		return;
+	}
+
+	gps->flags |= GPS_FLAG_CACHED;
+
+	powered_old = gps->powered;
+	gps->powered = powered;
+
+	reply = gps_get_properties_reply(gps->pending, gps);
+	__ofono_dbus_pending_reply(&gps->pending, reply);
+
+	if (gps->powered != powered_old)
+		gps_signal_powered(gps);
+
+}
+
+static DBusMessage *gps_get_properties(DBusConnection *conn,
+					DBusMessage *msg, void *data)
+{
+	struct ofono_gps *gps = data;
+
+	if (gps->flags & GPS_FLAG_CACHED)
+		return gps_get_properties_reply(msg, gps);
+
+	if (gps->pending)
+		return __ofono_error_busy(msg);
+
+	gps->pending = dbus_message_ref(msg);
+
+	gps->driver->query_gps(gps, gps_query_powered_callback, gps);
+
+	return NULL;
+}
+
+static DBusMessage *gps_set_property(DBusConnection *conn, DBusMessage *msg,
+					void *data)
+{
+	struct ofono_gps *gps = data;
+	DBusMessageIter iter;
+	DBusMessageIter var;
+	const char *property;
+
+	if (gps->pending)
+		return __ofono_error_busy(msg);
+
+	if (!dbus_message_iter_init(msg, &iter))
+		return __ofono_error_invalid_args(msg);
+
+	if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING)
+		return __ofono_error_invalid_args(msg);
+
+	dbus_message_iter_get_basic(&iter, &property);
+	dbus_message_iter_next(&iter);
+
+	if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_VARIANT)
+		return __ofono_error_invalid_args(msg);
+
+	dbus_message_iter_recurse(&iter, &var);
+
+	if (g_strcmp0(property, "Powered") == 0) {
+		dbus_bool_t value;
+		int target;
+
+		if (dbus_message_iter_get_arg_type(&var) != DBUS_TYPE_BOOLEAN)
+			return __ofono_error_invalid_args(msg);
+
+		dbus_message_iter_get_basic(&var, &value);
+		target = value;
+
+		if (gps->powered == target)
+			return dbus_message_new_method_return(msg);
+
+		gps->pending = dbus_message_ref(msg);
+
+		gps->driver->set_gps(gps, target, gps_set_powered_callback,
+					gps);
+		return NULL;
+	}
+
+	return __ofono_error_invalid_args(msg);
+}
+
+static GDBusMethodTable gps_methods[] = {
+	{ "GetProperties",  "",    "a{sv}",  gps_get_properties,
+						G_DBUS_METHOD_FLAG_ASYNC },
+	{ "SetProperty",    "sv",  "",       gps_set_property,
+						G_DBUS_METHOD_FLAG_ASYNC },
+	{ }
+};
+
+static GDBusSignalTable gps_signals[] = {
+	{ "PropertyChanged",	"sv" },
+	{ }
+};
+
+int ofono_gps_driver_register(const struct ofono_gps_driver *d)
+{
+	DBG("driver: %p, name: %s", d, d->name);
+
+	if (d == NULL || d->probe == NULL)
+		return -EINVAL;
+
+	g_drivers = g_slist_prepend(g_drivers, (void *) d);
+
+	return 0;
+}
+
+void ofono_gps_driver_unregister(const struct ofono_gps_driver *d)
+{
+	DBG("driver: %p, name: %s", d, d->name);
+
+	if (d == NULL)
+		return;
+
+	g_drivers = g_slist_remove(g_drivers, (void *) d);
+}
+
+static void gps_unregister(struct ofono_atom *atom)
+{
+	struct ofono_gps *gps = __ofono_atom_get_data(atom);
+	const char *path = __ofono_atom_get_path(gps->atom);
+	DBusConnection *conn = ofono_dbus_get_connection();
+	struct ofono_modem *modem = __ofono_atom_get_modem(gps->atom);
+
+	ofono_modem_remove_interface(modem, OFONO_GPS_INTERFACE);
+	g_dbus_unregister_interface(conn, path, OFONO_GPS_INTERFACE);
+}
+
+static void gps_remove(struct ofono_atom *atom)
+{
+	struct ofono_gps *gps = __ofono_atom_get_data(atom);
+
+	DBG("atom: %p", atom);
+
+	if (gps == NULL)
+		return;
+
+	if (gps->driver && gps->driver->remove)
+		gps->driver->remove(gps);
+
+	g_free(gps);
+}
+
+struct ofono_gps *ofono_gps_create(struct ofono_modem *modem,
+					 unsigned int vendor,
+					 const char *driver, void *data)
+{
+	struct ofono_gps *gps;
+	GSList *l;
+
+	if (driver == NULL)
+		return NULL;
+
+	gps = g_try_new0(struct ofono_gps, 1);
+	if (gps == NULL)
+		return NULL;
+
+	gps->atom = __ofono_modem_add_atom(modem, OFONO_ATOM_TYPE_GPS,
+						gps_remove, gps);
+
+	for (l = g_drivers; l; l = l->next) {
+		const struct ofono_gps_driver *drv = l->data;
+
+		if (g_strcmp0(drv->name, driver) != 0)
+			continue;
+
+		if (drv->probe(gps, vendor, data) < 0)
+			continue;
+
+		gps->driver = drv;
+		break;
+	}
+
+	return gps;
+}
+
+void ofono_gps_register(struct ofono_gps *gps)
+{
+	DBusConnection *conn = ofono_dbus_get_connection();
+	struct ofono_modem *modem = __ofono_atom_get_modem(gps->atom);
+	const char *path = __ofono_atom_get_path(gps->atom);
+
+	if (!g_dbus_register_interface(conn, path, OFONO_GPS_INTERFACE,
+					gps_methods, gps_signals, NULL, gps,
+					NULL)) {
+		ofono_error("Could not create %s interface",
+				OFONO_GPS_INTERFACE);
+
+		return;
+	}
+
+	ofono_modem_add_interface(modem, OFONO_GPS_INTERFACE);
+	__ofono_atom_register(gps->atom, gps_unregister);
+}
+
+void ofono_gps_remove(struct ofono_gps *gps)
+{
+	__ofono_atom_free(gps->atom);
+}
+
+void ofono_gps_set_data(struct ofono_gps *gps,
+					void *data)
+{
+	gps->driver_data = data;
+}
+
+void *ofono_gps_get_data(struct ofono_gps *gps)
+{
+	return gps->driver_data;
+}
diff --git a/src/ofono.h b/src/ofono.h
index 792134b..aa62368 100644
--- a/src/ofono.h
+++ b/src/ofono.h
@@ -126,6 +126,7 @@ enum ofono_atom_type {
 	OFONO_ATOM_TYPE_STK = 20,
 	OFONO_ATOM_TYPE_NETTIME = 21,
 	OFONO_ATOM_TYPE_CTM = 22,
+	OFONO_ATOM_TYPE_GPS = 23,
 };
 
 enum ofono_atom_watch_condition {
@@ -207,6 +208,7 @@ gboolean __ofono_call_settings_is_busy(struct ofono_call_settings *cs);
 #include <ofono/radio-settings.h>
 #include <ofono/audio-settings.h>
 #include <ofono/ctm.h>
+#include <ofono/gps.h>
 
 #include <ofono/voicecall.h>
 
-- 
1.7.2.3


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

* [PATCH 5/8] mbmmodem: add gps atom
  2010-12-16 20:30 [PATCH 0/8] Add GPS atom Rafael Ignacio Zurita
                   ` (3 preceding siblings ...)
  2010-12-16 20:30 ` [PATCH 4/8] gps: implement interface/atom Rafael Ignacio Zurita
@ 2010-12-16 20:30 ` Rafael Ignacio Zurita
  2010-12-16 20:30 ` [PATCH 6/8] plugins: add gps atom to mbm Rafael Ignacio Zurita
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 14+ messages in thread
From: Rafael Ignacio Zurita @ 2010-12-16 20:30 UTC (permalink / raw)
  To: ofono

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

---
 Makefile.am                 |    3 +-
 drivers/mbmmodem/gps.c      |  185 +++++++++++++++++++++++++++++++++++++++++++
 drivers/mbmmodem/mbmmodem.c |    2 +
 drivers/mbmmodem/mbmmodem.h |    3 +
 4 files changed, 192 insertions(+), 1 deletions(-)
 create mode 100644 drivers/mbmmodem/gps.c

diff --git a/Makefile.am b/Makefile.am
index 45f1ba3..4b8cb51 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -202,7 +202,8 @@ builtin_sources += drivers/atmodem/atutil.h \
 			drivers/mbmmodem/mbmmodem.h \
 			drivers/mbmmodem/mbmmodem.c \
 			drivers/mbmmodem/gprs-context.c \
-			drivers/mbmmodem/stk.c
+			drivers/mbmmodem/stk.c \
+			drivers/mbmmodem/gps.c
 
 builtin_modules += hsomodem
 builtin_sources += drivers/atmodem/atutil.h \
diff --git a/drivers/mbmmodem/gps.c b/drivers/mbmmodem/gps.c
new file mode 100644
index 0000000..5bcfeb5
--- /dev/null
+++ b/drivers/mbmmodem/gps.c
@@ -0,0 +1,185 @@
+/*
+ *
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2008-2010  Intel Corporation. All rights reserved.
+ *  Copyright (C) 2010 ProFUSION embedded systems.
+ *
+ *  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 <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+
+#include <glib.h>
+
+#include <ofono/log.h>
+#include <ofono/modem.h>
+#include <ofono/gps.h>
+
+#include "gatchat.h"
+#include "gatresult.h"
+
+#include "mbmmodem.h"
+
+static const char *none_prefix[] = { NULL };
+static const char *e2gpsctl_prefix[] = { "*E2GPSCTL:", NULL };
+
+struct gps_data {
+	GAtChat *chat;
+};
+
+static void mbm_gps_query_cb(gboolean ok, GAtResult *result, gpointer user_data)
+{
+	struct cb_data *cbd = user_data;
+	ofono_gps_query_cb_t cb = cbd->cb;
+	struct ofono_error error;
+	GAtResultIter iter;
+	int value;
+
+	decode_at_error(&error, g_at_result_final_response(result));
+
+	if (!ok) {
+		cb(&error, -1, cbd->data);
+		return;
+	}
+
+	g_at_result_iter_init(&iter, result);
+
+	if (g_at_result_iter_next(&iter, "*E2GPSCTL:") == FALSE)
+		goto error;
+
+	if (g_at_result_iter_next_number(&iter, &value) == FALSE)
+		goto error;
+
+	if ((value != 0) && (value != 1))
+		goto error;
+
+	cb(&error, value, cbd->data);
+
+	return;
+
+error:
+	CALLBACK_WITH_FAILURE(cb, -1, cbd->data);
+}
+
+static void mbm_query_gps(struct ofono_gps *g,
+				ofono_gps_query_cb_t cb,
+				void *data)
+{
+	struct gps_data *gd = ofono_gps_get_data(g);
+	struct cb_data *cbd = cb_data_new(cb, data);
+
+	if (g_at_chat_send(gd->chat, "AT*E2GPSCTL?", e2gpsctl_prefix,
+					mbm_gps_query_cb, cbd, g_free) == 0) {
+		CALLBACK_WITH_FAILURE(cb, -1, data);
+		g_free(cbd);
+	}
+}
+
+static void mbm_e2gpsctl_cb(gboolean ok, GAtResult *result, gpointer user_data)
+{
+	struct cb_data *cbd = user_data;
+	ofono_gps_set_cb_t cb = cbd->cb;
+	struct ofono_error error;
+
+	decode_at_error(&error, g_at_result_final_response(result));
+	cb(&error, cbd->data);
+}
+
+static void mbm_set_gps(struct ofono_gps *g,
+				gboolean value,
+				ofono_gps_set_cb_t cb,
+				void *data)
+{
+	struct gps_data *gd = ofono_gps_get_data(g);
+	struct cb_data *cbd = cb_data_new(cb, data);
+	char buf[20];
+
+	snprintf(buf, sizeof(buf), "AT*E2GPSCTL=%u,5,1", value);
+
+	if (g_at_chat_send(gd->chat, buf, none_prefix,
+					mbm_e2gpsctl_cb, cbd, g_free) > 0)
+		return;
+
+	/* error */
+	CALLBACK_WITH_FAILURE(cb, data);
+	g_free(cbd);
+}
+
+static void mbm_gps_support_cb(gboolean ok, GAtResult *result, gpointer user_data)
+{
+	struct ofono_gps *gps = user_data;
+
+	if (!ok)
+		return;
+
+	ofono_gps_register(gps);
+}
+
+static int mbm_gps_probe(struct ofono_gps *g,
+					unsigned int vendor, void *data)
+{
+	GAtChat *chat = data;
+	struct gps_data *gd;
+
+	gd = g_try_new0(struct gps_data, 1);
+	if (gd == NULL)
+		return -ENOMEM;
+
+	gd->chat = g_at_chat_clone(chat);
+
+	ofono_gps_set_data(g, gd);
+
+	g_at_chat_send(gd->chat, "AT*E2GPSCTL=?", e2gpsctl_prefix,
+					mbm_gps_support_cb, g, NULL);
+
+	return 0;
+}
+
+static void mbm_gps_remove(struct ofono_gps *g)
+{
+	struct gps_data *gd = ofono_gps_get_data(g);
+
+	ofono_gps_set_data(g, NULL);
+
+	g_at_chat_unref(gd->chat);
+	g_free(gd);
+}
+
+static struct ofono_gps_driver driver = {
+	.name			= "mbmmodem",
+	.probe			= mbm_gps_probe,
+	.remove			= mbm_gps_remove,
+	.query_gps		= mbm_query_gps,
+	.set_gps		= mbm_set_gps
+};
+
+void mbm_gps_init()
+{
+	ofono_gps_driver_register(&driver);
+}
+
+void mbm_gps_exit()
+{
+	ofono_gps_driver_unregister(&driver);
+}
diff --git a/drivers/mbmmodem/mbmmodem.c b/drivers/mbmmodem/mbmmodem.c
index 03b61b3..ea56cd4 100644
--- a/drivers/mbmmodem/mbmmodem.c
+++ b/drivers/mbmmodem/mbmmodem.c
@@ -36,12 +36,14 @@ static int mbmmodem_init(void)
 {
 	mbm_gprs_context_init();
 	mbm_stk_init();
+	mbm_gps_init();
 
 	return 0;
 }
 
 static void mbmmodem_exit(void)
 {
+	mbm_gps_exit();
 	mbm_stk_exit();
 	mbm_gprs_context_exit();
 }
diff --git a/drivers/mbmmodem/mbmmodem.h b/drivers/mbmmodem/mbmmodem.h
index 65786d7..d1e96fa 100644
--- a/drivers/mbmmodem/mbmmodem.h
+++ b/drivers/mbmmodem/mbmmodem.h
@@ -26,3 +26,6 @@ extern void mbm_gprs_context_exit();
 
 extern void mbm_stk_init();
 extern void mbm_stk_exit();
+
+extern void mbm_gps_init();
+extern void mbm_gps_exit();
-- 
1.7.2.3


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

* [PATCH 6/8] plugins: add gps atom to mbm
  2010-12-16 20:30 [PATCH 0/8] Add GPS atom Rafael Ignacio Zurita
                   ` (4 preceding siblings ...)
  2010-12-16 20:30 ` [PATCH 5/8] mbmmodem: add gps atom Rafael Ignacio Zurita
@ 2010-12-16 20:30 ` Rafael Ignacio Zurita
  2010-12-22 21:58   ` Denis Kenzior
  2010-12-16 20:30 ` [PATCH 7/8] plugins/udev.c: add gps comparison for add_mbm registered modem Rafael Ignacio Zurita
  2010-12-16 20:30 ` [PATCH 8/8] gps: add documentation Rafael Ignacio Zurita
  7 siblings, 1 reply; 14+ messages in thread
From: Rafael Ignacio Zurita @ 2010-12-16 20:30 UTC (permalink / raw)
  To: ofono

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

---
 plugins/mbm.c |   30 ++++++++++++++++++++++++++++--
 1 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/plugins/mbm.c b/plugins/mbm.c
index 62e3ae1..60681df 100644
--- a/plugins/mbm.c
+++ b/plugins/mbm.c
@@ -45,6 +45,7 @@
 #include <ofono/gprs.h>
 #include <ofono/gprs-context.h>
 #include <ofono/log.h>
+#include <ofono/gps.h>
 
 #include <drivers/atmodem/atutil.h>
 #include <drivers/atmodem/vendor.h>
@@ -61,11 +62,13 @@ enum mbm_variant {
 struct mbm_data {
 	GAtChat *modem_port;
 	GAtChat *data_port;
+	GAtChat *gps_port;
 	guint cpin_poll_source;
 	guint cpin_poll_count;
 	gboolean have_sim;
 	struct ofono_gprs *gprs;
 	struct ofono_gprs_context *gc;
+	struct ofono_gps *gps;
 	guint reopen_source;
 	enum mbm_variant variant;
 };
@@ -93,6 +96,7 @@ static void mbm_remove(struct ofono_modem *modem)
 
 	ofono_modem_set_data(modem, NULL);
 
+	g_at_chat_unref(data->gps_port);
 	g_at_chat_unref(data->data_port);
 	g_at_chat_unref(data->modem_port);
 
@@ -354,15 +358,17 @@ static int mbm_enable(struct ofono_modem *modem)
 	struct mbm_data *data = ofono_modem_get_data(modem);
 	const char *modem_dev;
 	const char *data_dev;
+	const char *gps_dev;
 
 	DBG("%p", modem);
 
 	modem_dev = ofono_modem_get_string(modem, "ModemDevice");
 	data_dev = ofono_modem_get_string(modem, "DataDevice");
+	gps_dev = ofono_modem_get_string(modem, "GPSDevice");
 
-	DBG("%s, %s", modem_dev, data_dev);
+	DBG("%s, %s, %s", modem_dev, data_dev, gps_dev);
 
-	if (modem_dev == NULL || data_dev == NULL)
+	if (modem_dev == NULL || data_dev == NULL || gps_dev == NULL)
 		return -EINVAL;
 
 	data->modem_port = create_port(modem_dev);
@@ -383,6 +389,20 @@ static int mbm_enable(struct ofono_modem *modem)
 	if (getenv("OFONO_AT_DEBUG"))
 		g_at_chat_set_debug(data->data_port, mbm_debug, "Data: ");
 
+	data->gps_port = create_port(gps_dev);
+	if (data->gps_port == NULL) {
+		g_at_chat_unref(data->data_port);
+		data->data_port = NULL;
+
+		g_at_chat_unref(data->modem_port);
+		data->modem_port = NULL;
+
+		return -EIO;
+	}
+
+	if (getenv("OFONO_AT_DEBUG"))
+		g_at_chat_set_debug(data->gps_port, mbm_debug, "GPS: ");
+
 	g_at_chat_set_disconnect_function(data->data_port,
 						mbm_disconnect, modem);
 
@@ -415,6 +435,9 @@ static void cfun_disable(gboolean ok, GAtResult *result, gpointer user_data)
 	g_at_chat_unref(data->data_port);
 	data->data_port = NULL;
 
+	g_at_chat_unref(data->gps_port);
+	data->gps_port = NULL;
+
 	if (ok)
 		ofono_modem_set_powered(modem, FALSE);
 }
@@ -541,6 +564,9 @@ static void mbm_post_online(struct ofono_modem *modem)
 					OFONO_GPRS_CONTEXT_TYPE_MMS);
 		ofono_gprs_add_context(data->gprs, data->gc);
 	}
+
+	data->gps = ofono_gps_create(modem, 0,
+					"mbmmodem", data->gps_port);
 }
 
 static struct ofono_modem_driver mbm_driver = {
-- 
1.7.2.3


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

* [PATCH 7/8] plugins/udev.c: add gps comparison for add_mbm registered modem
  2010-12-16 20:30 [PATCH 0/8] Add GPS atom Rafael Ignacio Zurita
                   ` (5 preceding siblings ...)
  2010-12-16 20:30 ` [PATCH 6/8] plugins: add gps atom to mbm Rafael Ignacio Zurita
@ 2010-12-16 20:30 ` Rafael Ignacio Zurita
  2010-12-16 20:30 ` [PATCH 8/8] gps: add documentation Rafael Ignacio Zurita
  7 siblings, 0 replies; 14+ messages in thread
From: Rafael Ignacio Zurita @ 2010-12-16 20:30 UTC (permalink / raw)
  To: ofono

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

---
 plugins/udev.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/plugins/udev.c b/plugins/udev.c
index 255755e..99b500a 100644
--- a/plugins/udev.c
+++ b/plugins/udev.c
@@ -105,7 +105,7 @@ static void add_mbm(struct ofono_modem *modem,
 					struct udev_device *udev_device)
 {
 	const char *desc, *devnode;
-	const char *device, *data, *network;
+	const char *device, *data, *network, *gps;
 	int registered;
 
 	desc = udev_device_get_sysattr_value(udev_device, "device/interface");
@@ -152,8 +152,9 @@ static void add_mbm(struct ofono_modem *modem,
 	device  = ofono_modem_get_string(modem, MODEM_DEVICE);
 	data = ofono_modem_get_string(modem, DATA_DEVICE);
 	network = ofono_modem_get_string(modem, NETWORK_INTERFACE);
+	gps = ofono_modem_get_string(modem, GPS_DEVICE);
 
-	if (device != NULL && data != NULL && network != NULL) {
+	if (device != NULL && data != NULL && network != NULL && gps != NULL) {
 		ofono_modem_set_integer(modem, "Registered", 1);
 		ofono_modem_register(modem);
 	}
-- 
1.7.2.3


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

* [PATCH 8/8] gps: add documentation
  2010-12-16 20:30 [PATCH 0/8] Add GPS atom Rafael Ignacio Zurita
                   ` (6 preceding siblings ...)
  2010-12-16 20:30 ` [PATCH 7/8] plugins/udev.c: add gps comparison for add_mbm registered modem Rafael Ignacio Zurita
@ 2010-12-16 20:30 ` Rafael Ignacio Zurita
  2010-12-22 22:02   ` Denis Kenzior
  7 siblings, 1 reply; 14+ messages in thread
From: Rafael Ignacio Zurita @ 2010-12-16 20:30 UTC (permalink / raw)
  To: ofono

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

---
 Makefile.am     |    3 ++-
 doc/gps-api.txt |   41 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 43 insertions(+), 1 deletions(-)
 create mode 100644 doc/gps-api.txt

diff --git a/Makefile.am b/Makefile.am
index 4b8cb51..a8ad097 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -359,7 +359,8 @@ doc_files = doc/overview.txt doc/ofono-paper.txt doc/release-faq.txt \
 			doc/message-api.txt doc/message-waiting-api.txt \
 			doc/phonebook-api.txt doc/radio-settings-api.txt \
 			doc/sim-api.txt doc/stk-api.txt \
-			doc/audio-settings-api.txt doc/text-telephony-api.txt
+			doc/audio-settings-api.txt doc/text-telephony-api.txt \
+			doc/gps-api.txt
 
 
 test_scripts = test/backtrace \
diff --git a/doc/gps-api.txt b/doc/gps-api.txt
new file mode 100644
index 0000000..e9238a8
--- /dev/null
+++ b/doc/gps-api.txt
@@ -0,0 +1,41 @@
+GPS hierarchy
+=============
+
+Service		org.ofono
+Interface	org.ofono.Gps
+Object path	[variable prefix]/{modem0,modem1,...}
+
+Methods		dict GetProperties()
+
+			Returns all Gps properties. See the
+			properties section for available properties.
+
+			Possible Errors: [service].Error.InProgress
+					 [service].Error.Failed
+
+		void SetProperty(string name, variant value)
+
+			Changes the value of the specified property. Only
+			properties that are listed as read-write are
+			changeable. On success a PropertyChanged signal
+			will be emitted.
+
+			Possible Errors: [service].Error.InvalidArguments
+					 [service].Error.InProgress
+					 [service].Error.Failed
+
+Signals		PropertyChanged(string property, variant value)
+
+			This signal indicates a changed value of the given
+			property.
+
+Properties	boolean	Powered [readwrite]
+
+			This property will power or disable the GPS feature in
+			the modem.
+
+			Many modem manufacturers provide a GPS unit with their
+			modem hardware. This unit can be turned on or off and
+			frequently takes over one of the tty ports that the
+			modem provides.
+
-- 
1.7.2.3


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

* Re: [PATCH 1/8] gps: define new dbus interface
  2010-12-16 20:30 ` [PATCH 1/8] gps: define new dbus interface Rafael Ignacio Zurita
@ 2010-12-22 21:45   ` Denis Kenzior
  0 siblings, 0 replies; 14+ messages in thread
From: Denis Kenzior @ 2010-12-22 21:45 UTC (permalink / raw)
  To: ofono

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

Hi Rafael,

On 12/16/2010 02:30 PM, Rafael Ignacio Zurita wrote:
> ---
>  include/dbus.h |    1 +
>  1 files changed, 1 insertions(+), 0 deletions(-)
> 
> diff --git a/include/dbus.h b/include/dbus.h
> index 9e29afb..48e8ac4 100644
> --- a/include/dbus.h
> +++ b/include/dbus.h
> @@ -54,6 +54,7 @@ extern "C" {
>  #define OFONO_VOICECALL_MANAGER_INTERFACE "org.ofono.VoiceCallManager"
>  #define OFONO_STK_INTERFACE OFONO_SERVICE ".SimToolkit"
>  #define OFONO_SIM_APP_INTERFACE OFONO_SERVICE ".SimToolkitAgent"
> +#define OFONO_GPS_INTERFACE OFONO_SERVICE ".Gps"

Please name this 'LocationReporting'

Regards,
-Denis

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

* Re: [PATCH 3/8] gps: add public header
  2010-12-16 20:30 ` [PATCH 3/8] gps: add public header Rafael Ignacio Zurita
@ 2010-12-22 21:53   ` Denis Kenzior
  0 siblings, 0 replies; 14+ messages in thread
From: Denis Kenzior @ 2010-12-22 21:53 UTC (permalink / raw)
  To: ofono

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

Hi Rafael,

<snip>

> +struct ofono_gps_driver {
> +	const char *name;
> +	int (*probe)(struct ofono_gps *gps, unsigned int vendor, void *data);
> +	void (*remove)(struct ofono_gps *gps);
> +	void (*set_gps)(struct ofono_gps *gps, ofono_bool_t enable,
> +				ofono_gps_set_cb_t, void *data);

I would suggest breaking this up into enable and disable methods.  With
the enable providing additional information to the core, namely:

- NMEA / whatever device node to use
- type of the device

For the type information I suggest defining an enum with the possible
types.  Right now nmea is probably the only thing we want to support...

> +	void (*query_gps)(struct ofono_gps *gps, ofono_gps_query_cb_t cb,
> +				void *data);

I'm currently not sure this query function is really needed.  I think we
should just assume that the gps device is always powered=false when the
atom is created.

Regards,
-Denis

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

* Re: [PATCH 6/8] plugins: add gps atom to mbm
  2010-12-16 20:30 ` [PATCH 6/8] plugins: add gps atom to mbm Rafael Ignacio Zurita
@ 2010-12-22 21:58   ` Denis Kenzior
  2010-12-27 10:17     ` Rafael Ignacio Zurita
  0 siblings, 1 reply; 14+ messages in thread
From: Denis Kenzior @ 2010-12-22 21:58 UTC (permalink / raw)
  To: ofono

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

Hi Rafael,

>  
> -	if (modem_dev == NULL || data_dev == NULL)
> +	if (modem_dev == NULL || data_dev == NULL || gps_dev == NULL)
>  		return -EINVAL;

I don't think that failing because the gps device isn't set is such a
good idea.  There might be mbm cards without a gps node.  Let udev
autodetection handle this part.

>  
>  	data->modem_port = create_port(modem_dev);
> @@ -383,6 +389,20 @@ static int mbm_enable(struct ofono_modem *modem)
>  	if (getenv("OFONO_AT_DEBUG"))
>  		g_at_chat_set_debug(data->data_port, mbm_debug, "Data: ");
>  
> +	data->gps_port = create_port(gps_dev);
> +	if (data->gps_port == NULL) {
> +		g_at_chat_unref(data->data_port);
> +		data->data_port = NULL;
> +
> +		g_at_chat_unref(data->modem_port);
> +		data->modem_port = NULL;
> +
> +		return -EIO;
> +	}

So from what I understand we have to send AT*E2GPSNPD to the GPS port in
order to turn it from a regular AT command port into a GPS port.  At
this point this port is no longer usable for AT commands.  Right?

> +
> +	if (getenv("OFONO_AT_DEBUG"))
> +		g_at_chat_set_debug(data->gps_port, mbm_debug, "GPS: ");
> +
>  	g_at_chat_set_disconnect_function(data->data_port,
>  						mbm_disconnect, modem);
>  
> @@ -415,6 +435,9 @@ static void cfun_disable(gboolean ok, GAtResult *result, gpointer user_data)
>  	g_at_chat_unref(data->data_port);
>  	data->data_port = NULL;
>  
> +	g_at_chat_unref(data->gps_port);
> +	data->gps_port = NULL;
> +
>  	if (ok)
>  		ofono_modem_set_powered(modem, FALSE);
>  }
> @@ -541,6 +564,9 @@ static void mbm_post_online(struct ofono_modem *modem)
>  					OFONO_GPRS_CONTEXT_TYPE_MMS);
>  		ofono_gprs_add_context(data->gprs, data->gc);
>  	}
> +
> +	data->gps = ofono_gps_create(modem, 0,
> +					"mbmmodem", data->gps_port);

If my previous comment is correct, then the gps driver should be running
on the dev port, not on the gps port.

>  }
>  
>  static struct ofono_modem_driver mbm_driver = {

Regards,
-Denis

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

* Re: [PATCH 8/8] gps: add documentation
  2010-12-16 20:30 ` [PATCH 8/8] gps: add documentation Rafael Ignacio Zurita
@ 2010-12-22 22:02   ` Denis Kenzior
  0 siblings, 0 replies; 14+ messages in thread
From: Denis Kenzior @ 2010-12-22 22:02 UTC (permalink / raw)
  To: ofono

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

Hi Rafael,

On 12/16/2010 02:30 PM, Rafael Ignacio Zurita wrote:
> ---
>  Makefile.am     |    3 ++-
>  doc/gps-api.txt |   41 +++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 43 insertions(+), 1 deletions(-)
>  create mode 100644 doc/gps-api.txt
> 
> diff --git a/Makefile.am b/Makefile.am
> index 4b8cb51..a8ad097 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -359,7 +359,8 @@ doc_files = doc/overview.txt doc/ofono-paper.txt doc/release-faq.txt \
>  			doc/message-api.txt doc/message-waiting-api.txt \
>  			doc/phonebook-api.txt doc/radio-settings-api.txt \
>  			doc/sim-api.txt doc/stk-api.txt \
> -			doc/audio-settings-api.txt doc/text-telephony-api.txt
> +			doc/audio-settings-api.txt doc/text-telephony-api.txt \
> +			doc/gps-api.txt
>  
>  
>  test_scripts = test/backtrace \
> diff --git a/doc/gps-api.txt b/doc/gps-api.txt
> new file mode 100644
> index 0000000..e9238a8
> --- /dev/null
> +++ b/doc/gps-api.txt
> @@ -0,0 +1,41 @@
> +GPS hierarchy
> +=============
> +
> +Service		org.ofono
> +Interface	org.ofono.Gps

As mentioned previously, lets make the Interface
org.ofono.LocationReporting.

> +Object path	[variable prefix]/{modem0,modem1,...}
> +
> +Methods		dict GetProperties()
> +
> +			Returns all Gps properties. See the
> +			properties section for available properties.
> +
> +			Possible Errors: [service].Error.InProgress
> +					 [service].Error.Failed
> +
> +		void SetProperty(string name, variant value)
> +
> +			Changes the value of the specified property. Only
> +			properties that are listed as read-write are
> +			changeable. On success a PropertyChanged signal
> +			will be emitted.
> +
> +			Possible Errors: [service].Error.InvalidArguments
> +					 [service].Error.InProgress
> +					 [service].Error.Failed
> +
> +Signals		PropertyChanged(string property, variant value)
> +
> +			This signal indicates a changed value of the given
> +			property.
> +
> +Properties	boolean	Powered [readwrite]
> +
> +			This property will power or disable the GPS feature in
> +			the modem.
> +
> +			Many modem manufacturers provide a GPS unit with their
> +			modem hardware. This unit can be turned on or off and
> +			frequently takes over one of the tty ports that the
> +			modem provides.
> +

I think we need two additional properties here:

string Device [readonly]
	The device which can be used to obtain the location information

string Type [readonly]
	The type of the device (e.g. nmea)

One thing we can do here is stuff them inside a Settings dictionary
property that is emitted once Powered=True.  This is similar to how
org.ofono.ConnectionContext is implemented.

Regards,
-Denis

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

* Re: [PATCH 6/8] plugins: add gps atom to mbm
  2010-12-22 21:58   ` Denis Kenzior
@ 2010-12-27 10:17     ` Rafael Ignacio Zurita
  0 siblings, 0 replies; 14+ messages in thread
From: Rafael Ignacio Zurita @ 2010-12-27 10:17 UTC (permalink / raw)
  To: ofono

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

Hi Denis,

On Wed, Dec 22, 2010 at 03:58:53PM -0600, Denis Kenzior wrote:
> Hi Rafael,
> 
> >  
> > -	if (modem_dev == NULL || data_dev == NULL)
> > +	if (modem_dev == NULL || data_dev == NULL || gps_dev == NULL)
> >  		return -EINVAL;
> 
> I don't think that failing because the gps device isn't set is such a
> good idea.  There might be mbm cards without a gps node.  Let udev
> autodetection handle this part.

Okey.

> >  
> >  	data->modem_port = create_port(modem_dev);
> > @@ -383,6 +389,20 @@ static int mbm_enable(struct ofono_modem *modem)
> >  	if (getenv("OFONO_AT_DEBUG"))
> >  		g_at_chat_set_debug(data->data_port, mbm_debug, "Data: ");
> >  
> > +	data->gps_port = create_port(gps_dev);
> > +	if (data->gps_port == NULL) {
> > +		g_at_chat_unref(data->data_port);
> > +		data->data_port = NULL;
> > +
> > +		g_at_chat_unref(data->modem_port);
> > +		data->modem_port = NULL;
> > +
> > +		return -EIO;
> > +	}
> 
> So from what I understand we have to send AT*E2GPSNPD to the GPS port in
> order to turn it from a regular AT command port into a GPS port.  At
> this point this port is no longer usable for AT commands.  Right?

Yes, you are right. From what I read the only way for freeing this port would
be reseting the whole module.

> > +
> > +	if (getenv("OFONO_AT_DEBUG"))
> > +		g_at_chat_set_debug(data->gps_port, mbm_debug, "GPS: ");
> > +
> >  	g_at_chat_set_disconnect_function(data->data_port,
> >  						mbm_disconnect, modem);
> >  
> > @@ -415,6 +435,9 @@ static void cfun_disable(gboolean ok, GAtResult *result, gpointer user_data)
> >  	g_at_chat_unref(data->data_port);
> >  	data->data_port = NULL;
> >  
> > +	g_at_chat_unref(data->gps_port);
> > +	data->gps_port = NULL;
> > +
> >  	if (ok)
> >  		ofono_modem_set_powered(modem, FALSE);
> >  }
> > @@ -541,6 +564,9 @@ static void mbm_post_online(struct ofono_modem *modem)
> >  					OFONO_GPRS_CONTEXT_TYPE_MMS);
> >  		ofono_gprs_add_context(data->gprs, data->gc);
> >  	}
> > +
> > +	data->gps = ofono_gps_create(modem, 0,
> > +					"mbmmodem", data->gps_port);
> 
> If my previous comment is correct, then the gps driver should be running
> on the dev port, not on the gps port.

I will fix this. 

I am working on a new version of this gps task based on your comments and
suggestions. Thanks a lot for the review. 

Rafael

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

end of thread, other threads:[~2010-12-27 10:17 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-16 20:30 [PATCH 0/8] Add GPS atom Rafael Ignacio Zurita
2010-12-16 20:30 ` [PATCH 1/8] gps: define new dbus interface Rafael Ignacio Zurita
2010-12-22 21:45   ` Denis Kenzior
2010-12-16 20:30 ` [PATCH 2/8] gps: add new interface to feature map Rafael Ignacio Zurita
2010-12-16 20:30 ` [PATCH 3/8] gps: add public header Rafael Ignacio Zurita
2010-12-22 21:53   ` Denis Kenzior
2010-12-16 20:30 ` [PATCH 4/8] gps: implement interface/atom Rafael Ignacio Zurita
2010-12-16 20:30 ` [PATCH 5/8] mbmmodem: add gps atom Rafael Ignacio Zurita
2010-12-16 20:30 ` [PATCH 6/8] plugins: add gps atom to mbm Rafael Ignacio Zurita
2010-12-22 21:58   ` Denis Kenzior
2010-12-27 10:17     ` Rafael Ignacio Zurita
2010-12-16 20:30 ` [PATCH 7/8] plugins/udev.c: add gps comparison for add_mbm registered modem Rafael Ignacio Zurita
2010-12-16 20:30 ` [PATCH 8/8] gps: add documentation Rafael Ignacio Zurita
2010-12-22 22:02   ` 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.