From 0c5fa5cc8ea437db3c449b158310c5783aaea3ef Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Fri, 9 Mar 2018 15:25:30 +1300 Subject: Fix Watch protocol decoding --- src/org/traccar/protocol/WatchProtocolDecoder.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/org') diff --git a/src/org/traccar/protocol/WatchProtocolDecoder.java b/src/org/traccar/protocol/WatchProtocolDecoder.java index 6adcb34f2..1dd07a3f7 100644 --- a/src/org/traccar/protocol/WatchProtocolDecoder.java +++ b/src/org/traccar/protocol/WatchProtocolDecoder.java @@ -48,7 +48,7 @@ public class WatchProtocolDecoder extends BaseProtocolDecoder { .expression("([NS]),") .number(" *(-?d+.d+),") // longitude .expression("([EW])?,") - .number("(d+.d+),") // speed + .number("(d+.?d*),") // speed .number("(d+.?d*),") // course .number("(d+.?d*),") // altitude .number("(d+),") // satellites @@ -139,7 +139,7 @@ public class WatchProtocolDecoder extends BaseProtocolDecoder { String manufacturer = buf.readBytes(2).toString(StandardCharsets.US_ASCII); buf.skipBytes(1); // delimiter - int idLength = buf.indexOf(buf.readerIndex(), buf.writerIndex(), (byte) '*'); + int idLength = buf.indexOf(buf.readerIndex(), buf.writerIndex(), (byte) '*') - buf.readerIndex(); String id = buf.readBytes(idLength).toString(StandardCharsets.US_ASCII); DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, id); if (deviceSession == null) { @@ -150,7 +150,7 @@ public class WatchProtocolDecoder extends BaseProtocolDecoder { String index = null; if (idLength > 10) { - int indexLength = buf.indexOf(buf.readerIndex(), buf.writerIndex(), (byte) '*'); + int indexLength = buf.indexOf(buf.readerIndex(), buf.writerIndex(), (byte) '*') - buf.readerIndex(); index = buf.readBytes(indexLength).toString(StandardCharsets.US_ASCII); buf.skipBytes(1); // delimiter } -- cgit v1.2.3