* [PATCH 01/12] dbus: add gnss interface definition
2011-03-24 13:46 [PATCH 00/12] Basic E911 support Jarko Poutiainen
@ 2011-03-24 13:46 ` Jarko Poutiainen
2011-03-24 13:46 ` [PATCH 02/12] include: add gnss.h file Jarko Poutiainen
` (11 subsequent siblings)
12 siblings, 0 replies; 18+ messages in thread
From: Jarko Poutiainen @ 2011-03-24 13:46 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 718 bytes --]
---
include/dbus.h | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/include/dbus.h b/include/dbus.h
index 38864fb..4dd9db5 100644
--- a/include/dbus.h
+++ b/include/dbus.h
@@ -56,6 +56,8 @@ extern "C" {
#define OFONO_STK_INTERFACE OFONO_SERVICE ".SimToolkit"
#define OFONO_SIM_APP_INTERFACE OFONO_SERVICE ".SimToolkitAgent"
#define OFONO_LOCATION_REPORTING_INTERFACE OFONO_SERVICE ".LocationReporting"
+#define OFONO_GNSS_INTERFACE "org.ofono.AssistedSatelliteNavigation"
+#define OFONO_GNSS_POSR_AGENT_INTERFACE "org.ofono.PositioningRequestAgent"
/* CDMA Interfaces */
#define OFONO_CDMA_VOICECALL_MANAGER_INTERFACE "org.ofono.cdma.VoiceCallManager"
--
1.7.0.4
^ permalink raw reply related [flat|nested] 18+ messages in thread* [PATCH 02/12] include: add gnss.h file
2011-03-24 13:46 [PATCH 00/12] Basic E911 support Jarko Poutiainen
2011-03-24 13:46 ` [PATCH 01/12] dbus: add gnss interface definition Jarko Poutiainen
@ 2011-03-24 13:46 ` Jarko Poutiainen
2011-03-24 13:46 ` [PATCH 03/12] src: add atom type for gnss Jarko Poutiainen
` (10 subsequent siblings)
12 siblings, 0 replies; 18+ messages in thread
From: Jarko Poutiainen @ 2011-03-24 13:46 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 3078 bytes --]
---
Makefile.am | 3 +-
include/gnss.h | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 71 insertions(+), 1 deletions(-)
create mode 100644 include/gnss.h
diff --git a/Makefile.am b/Makefile.am
index b0cbcd7..bff2374 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -16,7 +16,8 @@ pkginclude_HEADERS = include/log.h include/plugin.h include/history.h \
include/cdma-sms.h include/sim-auth.h \
include/gprs-provision.h include/emulator.h \
include/location-reporting.h \
- include/cdma-connman.h
+ include/cdma-connman.h \
+ include/gnss.h
nodist_pkginclude_HEADERS = include/version.h
diff --git a/include/gnss.h b/include/gnss.h
new file mode 100644
index 0000000..c8ff310
--- /dev/null
+++ b/include/gnss.h
@@ -0,0 +1,69 @@
+/*
+ *
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 2008-2010 Intel Corporation. All rights reserved.
+ * Copyright (C) 2011 ST-Ericsson AB.
+ *
+ * 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_GNSS_H
+#define __OFONO_GNSS_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <ofono/types.h>
+
+struct ofono_gnss;
+
+typedef void (*ofono_gnss_cb_t)(const struct ofono_error *error, void *data);
+
+struct ofono_gnss_driver {
+ const char *name;
+ int (*probe)(struct ofono_gnss *gnss, unsigned int vendor, void *data);
+ void (*remove)(struct ofono_gnss *gnss);
+ void (*send_element)(struct ofono_gnss *gnss,
+ const char *xml,
+ ofono_gnss_cb_t cb, void *data);
+ void (*set_position_reporting)(struct ofono_gnss *gnss,
+ ofono_bool_t enable,
+ ofono_gnss_cb_t cb,
+ void *data);
+};
+
+void ofono_gnss_notify_posr_request(struct ofono_gnss *gnss, const char *xml);
+void ofono_gnss_notify_posr_reset(struct ofono_gnss *gnss);
+int ofono_gnss_driver_register(const struct ofono_gnss_driver *d);
+void ofono_gnss_driver_unregister(const struct ofono_gnss_driver *d);
+
+struct ofono_gnss *ofono_gnss_create(struct ofono_modem *modem,
+ unsigned int vendor,
+ const char *driver, void *data);
+
+void ofono_gnss_register(struct ofono_gnss *gnss);
+void ofono_gnss_remove(struct ofono_gnss *gnss);
+
+void ofono_gnss_set_data(struct ofono_gnss *gnss, void *data);
+void *ofono_gnss_get_data(struct ofono_gnss *gnss);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __OFONO_GNSS_H */
--
1.7.0.4
^ permalink raw reply related [flat|nested] 18+ messages in thread* [PATCH 03/12] src: add atom type for gnss
2011-03-24 13:46 [PATCH 00/12] Basic E911 support Jarko Poutiainen
2011-03-24 13:46 ` [PATCH 01/12] dbus: add gnss interface definition Jarko Poutiainen
2011-03-24 13:46 ` [PATCH 02/12] include: add gnss.h file Jarko Poutiainen
@ 2011-03-24 13:46 ` Jarko Poutiainen
2011-03-24 13:46 ` [PATCH 04/12] src: add gnss atom and agent implementation Jarko Poutiainen
` (9 subsequent siblings)
12 siblings, 0 replies; 18+ messages in thread
From: Jarko Poutiainen @ 2011-03-24 13:46 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 566 bytes --]
---
src/ofono.h | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/src/ofono.h b/src/ofono.h
index b9ca314..81570fe 100644
--- a/src/ofono.h
+++ b/src/ofono.h
@@ -132,6 +132,7 @@ enum ofono_atom_type {
OFONO_ATOM_TYPE_EMULATOR_DUN,
OFONO_ATOM_TYPE_EMULATOR_HFP,
OFONO_ATOM_TYPE_LOCATION_REPORTING,
+ OFONO_ATOM_TYPE_GNSS,
};
enum ofono_atom_watch_condition {
@@ -454,3 +455,4 @@ void __ofono_gprs_provision_free_settings(
int count);
#include <ofono/emulator.h>
+#include <ofono/gnss.h>
--
1.7.0.4
^ permalink raw reply related [flat|nested] 18+ messages in thread* [PATCH 04/12] src: add gnss atom and agent implementation
2011-03-24 13:46 [PATCH 00/12] Basic E911 support Jarko Poutiainen
` (2 preceding siblings ...)
2011-03-24 13:46 ` [PATCH 03/12] src: add atom type for gnss Jarko Poutiainen
@ 2011-03-24 13:46 ` Jarko Poutiainen
2011-03-24 13:46 ` [PATCH 05/12] gatchat: introduce send for +CPOS Jarko Poutiainen
` (8 subsequent siblings)
12 siblings, 0 replies; 18+ messages in thread
From: Jarko Poutiainen @ 2011-03-24 13:46 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 16848 bytes --]
---
Makefile.am | 3 +-
src/gnss.c | 386 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/gnssagent.c | 158 +++++++++++++++++++++++
src/gnssagent.h | 43 ++++++
4 files changed, 589 insertions(+), 1 deletions(-)
create mode 100644 src/gnss.c
create mode 100644 src/gnssagent.c
create mode 100644 src/gnssagent.h
diff --git a/Makefile.am b/Makefile.am
index bff2374..8d127af 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -385,7 +385,8 @@ src_ofonod_SOURCES = $(gdbus_sources) $(builtin_sources) src/ofono.ver \
src/cdma-voicecall.c src/sim-auth.c \
src/message.h src/message.c src/gprs-provision.c \
src/emulator.c src/location-reporting.c \
- src/cdma-connman.c
+ src/cdma-connman.c src/gnss.c \
+ src/gnssagent.c src/gnssagent.h
src_ofonod_LDADD = $(builtin_libadd) @GLIB_LIBS@ @DBUS_LIBS@ @CAPNG_LIBS@ -ldl
diff --git a/src/gnss.c b/src/gnss.c
new file mode 100644
index 0000000..e0c17e6
--- /dev/null
+++ b/src/gnss.c
@@ -0,0 +1,386 @@
+/*
+ *
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 2008-2010 Intel Corporation. All rights reserved.
+ * Copyright (C) 2011 ST-Ericsson AB.
+ *
+ * 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 <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+
+#include <glib.h>
+#include <gdbus.h>
+#include <errno.h>
+
+#include "ofono.h"
+
+#include "common.h"
+#include "gnssagent.h"
+
+static GSList *g_drivers = NULL;
+
+struct ofono_gnss {
+ const struct ofono_gnss_driver *driver;
+ void *driver_data;
+ struct ofono_atom *atom;
+ DBusMessage *pending;
+ struct gnss_agent *posr_agent;
+ ofono_bool_t enabled;
+};
+
+static void gnss_unregister_agent_cb(const struct ofono_error *error,
+ void *data)
+{
+ DBusMessage *reply;
+ struct ofono_gnss *gnss = data;
+
+ DBG("");
+
+ if (error->type != OFONO_ERROR_TYPE_NO_ERROR) {
+ ofono_error("Disabling Location Reporting Failed");
+ reply = __ofono_error_failed(gnss->pending);
+ __ofono_dbus_pending_reply(&gnss->pending, reply);
+ return;
+ }
+
+ gnss->enabled = FALSE;
+
+ if (gnss->posr_agent)
+ gnss_agent_free(gnss->posr_agent);
+
+ if (gnss->posr_agent) {
+ ofono_error("Releasing agent failed");
+ reply = __ofono_error_failed(gnss->pending);
+ __ofono_dbus_pending_reply(&gnss->pending, reply);
+ return;
+ }
+
+ if (gnss->pending) {
+ reply = dbus_message_new_method_return(gnss->pending);
+ __ofono_dbus_pending_reply(&gnss->pending, reply);
+ }
+}
+
+static void gnss_register_agent_cb(const struct ofono_error *error,
+ void *data)
+{
+ DBusMessage *reply;
+ struct ofono_gnss *gnss = data;
+
+ DBG("");
+
+ if (error->type != OFONO_ERROR_TYPE_NO_ERROR) {
+ ofono_error("Enabling Location Reporting Failed");
+ reply = __ofono_error_failed(gnss->pending);
+
+ if (gnss->posr_agent)
+ gnss_agent_free(gnss->posr_agent);
+
+ __ofono_dbus_pending_reply(&gnss->pending, reply);
+ return;
+ }
+
+ if (gnss->posr_agent) {
+ gnss->enabled = TRUE;
+ reply = dbus_message_new_method_return(gnss->pending);
+ __ofono_dbus_pending_reply(&gnss->pending, reply);
+ } else
+ gnss->driver->set_position_reporting(gnss, FALSE,
+ gnss_unregister_agent_cb,
+ gnss);
+}
+
+static void gnss_agent_notify(gpointer user_data)
+{
+ struct ofono_gnss *gnss = user_data;
+
+ if (gnss->enabled)
+ gnss->driver->set_position_reporting(gnss, FALSE,
+ gnss_unregister_agent_cb,
+ gnss);
+
+ gnss->posr_agent = NULL;
+}
+
+static DBusMessage *gnss_register_agent(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+{
+ struct ofono_gnss *gnss = data;
+ const char *agent_path;
+
+ if (gnss->pending)
+ return __ofono_error_busy(msg);
+
+ if (gnss->posr_agent)
+ return __ofono_error_busy(msg);
+
+ if (dbus_message_get_args(msg, NULL, DBUS_TYPE_OBJECT_PATH,
+ &agent_path, DBUS_TYPE_INVALID) == FALSE)
+ return __ofono_error_invalid_args(msg);
+
+ if (!__ofono_dbus_valid_object_path(agent_path))
+ return __ofono_error_invalid_format(msg);
+
+ gnss->posr_agent = gnss_agent_new(agent_path,
+ dbus_message_get_sender(msg),
+ FALSE);
+
+ if (gnss->posr_agent == NULL)
+ return __ofono_error_failed(msg);
+
+ gnss->enabled = FALSE;
+
+ gnss_agent_set_removed_notify(gnss->posr_agent,
+ gnss_agent_notify, gnss);
+
+ gnss->driver->set_position_reporting(gnss, TRUE, gnss_register_agent_cb,
+ gnss);
+
+ gnss->pending = dbus_message_ref(msg);
+
+ return NULL;
+}
+
+static DBusMessage *gnss_unregister_agent(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+{
+ struct ofono_gnss *gnss = data;
+ const char *agent_path;
+ const char *agent_bus = dbus_message_get_sender(msg);
+
+ if (gnss->pending)
+ return __ofono_error_busy(msg);
+
+ if (dbus_message_get_args(msg, NULL,
+ DBUS_TYPE_OBJECT_PATH, &agent_path,
+ DBUS_TYPE_INVALID) == FALSE)
+ return __ofono_error_invalid_args(msg);
+
+ if (gnss->posr_agent == NULL)
+ return __ofono_error_failed(msg);
+
+ if (!gnss_agent_matches(gnss->posr_agent, agent_path, agent_bus))
+ return __ofono_error_failed(msg);
+
+ gnss->pending = dbus_message_ref(msg);
+
+ gnss->driver->set_position_reporting(gnss, FALSE,
+ gnss_unregister_agent_cb,
+ gnss);
+
+ return NULL;
+}
+
+static void gnss_send_element_cb(const struct ofono_error *error,
+ void *data)
+{
+ DBusMessage *reply;
+ struct ofono_gnss *gnss = data;
+
+ DBG("");
+
+ if (error->type != OFONO_ERROR_TYPE_NO_ERROR) {
+ ofono_error("Sending Positioning Element failed");
+
+ reply = __ofono_error_failed(gnss->pending);
+
+ goto out;
+ }
+
+ reply = dbus_message_new_method_return(gnss->pending);
+
+out:
+ __ofono_dbus_pending_reply(&gnss->pending, reply);
+}
+
+static DBusMessage *gnss_send_element(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+{
+ const char *caller = dbus_message_get_sender(msg);
+ struct ofono_gnss *gnss = data;
+ const char *xml;
+
+ DBG("");
+
+ if (gnss->pending)
+ return __ofono_error_busy(msg);
+
+ if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &xml,
+ DBUS_TYPE_INVALID))
+ return __ofono_error_invalid_args(msg);
+
+ if (!gnss_agent_sender_matches(gnss->posr_agent, caller))
+ return __ofono_error_access_denied(msg);
+
+ gnss->pending = dbus_message_ref(msg);
+
+ gnss->driver->send_element(gnss, xml, gnss_send_element_cb, gnss);
+
+ return NULL;
+}
+
+static GDBusMethodTable gnss_methods[] = {
+ { "SendPositioningElement", "s", "",
+ gnss_send_element, G_DBUS_METHOD_FLAG_ASYNC },
+ { "RegisterPositioningRequestAgent", "o", "",
+ gnss_register_agent,
+ G_DBUS_METHOD_FLAG_ASYNC },
+ { "UnregisterPositioningRequestAgent", "o", "",
+ gnss_unregister_agent,
+ G_DBUS_METHOD_FLAG_ASYNC },
+ { }
+};
+
+static void gnss_unregister(struct ofono_atom *atom)
+{
+ struct ofono_gnss *gnss = __ofono_atom_get_data(atom);
+ DBusConnection *conn = ofono_dbus_get_connection();
+ struct ofono_modem *modem = __ofono_atom_get_modem(atom);
+ const char *path = __ofono_atom_get_path(atom);
+
+ if (gnss->posr_agent)
+ gnss_agent_free(gnss->posr_agent);
+
+ ofono_modem_remove_interface(modem, OFONO_GNSS_INTERFACE);
+ g_dbus_unregister_interface(conn, path, OFONO_GNSS_INTERFACE);
+}
+
+static void gnss_remove(struct ofono_atom *atom)
+{
+ struct ofono_gnss *gnss = __ofono_atom_get_data(atom);
+
+ DBG("atom: %p", atom);
+
+ if (gnss == NULL)
+ return;
+
+ if (gnss->driver && gnss->driver->remove)
+ gnss->driver->remove(gnss);
+
+ g_free(gnss);
+}
+
+void ofono_gnss_register(struct ofono_gnss *gnss)
+{
+ DBusConnection *conn = ofono_dbus_get_connection();
+ struct ofono_modem *modem = __ofono_atom_get_modem(gnss->atom);
+ const char *path = __ofono_atom_get_path(gnss->atom);
+
+ if (!g_dbus_register_interface(conn, path,
+ OFONO_GNSS_INTERFACE,
+ gnss_methods, NULL, NULL,
+ gnss, NULL)) {
+ ofono_error("Could not create %s interface",
+ OFONO_GNSS_INTERFACE);
+
+ return;
+ }
+
+ ofono_modem_add_interface(modem, OFONO_GNSS_INTERFACE);
+
+ __ofono_atom_register(gnss->atom, gnss_unregister);
+}
+
+int ofono_gnss_driver_register(const struct ofono_gnss_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_gnss_driver_unregister(const struct ofono_gnss_driver *d)
+{
+ DBG("driver: %p, name: %s", d, d->name);
+
+ g_drivers = g_slist_remove(g_drivers, (void *) d);
+}
+
+struct ofono_gnss *ofono_gnss_create(struct ofono_modem *modem,
+ unsigned int vendor,
+ const char *driver,
+ void *data)
+{
+ struct ofono_gnss *gnss;
+ GSList *l;
+
+ if (driver == NULL)
+ return NULL;
+
+ gnss = g_try_new0(struct ofono_gnss, 1);
+
+ if (gnss == NULL)
+ return NULL;
+
+ gnss->enabled = FALSE;
+ gnss->atom = __ofono_modem_add_atom(modem, OFONO_ATOM_TYPE_GNSS,
+ gnss_remove, gnss);
+
+ for (l = g_drivers; l; l = l->next) {
+ const struct ofono_gnss_driver *drv = l->data;
+
+ if (g_strcmp0(drv->name, driver))
+ continue;
+
+ if (drv->probe(gnss, vendor, data) < 0)
+ continue;
+
+ gnss->driver = drv;
+ break;
+ }
+
+ return gnss;
+}
+
+void ofono_gnss_notify_posr_request(struct ofono_gnss *gnss, const char *xml)
+{
+ if (gnss->posr_agent)
+ gnss_agent_receive_request(gnss->posr_agent, xml);
+}
+
+void ofono_gnss_notify_posr_reset(struct ofono_gnss *gnss)
+{
+ if (gnss->posr_agent)
+ gnss_agent_receive_reset(gnss->posr_agent);
+}
+
+void ofono_gnss_remove(struct ofono_gnss *gnss)
+{
+ __ofono_atom_free(gnss->atom);
+}
+
+void ofono_gnss_set_data(struct ofono_gnss *gnss, void *data)
+{
+ gnss->driver_data = data;
+}
+
+void *ofono_gnss_get_data(struct ofono_gnss *gnss)
+{
+ return gnss->driver_data;
+}
diff --git a/src/gnssagent.c b/src/gnssagent.c
new file mode 100644
index 0000000..0db9856
--- /dev/null
+++ b/src/gnssagent.c
@@ -0,0 +1,158 @@
+/*
+ *
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 2008-2010 Intel Corporation. All rights reserved.
+ * Copyright (C) 2011 ST-Ericsson AB.
+ *
+ * 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 <stdint.h>
+#include <string.h>
+#include <errno.h>
+
+#include <glib.h>
+#include <gdbus.h>
+
+#include "ofono.h"
+#include "gnssagent.h"
+
+struct gnss_agent {
+ char *path;
+ char *bus;
+ guint disconnect_watch;
+ ofono_bool_t remove_on_terminate;
+ ofono_destroy_func removed_cb;
+ void *removed_data;
+};
+
+void gnss_agent_receive_request(struct gnss_agent *agent, const char *xml)
+{
+ DBusConnection *conn = ofono_dbus_get_connection();
+ DBusMessage *message;
+
+ message = dbus_message_new_method_call(agent->bus, agent->path,
+ OFONO_GNSS_POSR_AGENT_INTERFACE,
+ "Request");
+
+ dbus_message_append_args(message,
+ DBUS_TYPE_STRING, &xml,
+ DBUS_TYPE_INVALID);
+
+ dbus_message_set_no_reply(message, TRUE);
+
+ g_dbus_send_message(conn, message);
+}
+
+static void gnss_agent_send_noreply(struct gnss_agent *agent,
+ const char *method)
+{
+ DBusConnection *conn = ofono_dbus_get_connection();
+ DBusMessage *message;
+
+ message = dbus_message_new_method_call(agent->bus, agent->path,
+ OFONO_GNSS_POSR_AGENT_INTERFACE,
+ method);
+
+ dbus_message_set_no_reply(message, TRUE);
+
+ g_dbus_send_message(conn, message);
+}
+
+static inline void gnss_agent_send_release(struct gnss_agent *agent)
+{
+ gnss_agent_send_noreply(agent, "Release");
+}
+
+void gnss_agent_receive_reset(struct gnss_agent *agent)
+{
+ gnss_agent_send_noreply(agent, "ResetAssistanceData");
+}
+
+ofono_bool_t gnss_agent_matches(struct gnss_agent *agent,
+ const char *path, const char *sender)
+{
+ return !g_strcmp0(agent->path, path) && !g_strcmp0(agent->bus, sender);
+}
+
+ofono_bool_t gnss_agent_sender_matches(struct gnss_agent *agent,
+ const char *sender)
+{
+ return !g_strcmp0(agent->bus, sender);
+}
+
+void gnss_agent_set_removed_notify(struct gnss_agent *agent,
+ ofono_destroy_func destroy,
+ void *user_data)
+{
+ agent->removed_cb = destroy;
+ agent->removed_data = user_data;
+}
+
+void gnss_agent_free(struct gnss_agent *agent)
+{
+ DBusConnection *conn = ofono_dbus_get_connection();
+
+
+ if (agent->disconnect_watch) {
+ gnss_agent_send_release(agent);
+ g_dbus_remove_watch(conn, agent->disconnect_watch);
+ agent->disconnect_watch = 0;
+ }
+
+ if (agent->removed_cb)
+ agent->removed_cb(agent->removed_data);
+
+ g_free(agent->path);
+ g_free(agent->bus);
+ g_free(agent);
+}
+
+static void gnss_agent_disconnect_cb(DBusConnection *conn, void *user_data)
+{
+ struct gnss_agent *agent = user_data;
+
+ ofono_debug("Agent exited without calling Unregister");
+
+ agent->disconnect_watch = 0;
+
+ gnss_agent_free(agent);
+}
+
+struct gnss_agent *gnss_agent_new(const char *path, const char *sender,
+ ofono_bool_t remove_on_terminate)
+{
+ struct gnss_agent *agent = g_try_new0(struct gnss_agent, 1);
+ DBusConnection *conn = ofono_dbus_get_connection();
+
+ if (agent == NULL)
+ return NULL;
+
+ agent->path = g_strdup(path);
+ agent->bus = g_strdup(sender);
+ agent->remove_on_terminate = remove_on_terminate;
+
+ agent->disconnect_watch = g_dbus_add_disconnect_watch(conn, sender,
+ gnss_agent_disconnect_cb,
+ agent, NULL);
+
+ return agent;
+}
diff --git a/src/gnssagent.h b/src/gnssagent.h
new file mode 100644
index 0000000..b03645b
--- /dev/null
+++ b/src/gnssagent.h
@@ -0,0 +1,43 @@
+/*
+ *
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 2008-2010 Intel Corporation. All rights reserved.
+ * Copyright (C) 2011 ST-Ericsson AB.
+ *
+ * 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
+ *
+ */
+
+struct gnss_agent;
+
+
+struct gnss_agent *gnss_agent_new(const char *path, const char *sender,
+ ofono_bool_t remove_on_terminate);
+
+void gnss_agent_free(struct gnss_agent *agent);
+
+void gnss_agent_receive_request(struct gnss_agent *agent, const char *xml);
+
+void gnss_agent_receive_reset(struct gnss_agent *agent);
+
+void gnss_agent_set_removed_notify(struct gnss_agent *agent,
+ ofono_destroy_func removed_cb,
+ void *user_data);
+
+ofono_bool_t gnss_agent_matches(struct gnss_agent *agent,
+ const char *path, const char *sender);
+
+ofono_bool_t gnss_agent_sender_matches(struct gnss_agent *agent,
+ const char *sender);
--
1.7.0.4
^ permalink raw reply related [flat|nested] 18+ messages in thread* [PATCH 05/12] gatchat: introduce send for +CPOS
2011-03-24 13:46 [PATCH 00/12] Basic E911 support Jarko Poutiainen
` (3 preceding siblings ...)
2011-03-24 13:46 ` [PATCH 04/12] src: add gnss atom and agent implementation Jarko Poutiainen
@ 2011-03-24 13:46 ` Jarko Poutiainen
2011-03-24 13:46 ` [PATCH 06/12] gatchat: new hint to handle +CPOS Jarko Poutiainen
` (7 subsequent siblings)
12 siblings, 0 replies; 18+ messages in thread
From: Jarko Poutiainen @ 2011-03-24 13:46 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 836 bytes --]
---
gatchat/gatchat.h | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/gatchat/gatchat.h b/gatchat/gatchat.h
index 8cbb559..eb82daa 100644
--- a/gatchat/gatchat.h
+++ b/gatchat/gatchat.h
@@ -124,6 +124,14 @@ guint g_at_chat_send_pdu_listing(GAtChat *chat, const char *cmd,
GAtNotifyFunc listing, GAtResultFunc func,
gpointer user_data, GDestroyNotify notify);
+/*!
+ * Same as g_at_chat_send except parser will know to expect short prompt syntax
+ * used with +CPOS.
+ */
+guint g_at_chat_send_and_expect_short_prompt(GAtChat *chat, const char *cmd,
+ const char **valid_resp, GAtResultFunc func,
+ gpointer user_data, GDestroyNotify notify);
+
gboolean g_at_chat_cancel(GAtChat *chat, guint id);
gboolean g_at_chat_cancel_all(GAtChat *chat);
--
1.7.0.4
^ permalink raw reply related [flat|nested] 18+ messages in thread* [PATCH 06/12] gatchat: new hint to handle +CPOS
2011-03-24 13:46 [PATCH 00/12] Basic E911 support Jarko Poutiainen
` (4 preceding siblings ...)
2011-03-24 13:46 ` [PATCH 05/12] gatchat: introduce send for +CPOS Jarko Poutiainen
@ 2011-03-24 13:46 ` Jarko Poutiainen
2011-03-24 13:46 ` [PATCH 07/12] gatchat: implementation for +CPOS send Jarko Poutiainen
` (6 subsequent siblings)
12 siblings, 0 replies; 18+ messages in thread
From: Jarko Poutiainen @ 2011-03-24 13:46 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 529 bytes --]
---
gatchat/gatsyntax.h | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/gatchat/gatsyntax.h b/gatchat/gatsyntax.h
index afc0bd3..2580ec6 100644
--- a/gatchat/gatsyntax.h
+++ b/gatchat/gatsyntax.h
@@ -29,7 +29,8 @@ extern "C" {
enum _GAtSyntaxExpectHint {
G_AT_SYNTAX_EXPECT_PDU,
G_AT_SYNTAX_EXPECT_MULTILINE,
- G_AT_SYNTAX_EXPECT_PROMPT
+ G_AT_SYNTAX_EXPECT_PROMPT,
+ G_AT_SYNTAX_EXPECT_SHORT_PROMPT
};
typedef enum _GAtSyntaxExpectHint GAtSyntaxExpectHint;
--
1.7.0.4
^ permalink raw reply related [flat|nested] 18+ messages in thread* [PATCH 07/12] gatchat: implementation for +CPOS send
2011-03-24 13:46 [PATCH 00/12] Basic E911 support Jarko Poutiainen
` (5 preceding siblings ...)
2011-03-24 13:46 ` [PATCH 06/12] gatchat: new hint to handle +CPOS Jarko Poutiainen
@ 2011-03-24 13:46 ` Jarko Poutiainen
2011-03-28 23:00 ` Denis Kenzior
2011-03-24 13:46 ` [PATCH 08/12] gatchat: fix gatsyntax to support +CPOS Jarko Poutiainen
` (5 subsequent siblings)
12 siblings, 1 reply; 18+ messages in thread
From: Jarko Poutiainen @ 2011-03-24 13:46 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 3355 bytes --]
---
gatchat/gatchat.c | 37 +++++++++++++++++++++++++++++++++----
1 files changed, 33 insertions(+), 4 deletions(-)
diff --git a/gatchat/gatchat.c b/gatchat/gatchat.c
index 3fd564d..eeb8d24 100644
--- a/gatchat/gatchat.c
+++ b/gatchat/gatchat.c
@@ -53,6 +53,7 @@ struct at_command {
GAtNotifyFunc listing;
gpointer user_data;
GDestroyNotify notify;
+ gboolean short_prompt;
};
struct at_notify_node {
@@ -725,9 +726,18 @@ static void new_bytes(struct ring_buffer *rbuf, gpointer user_data)
unsigned char *buf = ring_buffer_read_ptr(rbuf, p->read_so_far);
GAtSyntaxResult result;
+ struct at_command *cmd;
p->in_read_handler = TRUE;
+ cmd = g_queue_peek_head(p->command_queue);
+ if (cmd)
+ if (cmd->short_prompt &&
+ !g_strcmp0(*cmd->prefixes, "+CPOS:") &&
+ p->syntax->set_hint)
+ p->syntax->set_hint(p->syntax,
+ G_AT_SYNTAX_EXPECT_SHORT_PROMPT);
+
while (p->suspended == FALSE && (p->read_so_far < len)) {
gsize rbytes = MIN(len - p->read_so_far, wrap - p->read_so_far);
result = p->syntax->feed(p->syntax, (char *)buf, &rbytes);
@@ -754,6 +764,12 @@ static void new_bytes(struct ring_buffer *rbuf, gpointer user_data)
break;
case G_AT_SYNTAX_RESULT_PROMPT:
+ if (cmd)
+ if (cmd->short_prompt &&
+ !g_strcmp0(*cmd->prefixes,
+ "+CPOS:"))
+ cmd->short_prompt = FALSE;
+
chat_wakeup_writer(p);
ring_buffer_drain(rbuf, p->read_so_far);
break;
@@ -995,7 +1011,8 @@ static guint at_chat_send_common(struct at_chat *chat, guint gid,
GAtNotifyFunc listing,
GAtResultFunc func,
gpointer user_data,
- GDestroyNotify notify)
+ GDestroyNotify notify,
+ gboolean short_prompt)
{
struct at_command *c;
@@ -1007,6 +1024,7 @@ static guint at_chat_send_common(struct at_chat *chat, guint gid,
if (c == NULL)
return 0;
+ c->short_prompt = short_prompt;
c->id = chat->next_cmd_id++;
g_queue_push_tail(chat->command_queue, c);
@@ -1439,7 +1457,7 @@ guint g_at_chat_send(GAtChat *chat, const char *cmd,
{
return at_chat_send_common(chat->parent, chat->group,
cmd, prefix_list, FALSE, NULL,
- func, user_data, notify);
+ func, user_data, notify, FALSE);
}
guint g_at_chat_send_listing(GAtChat *chat, const char *cmd,
@@ -1452,7 +1470,8 @@ guint g_at_chat_send_listing(GAtChat *chat, const char *cmd,
return at_chat_send_common(chat->parent, chat->group,
cmd, prefix_list, FALSE,
- listing, func, user_data, notify);
+ listing, func, user_data, notify,
+ FALSE);
}
guint g_at_chat_send_pdu_listing(GAtChat *chat, const char *cmd,
@@ -1465,7 +1484,17 @@ guint g_at_chat_send_pdu_listing(GAtChat *chat, const char *cmd,
return at_chat_send_common(chat->parent, chat->group,
cmd, prefix_list, TRUE,
- listing, func, user_data, notify);
+ listing, func, user_data, notify,
+ FALSE);
+}
+
+guint g_at_chat_send_and_expect_short_prompt(GAtChat *chat, const char *cmd,
+ const char **prefix_list, GAtResultFunc func,
+ gpointer user_data, GDestroyNotify notify)
+{
+ return at_chat_send_common(chat->parent, chat->group,
+ cmd, prefix_list, FALSE, NULL,
+ func, user_data, notify, TRUE);
}
gboolean g_at_chat_cancel(GAtChat *chat, guint id)
--
1.7.0.4
^ permalink raw reply related [flat|nested] 18+ messages in thread* [PATCH 08/12] gatchat: fix gatsyntax to support +CPOS
2011-03-24 13:46 [PATCH 00/12] Basic E911 support Jarko Poutiainen
` (6 preceding siblings ...)
2011-03-24 13:46 ` [PATCH 07/12] gatchat: implementation for +CPOS send Jarko Poutiainen
@ 2011-03-24 13:46 ` Jarko Poutiainen
2011-03-24 13:46 ` [PATCH 09/12] atmodem: add gnss driver Jarko Poutiainen
` (4 subsequent siblings)
12 siblings, 0 replies; 18+ messages in thread
From: Jarko Poutiainen @ 2011-03-24 13:46 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 2335 bytes --]
---
gatchat/gatsyntax.c | 27 +++++++++++++++++++++++++++
1 files changed, 27 insertions(+), 0 deletions(-)
diff --git a/gatchat/gatsyntax.c b/gatchat/gatsyntax.c
index 2fc70b8..469ffc3 100644
--- a/gatchat/gatsyntax.c
+++ b/gatchat/gatsyntax.c
@@ -44,6 +44,7 @@ enum GSMV1_STATE {
GSMV1_STATE_PROMPT,
GSMV1_STATE_ECHO,
GSMV1_PPP_DATA,
+ GSMV1_STATE_SHORT_PROMPT,
};
enum GSM_PERMISSIVE_STATE {
@@ -53,6 +54,7 @@ enum GSM_PERMISSIVE_STATE {
GSM_PERMISSIVE_STATE_GUESS_PDU,
GSM_PERMISSIVE_STATE_PDU,
GSM_PERMISSIVE_STATE_PROMPT,
+ GSM_PERMISSIVE_STATE_SHORT_PROMPT,
};
static void gsmv1_hint(GAtSyntax *syntax, GAtSyntaxExpectHint hint)
@@ -64,6 +66,9 @@ static void gsmv1_hint(GAtSyntax *syntax, GAtSyntaxExpectHint hint)
case G_AT_SYNTAX_EXPECT_MULTILINE:
syntax->state = GSMV1_STATE_GUESS_MULTILINE_RESPONSE;
break;
+ case G_AT_SYNTAX_EXPECT_SHORT_PROMPT:
+ syntax->state = GSMV1_STATE_SHORT_PROMPT;
+ break;
default:
break;
};
@@ -200,6 +205,16 @@ static GAtSyntaxResult gsmv1_feed(GAtSyntax *syntax,
syntax->state = GSMV1_STATE_RESPONSE;
return G_AT_SYNTAX_RESULT_UNSURE;
+ case GSMV1_STATE_SHORT_PROMPT:
+ if (byte == '\r')
+ break;
+ else if (byte == '\n') {
+ syntax->state = GSMV1_STATE_IDLE;
+ i += 1;
+ res = G_AT_SYNTAX_RESULT_PROMPT;
+ goto out;
+ }
+
case GSMV1_STATE_ECHO:
/* This handles the case of echo of the PDU terminated
* by CtrlZ character
@@ -239,6 +254,8 @@ static void gsm_permissive_hint(GAtSyntax *syntax, GAtSyntaxExpectHint hint)
{
if (hint == G_AT_SYNTAX_EXPECT_PDU)
syntax->state = GSM_PERMISSIVE_STATE_GUESS_PDU;
+ else if (hint == G_AT_SYNTAX_EXPECT_SHORT_PROMPT)
+ syntax->state = GSM_PERMISSIVE_STATE_SHORT_PROMPT;
}
static GAtSyntaxResult gsm_permissive_feed(GAtSyntax *syntax,
@@ -303,6 +320,16 @@ static GAtSyntaxResult gsm_permissive_feed(GAtSyntax *syntax,
syntax->state = GSM_PERMISSIVE_STATE_RESPONSE;
return G_AT_SYNTAX_RESULT_UNSURE;
+ case GSM_PERMISSIVE_STATE_SHORT_PROMPT:
+ if (byte == '\r')
+ break;
+ else if (byte == '\n') {
+ syntax->state = GSM_PERMISSIVE_STATE_IDLE;
+ i += 1;
+ res = G_AT_SYNTAX_RESULT_PROMPT;
+ goto out;
+ }
+
default:
break;
};
--
1.7.0.4
^ permalink raw reply related [flat|nested] 18+ messages in thread* [PATCH 09/12] atmodem: add gnss driver
2011-03-24 13:46 [PATCH 00/12] Basic E911 support Jarko Poutiainen
` (7 preceding siblings ...)
2011-03-24 13:46 ` [PATCH 08/12] gatchat: fix gatsyntax to support +CPOS Jarko Poutiainen
@ 2011-03-24 13:46 ` Jarko Poutiainen
2011-03-28 23:06 ` Denis Kenzior
2011-03-24 13:46 ` [PATCH 10/12] ste: add support for gnss Jarko Poutiainen
` (3 subsequent siblings)
12 siblings, 1 reply; 18+ messages in thread
From: Jarko Poutiainen @ 2011-03-24 13:46 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 8428 bytes --]
---
Makefile.am | 3 +-
drivers/atmodem/atmodem.c | 2 +
drivers/atmodem/atmodem.h | 3 +
drivers/atmodem/gnss.c | 282 +++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 289 insertions(+), 1 deletions(-)
create mode 100644 drivers/atmodem/gnss.c
diff --git a/Makefile.am b/Makefile.am
index 8d127af..b5a3d6e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -180,7 +180,8 @@ builtin_sources += $(gatchat_sources) \
drivers/atmodem/atutil.c \
drivers/atmodem/gprs.c \
drivers/atmodem/gprs-context.c \
- drivers/atmodem/sim-auth.c
+ drivers/atmodem/sim-auth.c \
+ drivers/atmodem/gnss.c
builtin_modules += nwmodem
builtin_sources += drivers/atmodem/atutil.h \
diff --git a/drivers/atmodem/atmodem.c b/drivers/atmodem/atmodem.c
index ce6c10a..be93f41 100644
--- a/drivers/atmodem/atmodem.c
+++ b/drivers/atmodem/atmodem.c
@@ -51,6 +51,7 @@ static int atmodem_init(void)
at_gprs_init();
at_gprs_context_init();
at_sim_auth_init();
+ at_gnss_init();
return 0;
}
@@ -74,6 +75,7 @@ static void atmodem_exit(void)
at_call_volume_exit();
at_gprs_exit();
at_gprs_context_exit();
+ at_gnss_exit();
}
OFONO_PLUGIN_DEFINE(atmodem, "AT modem driver", VERSION,
diff --git a/drivers/atmodem/atmodem.h b/drivers/atmodem/atmodem.h
index a6720d1..41f480f 100644
--- a/drivers/atmodem/atmodem.h
+++ b/drivers/atmodem/atmodem.h
@@ -71,3 +71,6 @@ extern void at_gprs_context_exit(void);
extern void at_sim_auth_init(void);
extern void at_sim_auth_exit(void);
+
+extern void at_gnss_init(void);
+extern void at_gnss_exit(void);
diff --git a/drivers/atmodem/gnss.c b/drivers/atmodem/gnss.c
new file mode 100644
index 0000000..f2ed0a7
--- /dev/null
+++ b/drivers/atmodem/gnss.c
@@ -0,0 +1,282 @@
+/*
+ *
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 2008-2010 Intel Corporation. All rights reserved.
+ * Copyright (C) 2011 ST-Ericsson AB.
+ *
+ * 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/gnss.h>
+
+#include "gatchat.h"
+#include "gatresult.h"
+
+#include "atmodem.h"
+#include "vendor.h"
+
+struct gnss_data {
+ GAtChat *chat;
+ unsigned int vendor;
+};
+
+static const char *none_prefix[] = { NULL };
+static const char *cpos_prefix[] = { "+CPOS:", NULL };
+static const char *cposr_prefix[] = { "+CPOSR:", NULL };
+
+static void gnss_pr_cb(gboolean ok, GAtResult *result, gpointer user_data)
+{
+ struct cb_data *cbd = user_data;
+ ofono_gnss_cb_t cb = cbd->cb;
+ struct ofono_error error;
+
+ DBG("");
+
+ decode_at_error(&error, g_at_result_final_response(result));
+
+ cb(&error, cbd->data);
+}
+
+static void at_gnss_position_reporting(struct ofono_gnss *gnss,
+ ofono_bool_t enable,
+ ofono_gnss_cb_t cb,
+ void *data)
+{
+ struct gnss_data *ad = ofono_gnss_get_data(gnss);
+ struct cb_data *cbd = cb_data_new(cb, data);
+
+ DBG("");
+
+ if (enable) {
+ g_at_chat_send(ad->chat, "AT+CPOSR=1",
+ cposr_prefix, gnss_pr_cb, cbd, g_free);
+
+ if (ad->vendor == OFONO_VENDOR_STE)
+ g_at_chat_send(ad->chat, "AT*EPOSADRR=1",
+ NULL, NULL, NULL, NULL);
+ } else {
+ g_at_chat_send(ad->chat, "AT+CPOSR=0",
+ cposr_prefix, gnss_pr_cb, cbd, g_free);
+
+ if (ad->vendor == OFONO_VENDOR_STE)
+ g_at_chat_send(ad->chat, "AT*EPOSADRR=0",
+ NULL, NULL, NULL, NULL);
+ }
+}
+
+static void gnss_se_cb(gboolean ok, GAtResult *result, gpointer user_data)
+{
+ struct cb_data *cbd = user_data;
+ ofono_gnss_cb_t cb = cbd->cb;
+ struct ofono_error error;
+
+ DBG("");
+
+ decode_at_error(&error, g_at_result_final_response(result));
+
+ cb(&error, cbd->data);
+}
+
+static void at_gnss_send_element(struct ofono_gnss *gnss,
+ const char *xml,
+ ofono_gnss_cb_t cb, void *data)
+{
+ struct gnss_data *ad = ofono_gnss_get_data(gnss);
+ struct cb_data *cbd = cb_data_new(cb, data);
+ char *buf = g_try_new(char, strlen(xml) + 10);
+ int len;
+
+ DBG("");
+
+ if (buf == NULL)
+ goto error;
+
+ len = sprintf(buf, "AT+CPOS\r");
+ len += sprintf(buf + len, "%s", xml);
+
+ if (g_at_chat_send_and_expect_short_prompt(ad->chat, buf, cpos_prefix,
+ gnss_se_cb, cbd,
+ g_free) > 0) {
+ g_free(buf);
+ return;
+ }
+
+error:
+ g_free(buf);
+ g_free(cbd);
+
+ CALLBACK_WITH_FAILURE(cb, data);
+}
+
+static gboolean gnss_parse_report(GAtResult *result, const char *prefix,
+ const char **xml)
+{
+ GAtResultIter iter;
+
+ g_at_result_iter_init(&iter, result);
+
+ if (!g_at_result_iter_next(&iter, prefix))
+ return FALSE;
+
+ if (!g_at_result_iter_next_unquoted_string(&iter, xml))
+ return FALSE;
+
+ return TRUE;
+}
+
+static void gnss_report(GAtResult *result, gpointer user_data)
+{
+ struct ofono_gnss *gnss = user_data;
+ const char *xml;
+
+ DBG("");
+
+ xml = NULL;
+ if (!gnss_parse_report(result, "+CPOSR:", &xml)) {
+ ofono_error("Unable to parse CPOSR notification");
+ return;
+ }
+
+ if (xml == NULL) {
+ ofono_error("Unable to parse CPOSR notification");
+ return;
+ }
+
+ ofono_gnss_notify_posr_request(gnss, xml);
+}
+
+static void at_gnss_reset_notify(GAtResult *result, gpointer user_data)
+{
+ struct ofono_gnss *gnss = user_data;
+
+ DBG("");
+
+ ofono_gnss_notify_posr_reset(gnss);
+}
+
+static void at_gnss_not_supported(struct ofono_gnss *gnss)
+{
+ ofono_error("gnss not supported by this modem.");
+
+ ofono_gnss_remove(gnss);
+}
+
+static void at_gnss_cposr_support_cb(gboolean ok, GAtResult *result,
+ gpointer user_data)
+{
+ struct ofono_gnss *gnss = user_data;
+ struct gnss_data *ad = ofono_gnss_get_data(gnss);
+
+ DBG("");
+
+ if (!ok) {
+ at_gnss_not_supported(gnss);
+ return;
+ }
+
+ g_at_chat_register(ad->chat, "+CPOSR:", gnss_report,
+ FALSE, gnss, NULL);
+
+ if (ad->vendor == OFONO_VENDOR_STE)
+ g_at_chat_register(ad->chat, "*EPOSADRR:", at_gnss_reset_notify,
+ FALSE, gnss, NULL);
+
+ ofono_gnss_register(gnss);
+}
+
+static void at_gnss_cpos_support_cb(gboolean ok, GAtResult *result,
+ gpointer user_data)
+{
+ struct ofono_gnss *gnss = user_data;
+ struct gnss_data *ad = ofono_gnss_get_data(gnss);
+
+ DBG("");
+
+ if (!ok) {
+ at_gnss_not_supported(gnss);
+ return;
+ }
+
+ g_at_chat_send(ad->chat, "AT+CPOSR=?",
+ none_prefix, at_gnss_cposr_support_cb, gnss, NULL);
+}
+
+static int at_gnss_probe(struct ofono_gnss *gnss, unsigned int vendor,
+ void *user)
+{
+ GAtChat *chat = user;
+ struct gnss_data *gd;
+
+ DBG("");
+
+ gd = g_try_new0(struct gnss_data, 1);
+ if (gd == NULL)
+ return -ENOMEM;
+
+ gd->chat = g_at_chat_clone(chat);
+ gd->vendor = vendor;
+
+ ofono_gnss_set_data(gnss, gd);
+
+ g_at_chat_send(gd->chat, "AT+CPOS=?",
+ none_prefix, at_gnss_cpos_support_cb, gnss, NULL);
+
+ return 0;
+}
+
+static void at_gnss_remove(struct ofono_gnss *gnss)
+{
+ struct gnss_data *gd = ofono_gnss_get_data(gnss);
+
+ DBG("");
+
+ ofono_gnss_set_data(gnss, NULL);
+
+ g_at_chat_unref(gd->chat);
+ g_free(gd);
+}
+
+static struct ofono_gnss_driver driver = {
+ .name = "atmodem",
+ .probe = at_gnss_probe,
+ .remove = at_gnss_remove,
+ .send_element = at_gnss_send_element,
+ .set_position_reporting = at_gnss_position_reporting,
+};
+
+void at_gnss_init(void)
+{
+ ofono_gnss_driver_register(&driver);
+}
+
+void at_gnss_exit(void)
+{
+ ofono_gnss_driver_unregister(&driver);
+}
--
1.7.0.4
^ permalink raw reply related [flat|nested] 18+ messages in thread* Re: [PATCH 09/12] atmodem: add gnss driver
2011-03-24 13:46 ` [PATCH 09/12] atmodem: add gnss driver Jarko Poutiainen
@ 2011-03-28 23:06 ` Denis Kenzior
0 siblings, 0 replies; 18+ messages in thread
From: Denis Kenzior @ 2011-03-28 23:06 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1817 bytes --]
Hi Jarko,
On 03/24/2011 08:46 AM, Jarko Poutiainen wrote:
> ---
> Makefile.am | 3 +-
> drivers/atmodem/atmodem.c | 2 +
> drivers/atmodem/atmodem.h | 3 +
> drivers/atmodem/gnss.c | 282 +++++++++++++++++++++++++++++++++++++++++++++
> 4 files changed, 289 insertions(+), 1 deletions(-)
> create mode 100644 drivers/atmodem/gnss.c
I applied this patch, however:
> +static gboolean gnss_parse_report(GAtResult *result, const char *prefix,
> + const char **xml)
> +{
> + GAtResultIter iter;
> +
> + g_at_result_iter_init(&iter, result);
> +
> + if (!g_at_result_iter_next(&iter, prefix))
> + return FALSE;
> +
> + if (!g_at_result_iter_next_unquoted_string(&iter, xml))
> + return FALSE;
> +
> + return TRUE;
> +}
> +
> +static void gnss_report(GAtResult *result, gpointer user_data)
> +{
> + struct ofono_gnss *gnss = user_data;
> + const char *xml;
> +
> + DBG("");
> +
> + xml = NULL;
> + if (!gnss_parse_report(result, "+CPOSR:", &xml)) {
> + ofono_error("Unable to parse CPOSR notification");
> + return;
> + }
> +
> + if (xml == NULL) {
> + ofono_error("Unable to parse CPOSR notification");
> + return;
> + }
> +
> + ofono_gnss_notify_posr_request(gnss, xml);
> +}
The implementation of CPOSR is pretty much unacceptable. You're relying
on the agent to parse the XML piecemeal. I don't like this at all. It
creates unnecessary round-trips over D-Bus for each CPOSR we receive,
not to mention ambiguity in exceptional conditions (e.g. a modem reset
happens during CPOSR emission).
I'd like you to modify the driver to detect the start and end of CPOSR
strings, assemble the XML fragments into a single chunk and only call
ofono_gnss_notify_posr_request once the XML string is assembled.
Regards,
-Denis
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 10/12] ste: add support for gnss
2011-03-24 13:46 [PATCH 00/12] Basic E911 support Jarko Poutiainen
` (8 preceding siblings ...)
2011-03-24 13:46 ` [PATCH 09/12] atmodem: add gnss driver Jarko Poutiainen
@ 2011-03-24 13:46 ` Jarko Poutiainen
2011-03-24 13:46 ` [PATCH 11/12] ofono.conf: add positioning agent interface Jarko Poutiainen
` (2 subsequent siblings)
12 siblings, 0 replies; 18+ messages in thread
From: Jarko Poutiainen @ 2011-03-24 13:46 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1416 bytes --]
---
plugins/ste.c | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/plugins/ste.c b/plugins/ste.c
index 36b3148..f7fe2b4 100644
--- a/plugins/ste.c
+++ b/plugins/ste.c
@@ -57,6 +57,7 @@
#include <ofono/gprs-context.h>
#include <ofono/radio-settings.h>
#include <ofono/stk.h>
+#include <ofono/gnss.h>
#include <drivers/atmodem/atutil.h>
#include <drivers/atmodem/vendor.h>
@@ -64,17 +65,18 @@
#include <drivers/stemodem/caif_socket.h>
#include <drivers/stemodem/if_caif.h>
-#define NUM_CHAT 5
+#define NUM_CHAT 6
#define AT_DEFAULT 0
#define AT_NET 1
#define AT_VOICE 2
#define AT_GPRS 3
#define AT_SIM 4
+#define AT_GNSS 5
#define MAX_PDP_CONTEXTS 4
static char *chat_prefixes[NUM_CHAT] = { "Default: ", "Net: ", "Voice: ",
- "GPRS: ", "SIM: " };
+ "GPRS: ", "SIM: ", "GNSS:" };
struct ste_data {
GAtChat *chat[NUM_CHAT];
@@ -471,6 +473,8 @@ static void ste_post_online(struct ofono_modem *modem)
ofono_call_barring_create(modem, 0, "atmodem", data->chat[AT_DEFAULT]);
ofono_call_volume_create(modem, 0, "atmodem", data->chat[AT_DEFAULT]);
ofono_cbs_create(modem, 0, "atmodem", data->chat[AT_DEFAULT]);
+ ofono_gnss_create(modem, OFONO_VENDOR_STE, "atmodem",
+ data->chat[AT_GNSS]);
gprs = ofono_gprs_create(modem, OFONO_VENDOR_MBM,
"atmodem", data->chat[AT_GPRS]);
--
1.7.0.4
^ permalink raw reply related [flat|nested] 18+ messages in thread* [PATCH 11/12] ofono.conf: add positioning agent interface
2011-03-24 13:46 [PATCH 00/12] Basic E911 support Jarko Poutiainen
` (9 preceding siblings ...)
2011-03-24 13:46 ` [PATCH 10/12] ste: add support for gnss Jarko Poutiainen
@ 2011-03-24 13:46 ` Jarko Poutiainen
2011-03-24 13:46 ` [PATCH 12/12] test: add test-gnss Jarko Poutiainen
2011-03-28 22:56 ` [PATCH 00/12] Basic E911 support Denis Kenzior
12 siblings, 0 replies; 18+ messages in thread
From: Jarko Poutiainen @ 2011-03-24 13:46 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 538 bytes --]
---
src/ofono.conf | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/src/ofono.conf b/src/ofono.conf
index 0dfa038..8a83cd0 100644
--- a/src/ofono.conf
+++ b/src/ofono.conf
@@ -13,6 +13,7 @@
<allow send_interface="org.ofono.SimToolkitAgent"/>
<allow send_interface="org.ofono.PushNotificationAgent"/>
<allow send_interface="org.ofono.SmartMessagingAgent"/>
+ <allow send_interface="org.ofono.PositioningRequestAgent"/>
</policy>
<policy at_console="true">
--
1.7.0.4
^ permalink raw reply related [flat|nested] 18+ messages in thread* [PATCH 12/12] test: add test-gnss
2011-03-24 13:46 [PATCH 00/12] Basic E911 support Jarko Poutiainen
` (10 preceding siblings ...)
2011-03-24 13:46 ` [PATCH 11/12] ofono.conf: add positioning agent interface Jarko Poutiainen
@ 2011-03-24 13:46 ` Jarko Poutiainen
2011-03-28 22:56 ` [PATCH 00/12] Basic E911 support Denis Kenzior
12 siblings, 0 replies; 18+ messages in thread
From: Jarko Poutiainen @ 2011-03-24 13:46 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 3360 bytes --]
---
Makefile.am | 3 +-
test/test-gnss | 91 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 93 insertions(+), 1 deletions(-)
create mode 100755 test/test-gnss
diff --git a/Makefile.am b/Makefile.am
index b5a3d6e..626a310 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -509,7 +509,8 @@ test_scripts = test/backtrace \
test/test-sms \
test/test-message-waiting \
test/cdma-connman-disable \
- test/cdma-connman-enable
+ test/cdma-connman-enable \
+ test/test-gnss
if TEST
testdir = $(pkglibdir)/test
diff --git a/test/test-gnss b/test/test-gnss
new file mode 100755
index 0000000..d7d9027
--- /dev/null
+++ b/test/test-gnss
@@ -0,0 +1,91 @@
+#!/usr/bin/python
+
+import gobject
+import sys
+import os
+
+import dbus
+import dbus.service
+import dbus.mainloop.glib
+
+class PositioningAgent(dbus.service.Object):
+ @dbus.service.method("org.ofono.PositioningRequestAgent",
+ in_signature="", out_signature="")
+ def Release(self):
+ print "Release"
+ mainloop.quit()
+
+ @dbus.service.method("org.ofono.PositioningRequestAgent",
+ in_signature="s", out_signature="")
+ def Request(self, xml):
+ print "positioning data: %s" % (xml)
+
+ @dbus.service.method("org.ofono.PositioningRequestAgent",
+ in_signature="", out_signature="")
+ def ResetAssistanceData(self):
+ print "Reset Assistance Data request received"
+
+def print_menu():
+ print "Select test case"
+ print "-----------------------------------------------------------"
+ print "[0] SendPositioningElement"
+ print "[1] RegisterPositioningRequestAgent"
+ print "[2] UnregisterPositioningRequestAgent"
+ print "[x] Exit"
+ print "-----------------------------------------------------------"
+
+def stdin_handler(fd, condition, positioning, path):
+
+ in_key = os.read(fd.fileno(), 8).rstrip()
+ if in_key == '0':
+ xml = raw_input('type the element and press enter: ')
+ try:
+ positioning.SendPositioningElement(dbus.String(xml))
+ print "ok"
+ except dbus.DBusException, e:
+ print "Unable to send positioning element"
+
+ elif in_key == '1':
+ try:
+ positioning.RegisterPositioningRequestAgent("/test/posagent")
+ print "ok"
+ except dbus.DBusException, e:
+ print "Unable to register positioning agent"
+
+ elif in_key == '2':
+ try:
+ positioning.UnregisterPositioningRequestAgent(path)
+ print "ok"
+ except dbus.DBusException, e:
+ print "Unable to unregister positioning agent"
+ elif in_key == 'x':
+ sys.exit(1)
+
+ return True
+
+if __name__ == "__main__":
+
+ if len(sys.argv) < 1:
+ sys.exit(1)
+
+ dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
+ bus = dbus.SystemBus()
+ manager = dbus.Interface(bus.get_object('org.ofono', '/'),
+ 'org.ofono.Manager')
+
+ modems = manager.GetModems()
+ for path, properties in modems:
+ if "org.ofono.AssistedSatelliteNavigation" not in properties["Interfaces"]:
+ continue
+
+ positioning = dbus.Interface(bus.get_object('org.ofono', path),
+ 'org.ofono.AssistedSatelliteNavigation')
+
+ path = "/test/posagent"
+ agent = PositioningAgent(bus, path)
+
+ print_menu()
+
+ gobject.io_add_watch(sys.stdin, gobject.IO_IN, stdin_handler, positioning, path)
+ mainloop = gobject.MainLoop()
+ mainloop.run()
--
1.7.0.4
^ permalink raw reply related [flat|nested] 18+ messages in thread* Re: [PATCH 00/12] Basic E911 support
2011-03-24 13:46 [PATCH 00/12] Basic E911 support Jarko Poutiainen
` (11 preceding siblings ...)
2011-03-24 13:46 ` [PATCH 12/12] test: add test-gnss Jarko Poutiainen
@ 2011-03-28 22:56 ` Denis Kenzior
2011-03-29 10:19 ` Jarko Poutiainen
12 siblings, 1 reply; 18+ messages in thread
From: Denis Kenzior @ 2011-03-28 22:56 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1942 bytes --]
Hi Jarko,
On 03/24/2011 08:46 AM, Jarko Poutiainen wrote:
> Hi,
>
> This is third attempt to provide implementation for basic E911 support.
>
> Br,
> Jarko
>
> Jarko Poutiainen (12):
> dbus: add gnss interface definition
> include: add gnss.h file
> src: add atom type for gnss
> src: add gnss atom and agent implementation
> gatchat: introduce send for +CPOS
> gatchat: new hint to handle +CPOS
> gatchat: implementation for +CPOS send
> gatchat: fix gatsyntax to support +CPOS
> atmodem: add gnss driver
> ste: add support for gnss
> ofono.conf: add positioning agent interface
> test: add test-gnss
>
> Makefile.am | 12 +-
> drivers/atmodem/atmodem.c | 2 +
> drivers/atmodem/atmodem.h | 3 +
> drivers/atmodem/gnss.c | 282 +++++++++++++++++++++++++++++++++
> gatchat/gatchat.c | 37 ++++-
> gatchat/gatchat.h | 8 +
> gatchat/gatsyntax.c | 27 +++
> gatchat/gatsyntax.h | 3 +-
> include/dbus.h | 2 +
> include/gnss.h | 69 ++++++++
> plugins/ste.c | 8 +-
> src/gnss.c | 386 +++++++++++++++++++++++++++++++++++++++++++++
> src/gnssagent.c | 158 ++++++++++++++++++
> src/gnssagent.h | 43 +++++
> src/ofono.conf | 1 +
> src/ofono.h | 2 +
> test/test-gnss | 91 +++++++++++
> 17 files changed, 1123 insertions(+), 11 deletions(-)
> create mode 100644 drivers/atmodem/gnss.c
> create mode 100644 include/gnss.h
> create mode 100644 src/gnss.c
> create mode 100644 src/gnssagent.c
> create mode 100644 src/gnssagent.h
> create mode 100755 test/test-gnss
>
I applied (most) of this patch series, however see my comments for the
individual patches. I did refactor your work 'slightly', so please let
me know if something doesn't work.
Regards,
-Denis
^ permalink raw reply [flat|nested] 18+ messages in thread* Re: [PATCH 00/12] Basic E911 support
2011-03-28 22:56 ` [PATCH 00/12] Basic E911 support Denis Kenzior
@ 2011-03-29 10:19 ` Jarko Poutiainen
0 siblings, 0 replies; 18+ messages in thread
From: Jarko Poutiainen @ 2011-03-29 10:19 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 532 bytes --]
Hi Denis,
On Tue, 2011-03-29 at 01:56 +0300, Denis Kenzior wrote:
> Hi Jarko,
>
> On 03/24/2011 08:46 AM, Jarko Poutiainen wrote:
> > Hi,
> >
> > This is third attempt to provide implementation for basic E911 support.
> >
> > Br,
> > Jarko
> >
>
> I applied (most) of this patch series, however see my comments for the
> individual patches. I did refactor your work 'slightly', so please let
> me know if something doesn't work.
>
> Regards,
> -Denis
Thanks! Everything seems to work.
Br,
Jarko
^ permalink raw reply [flat|nested] 18+ messages in thread