aboutsummaryrefslogtreecommitdiffstats
path: root/gps-track
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2018-08-06 14:21:55 +0200
committerGravatar Christian Hesse <mail@eworm.de>2018-08-06 14:21:55 +0200
commit2ec96e9db4dddea7ea9aa34996395c445b20cb67 (patch)
tree7a96e3169bb36300c0a67093c00121acf290bd37 /gps-track
parent7fcb7a6b61a0c34a92e19ef5f35a82042f1bee11 (diff)
add script 'gps-track'
Diffstat (limited to 'gps-track')
-rw-r--r--gps-track33
1 files changed, 33 insertions, 0 deletions
diff --git a/gps-track b/gps-track
new file mode 100644
index 0000000..bb4f370
--- /dev/null
+++ b/gps-track
@@ -0,0 +1,33 @@
+# RouterOS script: gps-track
+# Copyright (c) 2018 Christian Hesse <mail@eworm.de>
+#
+# track gps data by sending json data to http server
+
+:global "identity";
+:global "gps-track-url";
+
+:local gpslat;
+:local gpslon;
+:local gpsvalid;
+
+/ system gps monitor once do={
+ :set $gpslat $("latitude");
+ :set $gpslon $("longitude");
+ :set $gpsvalid $("valid");
+}
+
+if ($gpsvalid) do={
+ :tool fetch mode=http \
+ url=$"gps-track-url" \
+ check-certificate=yes-without-crl \
+ http-method=post \
+ http-content-type="application/json" \
+ http-data=("{" . \
+ "\"lat\":\"" . $gpslat . "\"," . \
+ "\"lon\":\"" . $gpslon . "\"," . \
+ "\"identity\":\"" . $identity . "\"" . \
+ "}");
+ :log debug ("Sending gps data for tracking: " . \
+ "lat: " . $gpslat . " " . \
+ "lon: " . $gpslon);
+}