diff options
-rw-r--r-- | src/org/traccar/protocol/Gt02ProtocolDecoder.java | 13 | ||||
-rw-r--r-- | test/org/traccar/protocol/Gt02ProtocolDecoderTest.java | 6 |
2 files changed, 17 insertions, 2 deletions
diff --git a/src/org/traccar/protocol/Gt02ProtocolDecoder.java b/src/org/traccar/protocol/Gt02ProtocolDecoder.java index d93b93b83..dea1416ac 100644 --- a/src/org/traccar/protocol/Gt02ProtocolDecoder.java +++ b/src/org/traccar/protocol/Gt02ProtocolDecoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2012 - 2015 Anton Tananaev (anton.tananaev@gmail.com) + * Copyright 2012 - 2016 Anton Tananaev (anton.tananaev@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,6 +26,7 @@ import org.traccar.helper.UnitsConverter; import org.traccar.model.Position; import java.net.SocketAddress; +import java.nio.charset.StandardCharsets; public class Gt02ProtocolDecoder extends BaseProtocolDecoder { @@ -33,8 +34,9 @@ public class Gt02ProtocolDecoder extends BaseProtocolDecoder { super(protocol); } - public static final int MSG_HEARTBEAT = 0x1A; public static final int MSG_DATA = 0x10; + public static final int MSG_HEARTBEAT = 0x1A; + public static final int MSG_RESPONSE = 0x1C; @Override protected Object decode( @@ -102,6 +104,13 @@ public class Gt02ProtocolDecoder extends BaseProtocolDecoder { position.setLatitude(latitude); position.setLongitude(longitude); + } else if (type == MSG_RESPONSE) { + + getLastLocation(position, null); + + position.set(Position.KEY_RESULT, + buf.readBytes(buf.readUnsignedByte()).toString(StandardCharsets.US_ASCII)); + } else { return null; diff --git a/test/org/traccar/protocol/Gt02ProtocolDecoderTest.java b/test/org/traccar/protocol/Gt02ProtocolDecoderTest.java index 3cfa0ea4a..c957acd6c 100644 --- a/test/org/traccar/protocol/Gt02ProtocolDecoderTest.java +++ b/test/org/traccar/protocol/Gt02ProtocolDecoderTest.java @@ -11,6 +11,12 @@ public class Gt02ProtocolDecoderTest extends ProtocolTest { Gt02ProtocolDecoder decoder = new Gt02ProtocolDecoder(new Gt02Protocol()); verifyAttributes(decoder, binary( + "6868150000035889905895258400831c07415045584f4b210d0a")); + + verifyAttributes(decoder, binary( + "68682d0000035889905895258400951c1f415045584572726f723a20506172616d65746572203120284f4e2f4f4646290d0a")); + + verifyAttributes(decoder, binary( "68680f0504035889905831401700df1a00000d0a")); verifyAttributes(decoder, binary( |