normalize acc to double

This commit is contained in:
Jan-Piet Mens
2015-12-09 12:52:20 +01:00
parent 1e79015aae
commit 43d6e54035

View File

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