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_);