Re: [PATCH 09/12] atmodem: add gnss driver

2011-03-28 Thread Denis Kenzior
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
___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 09/12] atmodem: add gnss driver

2011-03-24 Thread Jarko Poutiainen
---
 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 000..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, 

Re: [PATCH 09/12] atmodem: add gnss driver

2011-03-18 Thread Jarko Poutiainen
Hi Denis,

On Fri, 2011-03-18 at 07:03 +0200, Denis Kenzior wrote:
 On 03/11/2011 06:23 AM, Jarko Poutiainen wrote:
  ---
   Makefile.am   |3 +-
   drivers/atmodem/atmodem.c |2 +
   drivers/atmodem/atmodem.h |3 +
   drivers/atmodem/gnss.c|  279 
  +
   4 files changed, 286 insertions(+), 1 deletions(-)
   create mode 100644 drivers/atmodem/gnss.c
  
  diff --git a/Makefile.am b/Makefile.am
  index 24742bb..3dae7f4 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 e140281..3093c23 100644
  --- a/drivers/atmodem/atmodem.c
  +++ b/drivers/atmodem/atmodem.c
  @@ -52,6 +52,7 @@ static int atmodem_init(void)
  at_gprs_init();
  at_gprs_context_init();
  at_sim_auth_init();
  +   at_gnss_init();
   
  return 0;
   }
  @@ -76,6 +77,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 1b7cf67..1a73b84 100644
  --- a/drivers/atmodem/atmodem.h
  +++ b/drivers/atmodem/atmodem.h
  @@ -74,3 +74,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 000..c1b1de3
  --- /dev/null
  +++ b/drivers/atmodem/gnss.c
  @@ -0,0 +1,279 @@
  +/*
  + *
  + *  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 gnsspr_cb(gboolean ok, GAtResult *result, gpointer user_data)
  +{
  +   struct cb_data *cbd = user_data;
  +   ofono_gnss_position_report_cb_t cb = cbd-cb;
  +
  +   DBG();
  +
  +   if (ok)
  +   CALLBACK_WITH_SUCCESS(cb, cbd-data);
  +   else
  +   CALLBACK_WITH_FAILURE(cb, cbd-data);
 
 As a general habit, please use at_util_decode_error instead of using
 these macros.  This leads to simpler code as well
 
Thanks I will do that

  +}
  +
  +static void at_gnss_position_reporting(struct ofono_gnss *gnss,
  +   ofono_bool_t enable,
  +   ofono_gnss_position_report_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, gnsspr_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, gnsspr_cb, cbd, g_free);
  +
  +   if (ad-vendor 

Re: [PATCH 09/12] atmodem: add gnss driver

2011-03-18 Thread Denis Kenzior
Hi Jarko,

 +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;

 Do you really need a separate function?  This might belong in gnss_report

 I just thought that it would be more logical to have separate function
 to parse the result rather than putting it all in to same function. Is
 that a big deal or do you want me to change that?

This is not really wrong, was just wondering.  Leave it as is for now.

Regards,
-Denis
___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


Re: [PATCH 09/12] atmodem: add gnss driver

2011-03-17 Thread Denis Kenzior
On 03/11/2011 06:23 AM, Jarko Poutiainen wrote:
 ---
  Makefile.am   |3 +-
  drivers/atmodem/atmodem.c |2 +
  drivers/atmodem/atmodem.h |3 +
  drivers/atmodem/gnss.c|  279 
 +
  4 files changed, 286 insertions(+), 1 deletions(-)
  create mode 100644 drivers/atmodem/gnss.c
 
 diff --git a/Makefile.am b/Makefile.am
 index 24742bb..3dae7f4 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 e140281..3093c23 100644
 --- a/drivers/atmodem/atmodem.c
 +++ b/drivers/atmodem/atmodem.c
 @@ -52,6 +52,7 @@ static int atmodem_init(void)
   at_gprs_init();
   at_gprs_context_init();
   at_sim_auth_init();
 + at_gnss_init();
  
   return 0;
  }
 @@ -76,6 +77,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 1b7cf67..1a73b84 100644
 --- a/drivers/atmodem/atmodem.h
 +++ b/drivers/atmodem/atmodem.h
 @@ -74,3 +74,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 000..c1b1de3
 --- /dev/null
 +++ b/drivers/atmodem/gnss.c
 @@ -0,0 +1,279 @@
 +/*
 + *
 + *  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 gnsspr_cb(gboolean ok, GAtResult *result, gpointer user_data)
 +{
 + struct cb_data *cbd = user_data;
 + ofono_gnss_position_report_cb_t cb = cbd-cb;
 +
 + DBG();
 +
 + if (ok)
 + CALLBACK_WITH_SUCCESS(cb, cbd-data);
 + else
 + CALLBACK_WITH_FAILURE(cb, cbd-data);

As a general habit, please use at_util_decode_error instead of using
these macros.  This leads to simpler code as well

 +}
 +
 +static void at_gnss_position_reporting(struct ofono_gnss *gnss,
 + ofono_bool_t enable,
 + ofono_gnss_position_report_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, gnsspr_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, gnsspr_cb, cbd, g_free);
 +
 + if (ad-vendor == OFONO_VENDOR_STE)
 + g_at_chat_send(ad-chat, AT*EPOSADRR=0,
 + NULL, NULL, NULL, NULL);
 + }
 +}
 +
 

[PATCH 09/12] atmodem: add gnss driver

2011-03-11 Thread Jarko Poutiainen
---
 Makefile.am   |3 +-
 drivers/atmodem/atmodem.c |2 +
 drivers/atmodem/atmodem.h |3 +
 drivers/atmodem/gnss.c|  279 +
 4 files changed, 286 insertions(+), 1 deletions(-)
 create mode 100644 drivers/atmodem/gnss.c

diff --git a/Makefile.am b/Makefile.am
index 24742bb..3dae7f4 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 e140281..3093c23 100644
--- a/drivers/atmodem/atmodem.c
+++ b/drivers/atmodem/atmodem.c
@@ -52,6 +52,7 @@ static int atmodem_init(void)
at_gprs_init();
at_gprs_context_init();
at_sim_auth_init();
+   at_gnss_init();
 
return 0;
 }
@@ -76,6 +77,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 1b7cf67..1a73b84 100644
--- a/drivers/atmodem/atmodem.h
+++ b/drivers/atmodem/atmodem.h
@@ -74,3 +74,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 000..c1b1de3
--- /dev/null
+++ b/drivers/atmodem/gnss.c
@@ -0,0 +1,279 @@
+/*
+ *
+ *  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 gnsspr_cb(gboolean ok, GAtResult *result, gpointer user_data)
+{
+   struct cb_data *cbd = user_data;
+   ofono_gnss_position_report_cb_t cb = cbd-cb;
+
+   DBG();
+
+   if (ok)
+   CALLBACK_WITH_SUCCESS(cb, cbd-data);
+   else
+   CALLBACK_WITH_FAILURE(cb, cbd-data);
+}
+
+static void at_gnss_position_reporting(struct ofono_gnss *gnss,
+   ofono_bool_t enable,
+   ofono_gnss_position_report_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, gnsspr_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, gnsspr_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 gnssse_cb(gboolean ok, GAtResult *result, gpointer user_data)
+{
+   struct cb_data *cbd = user_data;
+   ofono_gnss_send_element_cb_t cb = cbd-cb;
+
+   DBG();
+
+   if (ok)
+