aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol/WatchProtocolDecoder.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/traccar/protocol/WatchProtocolDecoder.java')
-rw-r--r--src/org/traccar/protocol/WatchProtocolDecoder.java19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/org/traccar/protocol/WatchProtocolDecoder.java b/src/org/traccar/protocol/WatchProtocolDecoder.java
index 00f49deb5..6b5d47023 100644
--- a/src/org/traccar/protocol/WatchProtocolDecoder.java
+++ b/src/org/traccar/protocol/WatchProtocolDecoder.java
@@ -50,9 +50,9 @@ public class WatchProtocolDecoder extends BaseProtocolDecoder {
.number("-?(d+.d+),") // latitude
.expression("([NS]),")
.number("-?(d+.d+),") // longitude
- .expression("([EW]),")
+ .expression("([EW])?,")
.number("(d+.d+),") // speed
- .number("(d+.d+),") // course
+ .number("(d+.?d*),") // course
.number("(d+.?d*),") // altitude
.number("(d+),") // satellites
.number("(d+),") // gsm
@@ -92,15 +92,18 @@ public class WatchProtocolDecoder extends BaseProtocolDecoder {
sendResponse(channel, manufacturer, id, "LK");
if (!content.isEmpty()) {
- Position position = new Position();
- position.setProtocol(getProtocolName());
- position.setDeviceId(getDeviceId());
+ String[] values = content.split(",");
+ if (values.length >= 4) {
+ Position position = new Position();
+ position.setProtocol(getProtocolName());
+ position.setDeviceId(getDeviceId());
- getLastLocation(position, null);
+ getLastLocation(position, null);
- position.set(Event.KEY_BATTERY, content.split(",")[3]);
+ position.set(Event.KEY_BATTERY, values[3]);
- return position;
+ return position;
+ }
}
} else if (type.equals("UD") || type.equals("UD2") || type.equals("AL")) {