aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/org/traccar/protocol/WatchProtocolDecoder.java6
-rw-r--r--test/org/traccar/protocol/WatchProtocolDecoderTest.java18
2 files changed, 12 insertions, 12 deletions
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
}
diff --git a/test/org/traccar/protocol/WatchProtocolDecoderTest.java b/test/org/traccar/protocol/WatchProtocolDecoderTest.java
index 46b4c1cd0..657cb0640 100644
--- a/test/org/traccar/protocol/WatchProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/WatchProtocolDecoderTest.java
@@ -11,15 +11,6 @@ public class WatchProtocolDecoderTest extends ProtocolTest {
WatchProtocolDecoder decoder = new WatchProtocolDecoder(new WatchProtocol());
verifyPosition(decoder, buffer(
- "[ZJ*014111001350304*0033*0064*UD,070318,020827,V,00.000000,N,000.000000,E,0,0,0,0,100,19,1000,50,00000000,1,255,460,0,9346,5223,42]"));
-
- verifyPosition(decoder, buffer(
- "[ZJ*014111001350304*0035*0097*UD,070318,020857,V,00.000000,N,000.000000,E,0,0,0,0,100,19,1000,50,00000000,5,255,460,0,9346,5223,42,9346,5214,21,9784,4083,13,9346,5222,11,9346,5221,8]"));
-
- verifyPosition(decoder, buffer(
- "[ZJ*014111001350304*0038*008a*UD,070318,021027,V,00.000000,N,000.000000,E,0,0,0,0,100,18,1000,50,00000000,4,255,460,0,9346,5223,42,9346,5214,20,9784,4083,11,9346,5221,5]"));
-
- verifyPosition(decoder, buffer(
"[3G*8308373902*0080*AL,230817,095346,A,47.083950,N,15.4821850,E,7.60,273.8,0.0,4,15,44,0,0,00200010,2,255,232,1,7605,42530,118,7605,58036,119,0,65.8]"));
verifyPosition(decoder, buffer(
@@ -93,6 +84,15 @@ public class WatchProtocolDecoderTest extends ProtocolTest {
verifyAttributes(decoder, buffer(
"[3G*6005412902*0008*heart,71]"));
+ verifyPosition(decoder, buffer(
+ "[ZJ*014111001350304*0033*0064*UD,070318,020827,V,00.000000,N,000.000000,E,0,0,0,0,100,19,1000,50,00000000,1,255,460,0,9346,5223,42]"));
+
+ verifyPosition(decoder, buffer(
+ "[ZJ*014111001350304*0035*0097*UD,070318,020857,V,00.000000,N,000.000000,E,0,0,0,0,100,19,1000,50,00000000,5,255,460,0,9346,5223,42,9346,5214,21,9784,4083,13,9346,5222,11,9346,5221,8]"));
+
+ verifyPosition(decoder, buffer(
+ "[ZJ*014111001350304*0038*008a*UD,070318,021027,V,00.000000,N,000.000000,E,0,0,0,0,100,18,1000,50,00000000,4,255,460,0,9346,5223,42,9346,5214,20,9784,4083,11,9346,5221,5]"));
+
}
}