diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2016-01-12 17:06:52 +1300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2016-01-12 17:06:52 +1300 |
commit | 8d973ed63075acfcf4b1c4809de41cb9d4a2c9db (patch) | |
tree | c43f2cb1573e76eda1816c98d55de4b4684677fa /src/org/traccar | |
parent | 751569af4d09b693ec01442ae2241ee5ec6432d7 (diff) | |
download | trackermap-server-8d973ed63075acfcf4b1c4809de41cb9d4a2c9db.tar.gz trackermap-server-8d973ed63075acfcf4b1c4809de41cb9d4a2c9db.tar.bz2 trackermap-server-8d973ed63075acfcf4b1c4809de41cb9d4a2c9db.zip |
Handle new format for Watch protocol
Diffstat (limited to 'src/org/traccar')
-rw-r--r-- | src/org/traccar/protocol/WatchProtocolDecoder.java | 19 |
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")) { |