aboutsummaryrefslogtreecommitdiffstats
path: root/gps-track
blob: 98a4406a5d5b700e8ed34a45c1e33c015003027f (about) (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#
# 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 gps [ / system gps monitor once as-value ];

if ($gps->"valid" = true) do={
  :tool fetch mode=http \
    url=$"gps-track-url" \
    check-certificate=yes-without-crl \
    keep-result=no \
    http-method=post \
    http-content-type="application/json" \
    http-data=("{" . \
      "\"lat\":\"" . ($gps->"latitude") . "\"," . \
      "\"lon\":\"" . ($gps->"longitude") . "\"," . \
      "\"identity\":\"" . $identity . "\"" . \
    "}");
  :log debug ("Sending GPS data for tracking: " . \
    "lat: " . ($gps->"latitude") . " " . \
    "lon: " . ($gps->"longitude"));
} else={
  :log debug ("GPS data not valid.");
}