From 7fd3161c2f97c0cfe140666c22eb7a151463c228 Mon Sep 17 00:00:00 2001 From: Jan-Piet Mens Date: Sat, 15 Aug 2015 09:04:50 +0200 Subject: [PATCH] ensure payload is written to REC even if not location --- ot-recorder.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ot-recorder.c b/ot-recorder.c index 7a1ad79..81821ac 100644 --- a/ot-recorder.c +++ b/ot-recorder.c @@ -442,9 +442,16 @@ void on_message(struct mosquitto *mosq, void *userdata, const struct mosquitto_m /* Is it OwnTracks Greenwich CSV? */ if ((json = csv(m->payload, tid, t, &lat, &lon, &tst)) == NULL) { + /* It's not JSON or it's not a location CSV; store it */ + if ((fp = pathn("a", "rec", username, device, "rec")) != NULL) { + fprintf(fp, RECFORMAT, isotime(now), + utstring_body(rest), + bindump(m->payload, m->payloadlen)); + fclose(fp); + } return; } - fprintf(stderr, "+++++ %s\n", json_stringify(json, NULL)); + // fprintf(stderr, "+++++ %s\n", json_stringify(json, NULL)); } #if 0