aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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;
}