routeros-scripts/gps-track

30 lines
818 B
Text
Raw Normal View History

#!rsc
2018-08-06 12:21:55 +00:00
# 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";
2018-09-13 10:21:54 +00:00
:local gps [ / system gps monitor once as-value ];
2018-08-06 12:21:55 +00:00
2018-09-13 10:21:54 +00:00
if ($gps->"valid" = true) do={
2018-08-06 12:21:55 +00:00
:tool fetch mode=http \
url=$"gps-track-url" \
check-certificate=yes-without-crl \
2018-08-06 13:35:26 +00:00
keep-result=no \
2018-08-06 12:21:55 +00:00
http-method=post \
http-content-type="application/json" \
http-data=("{" . \
2018-09-13 10:21:54 +00:00
"\"lat\":\"" . ($gps->"latitude") . "\"," . \
"\"lon\":\"" . ($gps->"longitude") . "\"," . \
2018-08-06 12:21:55 +00:00
"\"identity\":\"" . $identity . "\"" . \
"}");
2018-09-13 10:21:54 +00:00
:log debug ("Sending GPS data for tracking: " . \
"lat: " . ($gps->"latitude") . " " . \
"lon: " . ($gps->"longitude"));
} else={
:log debug ("GPS data not valid.");
2018-08-06 12:21:55 +00:00
}