aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2018-09-13 12:21:54 +0200
committerGravatar Christian Hesse <mail@eworm.de>2018-09-13 12:21:54 +0200
commitdcf795464b29236fa58ad23fe996e4f77480525b (patch)
treed0d996eb1bc157feb2cc581fe1a9ebe4b843b18b
parent6ee72324080ea1fe716f3b7c696d66d6a9204743 (diff)
gps-track: simplify gps value handling
-rw-r--r--gps-track24
1 files changed, 9 insertions, 15 deletions
diff --git a/gps-track b/gps-track
index 7179254..98a4406 100644
--- a/gps-track
+++ b/gps-track
@@ -7,17 +7,9 @@
:global "identity";
:global "gps-track-url";
-:local gpslat;
-:local gpslon;
-:local gpsvalid;
+:local gps [ / system gps monitor once as-value ];
-/ system gps monitor once do={
- :set $gpslat $("latitude");
- :set $gpslon $("longitude");
- :set $gpsvalid $("valid");
-}
-
-if ($gpsvalid) do={
+if ($gps->"valid" = true) do={
:tool fetch mode=http \
url=$"gps-track-url" \
check-certificate=yes-without-crl \
@@ -25,11 +17,13 @@ if ($gpsvalid) do={
http-method=post \
http-content-type="application/json" \
http-data=("{" . \
- "\"lat\":\"" . $gpslat . "\"," . \
- "\"lon\":\"" . $gpslon . "\"," . \
+ "\"lat\":\"" . ($gps->"latitude") . "\"," . \
+ "\"lon\":\"" . ($gps->"longitude") . "\"," . \
"\"identity\":\"" . $identity . "\"" . \
"}");
- :log debug ("Sending gps data for tracking: " . \
- "lat: " . $gpslat . " " . \
- "lon: " . $gpslon);
+ :log debug ("Sending GPS data for tracking: " . \
+ "lat: " . ($gps->"latitude") . " " . \
+ "lon: " . ($gps->"longitude"));
+} else={
+ :log debug ("GPS data not valid.");
}