aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Ranostay <matt.ranostay@konsulko.com>2017-08-31 13:05:39 -0700
committerMatt Ranostay <matt.ranostay@konsulko.com>2017-08-31 19:37:17 -0700
commitf5e242dfba3aac24b8d9aceffa9442b1ca71a2b5 (patch)
treeeb92808b2e9cc862b1c619e4d53f326f01944e6f
parent344f115511abc18c0156c2784c2fcc50e0d8306d (diff)
binding: gps: add dop reporting
Add dilution of precision report to JSON output to allow subscribers to judge if the 3D fix lock is good enough. If not user should fall back to the geoclue binding support. Bug-AGL: SPEC-844 Change-Id: If5a520d23c8b455583a022ab07a02dea03185705 Signed-off-by: Matt Ranostay <matt.ranostay@konsulko.com>
-rw-r--r--binding/afm-gps-binding.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/binding/afm-gps-binding.c b/binding/afm-gps-binding.c
index e7cbf8f..e00a317 100644
--- a/binding/afm-gps-binding.c
+++ b/binding/afm-gps-binding.c
@@ -36,6 +36,37 @@ static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
#define MSECS_TO_USECS(x) (x * 1000)
+// struct dop_t item order
+static const char *dop_names[] = {
+ "xdop",
+ "ydop",
+ "pdop",
+ "hdop",
+ "vdop",
+ "tdop",
+ "gdop",
+ NULL
+};
+
+static json_object *populate_json_dop_data(json_object *jresp, struct dop_t *dop)
+{
+ char **names = (char **) dop_names;
+ double *tmp = (double *) dop;
+ json_object *value = NULL;
+
+ while (*names) {
+ double val = *tmp++;
+
+ if (val != 0) {
+ value = json_object_new_double(val);
+ json_object_object_add(jresp, *names, value);
+ }
+ names++;
+ }
+
+ return jresp;
+}
+
static json_object *populate_json_data(json_object *jresp)
{
json_object *value = NULL;
@@ -63,6 +94,8 @@ static json_object *populate_json_data(json_object *jresp)
json_object_object_add(jresp, "speed", value);
}
+ jresp = populate_json_dop_data(jresp, &data.dop);
+
return jresp;
}