routeros-scripts/gps-track

36 lines
831 B
Text
Raw Normal View History

#
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";
: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 \
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=("{" . \
"\"lat\":\"" . $gpslat . "\"," . \
"\"lon\":\"" . $gpslon . "\"," . \
"\"identity\":\"" . $identity . "\"" . \
"}");
:log debug ("Sending gps data for tracking: " . \
"lat: " . $gpslat . " " . \
"lon: " . $gpslon);
}