From 43d6e54035d82a5ebffe921613765beae527f979 Mon Sep 17 00:00:00 2001 From: Jan-Piet Mens Date: Wed, 9 Dec 2015 12:52:20 +0100 Subject: [PATCH] normalize acc to double --- recorder.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/recorder.c b/recorder.c index 1806ed9..03b5320 100644 --- a/recorder.c +++ b/recorder.c @@ -553,7 +553,7 @@ void on_message(struct mosquitto *mosq, void *userdata, const struct mosquitto_m { JsonNode *json, *j, *geo = NULL; char *tid = NULL, *t = NULL, *p; - double lat, lon; + double lat, lon, acc; long tst; struct udata *ud = (struct udata *)userdata; char **topics; @@ -807,7 +807,7 @@ void on_message(struct mosquitto *mosq, void *userdata, const struct mosquitto_m tst = time(NULL); if ((j = json_find_member(json, "tst")) != NULL) { - if (j && j->tag == JSON_STRING) { + if (j->tag == JSON_STRING) { tst = strtoul(j->string_, NULL, 10); json_remove_from_parent(j); json_append_member(json, "tst", json_mknumber(tst)); @@ -821,6 +821,14 @@ void on_message(struct mosquitto *mosq, void *userdata, const struct mosquitto_m goto cleanup; } + if ((j = json_find_member(json, "acc")) != NULL) { + if (j->tag == JSON_STRING) { + acc = atof(j->string_); + json_remove_from_parent(j); + json_append_member(json, "acc", json_mknumber(acc)); + } + } + if ((j = json_find_member(json, "tid")) != NULL) { if (j->tag == JSON_STRING) { tid = strdup(j->string_);