From 1e29eeb388dff8f9cbb7e47e53146d4da87d3c81 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 13 Jun 2023 09:28:32 +0200 Subject: gps-track: add error handling --- gps-track.rsc | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'gps-track.rsc') diff --git a/gps-track.rsc b/gps-track.rsc index 29d2572..0d328d5 100644 --- a/gps-track.rsc +++ b/gps-track.rsc @@ -24,16 +24,20 @@ $WaitFullyConnected; :local Gps [ /system/gps/monitor once as-value ]; :if ($Gps->"valid" = true) do={ - /tool/fetch check-certificate=yes-without-crl $GpsTrackUrl output=none \ - http-method=post http-header-field="Content-Type: application/json" \ - http-data=("{" . \ - "\"lat\":\"" . ($Gps->"latitude") . "\"," . \ - "\"lon\":\"" . ($Gps->"longitude") . "\"," . \ - "\"identity\":\"" . $Identity . "\"" . \ - "}") as-value; - $LogPrintExit2 debug $0 ("Sending GPS data in " . $CoordinateFormat . " format: " . \ - "lat: " . ($Gps->"latitude") . " " . \ - "lon: " . ($Gps->"longitude")) false; + :do { + /tool/fetch check-certificate=yes-without-crl $GpsTrackUrl output=none \ + http-method=post http-header-field="Content-Type: application/json" \ + http-data=("{" . \ + "\"lat\":\"" . ($Gps->"latitude") . "\"," . \ + "\"lon\":\"" . ($Gps->"longitude") . "\"," . \ + "\"identity\":\"" . $Identity . "\"" . \ + "}") as-value; + $LogPrintExit2 debug $0 ("Sending GPS data in " . $CoordinateFormat . " format: " . \ + "lat: " . ($Gps->"latitude") . " " . \ + "lon: " . ($Gps->"longitude")) false; + } on-error={ + $LogPrintExit2 warning $0 ("Failed sending GPS data!") false; + } } else={ $LogPrintExit2 debug $0 ("GPS data not valid.") false; } -- cgit v1.2.3-54-g00ecf