From 8de9a36abef8e66be4fcc248b49045ffd3b5f7ae Mon Sep 17 00:00:00 2001
From: Anton Tananaev <anton@traccar.org>
Date: Tue, 30 May 2023 11:41:03 -0700
Subject: Handle missing GoSafe fields

---
 .../java/org/traccar/protocol/GoSafeProtocolDecoder.java     | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

(limited to 'src/main')

diff --git a/src/main/java/org/traccar/protocol/GoSafeProtocolDecoder.java b/src/main/java/org/traccar/protocol/GoSafeProtocolDecoder.java
index 77649a041..f17ea0e08 100644
--- a/src/main/java/org/traccar/protocol/GoSafeProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/GoSafeProtocolDecoder.java
@@ -93,14 +93,14 @@ public class GoSafeProtocolDecoder extends BaseProtocolDecoder {
                     position.setSpeed(UnitsConverter.knotsFromKph(Integer.parseInt(values[index - 1])));
                 }
                 position.setCourse(Integer.parseInt(values[index++]));
-                if (index < values.length) {
-                    position.setAltitude(Integer.parseInt(values[index++]));
+                if (index < values.length && !values[index++].isEmpty()) {
+                    position.setAltitude(Integer.parseInt(values[index - 1]));
                 }
-                if (index < values.length) {
-                    position.set(Position.KEY_HDOP, Double.parseDouble(values[index++]));
+                if (index < values.length && !values[index++].isEmpty()) {
+                    position.set(Position.KEY_HDOP, Double.parseDouble(values[index - 1]));
                 }
-                if (index < values.length) {
-                    position.set(Position.KEY_VDOP, Double.parseDouble(values[index++]));
+                if (index < values.length && !values[index++].isEmpty()) {
+                    position.set(Position.KEY_VDOP, Double.parseDouble(values[index - 1]));
                 }
                 break;
             case "GSM":
-- 
cgit v1.2.3