mirror of
https://github.com/eworm-de/routeros-scripts
synced 2024-05-14 08:04:19 +00:00
add script 'gps-track'
This commit is contained in:
parent
7fcb7a6b61
commit
2ec96e9db4
|
@ -37,6 +37,9 @@
|
|||
# ntp settings. A pool can rotate servers.
|
||||
:global "ntp-pool" "pool.ntp.org";
|
||||
|
||||
# This is the address used to send gps data to.
|
||||
:global "gps-track-url" "https://example.com/index.php";
|
||||
|
||||
# Enable this to fetch scripts from given url.
|
||||
:global "script-updates-fetch" true;
|
||||
:global "script-updates-baseurl" "https://git.eworm.de/cgit.cgi/routeros-scripts/plain/";
|
||||
|
|
33
gps-track
Normal file
33
gps-track
Normal file
|
@ -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);
|
||||
}
|
Loading…
Reference in a new issue