mirror of
https://git.eworm.de/cgit/routeros-scripts
synced 2025-07-16 13:04:30 +02:00
gps-track: simplify gps value handling
This commit is contained in:
parent
6ee7232408
commit
dcf795464b
1 changed files with 9 additions and 15 deletions
24
gps-track
24
gps-track
|
@ -7,17 +7,9 @@
|
||||||
:global "identity";
|
:global "identity";
|
||||||
:global "gps-track-url";
|
:global "gps-track-url";
|
||||||
|
|
||||||
:local gpslat;
|
:local gps [ / system gps monitor once as-value ];
|
||||||
:local gpslon;
|
|
||||||
:local gpsvalid;
|
|
||||||
|
|
||||||
/ system gps monitor once do={
|
if ($gps->"valid" = true) do={
|
||||||
:set $gpslat $("latitude");
|
|
||||||
:set $gpslon $("longitude");
|
|
||||||
:set $gpsvalid $("valid");
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($gpsvalid) do={
|
|
||||||
:tool fetch mode=http \
|
:tool fetch mode=http \
|
||||||
url=$"gps-track-url" \
|
url=$"gps-track-url" \
|
||||||
check-certificate=yes-without-crl \
|
check-certificate=yes-without-crl \
|
||||||
|
@ -25,11 +17,13 @@ if ($gpsvalid) do={
|
||||||
http-method=post \
|
http-method=post \
|
||||||
http-content-type="application/json" \
|
http-content-type="application/json" \
|
||||||
http-data=("{" . \
|
http-data=("{" . \
|
||||||
"\"lat\":\"" . $gpslat . "\"," . \
|
"\"lat\":\"" . ($gps->"latitude") . "\"," . \
|
||||||
"\"lon\":\"" . $gpslon . "\"," . \
|
"\"lon\":\"" . ($gps->"longitude") . "\"," . \
|
||||||
"\"identity\":\"" . $identity . "\"" . \
|
"\"identity\":\"" . $identity . "\"" . \
|
||||||
"}");
|
"}");
|
||||||
:log debug ("Sending gps data for tracking: " . \
|
:log debug ("Sending GPS data for tracking: " . \
|
||||||
"lat: " . $gpslat . " " . \
|
"lat: " . ($gps->"latitude") . " " . \
|
||||||
"lon: " . $gpslon);
|
"lon: " . ($gps->"longitude"));
|
||||||
|
} else={
|
||||||
|
:log debug ("GPS data not valid.");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue