mirror of
https://github.com/owntracks/recorder.git
synced 2026-05-05 02:36:45 +00:00
store waypoints
This commit is contained in:
@@ -298,6 +298,7 @@ As mentioned earlier, data is stored in files, and these files are relative to `
|
||||
* `msg/` contains messages received by the Messaging system.
|
||||
* `photos/` optional; contains the binary photos from a _card_.
|
||||
* `rec/` the recorder data proper. One subdirectory per user, one subdirectory therein per device. Data files are named `YYYY-MM.rec` (e.g. `2015-08.rec` for the data accumulated during the month of August 2015.
|
||||
* `waypoints/` contains a directory per user and device. Therein are individual files named by a timestamp with the JSON payload of published (i.e. shared) waypoints. The file names are timestamps because the `tst` of a waypoint is its key.
|
||||
|
||||
You should definitely **not** modify or touch these files: they remain under the control of the _recorder_. You can of course, remove old `.rec` files if they consume too much space.
|
||||
|
||||
|
||||
@@ -547,6 +547,20 @@ void on_message(struct mosquitto *mosq, void *userdata, const struct mosquitto_m
|
||||
utstring_body(username), utstring_body(device));
|
||||
|
||||
safewrite(utstring_body(ts), jsonstring);
|
||||
free(jsonstring);
|
||||
}
|
||||
} else if (_type == T_WAYPOINT) {
|
||||
if ((jsonstring = json_stringify(json, NULL)) != NULL) {
|
||||
/* Now safewrite the waypoint into a file with name UTC */
|
||||
utstring_printf(ts, "%s/waypoints/%s/%s",
|
||||
STORAGEDIR, utstring_body(username), utstring_body(device));
|
||||
if (mkpath(utstring_body(ts)) < 0) {
|
||||
perror(utstring_body(ts));
|
||||
}
|
||||
utstring_printf(ts, "/%s.json", isotime(tst));
|
||||
|
||||
safewrite(utstring_body(ts), jsonstring);
|
||||
|
||||
free(jsonstring);
|
||||
}
|
||||
}
|
||||
@@ -585,6 +599,18 @@ void on_message(struct mosquitto *mosq, void *userdata, const struct mosquitto_m
|
||||
utstring_body(addr),
|
||||
utstring_body(ghash)
|
||||
);
|
||||
} else if (_type == T_TRANSITION) {
|
||||
JsonNode *e, *d;
|
||||
|
||||
e = json_find_member(json, "event");
|
||||
d = json_find_member(json, "desc");
|
||||
printf("transition: %s %s\n",
|
||||
(e) ? e->string_ : "unknown",
|
||||
(d) ? d->string_ : "unknown");
|
||||
|
||||
} else if (_type == T_WAYPOINT) {
|
||||
j = json_find_member(json, "desc");
|
||||
printf("waypoint: %s\n", (j) ? j->string_ : "unknown desc");
|
||||
} else {
|
||||
if ((jsonstring = json_stringify(json, NULL)) != NULL) {
|
||||
printf("%s %s\n", _typestr, jsonstring);
|
||||
|
||||
Reference in New Issue
Block a user