diff options
-rw-r--r-- | src/org/traccar/protocol/Gt06ProtocolDecoder.java | 23 | ||||
-rw-r--r-- | test/org/traccar/protocol/Gt06ProtocolDecoderTest.java | 6 |
2 files changed, 28 insertions, 1 deletions
diff --git a/src/org/traccar/protocol/Gt06ProtocolDecoder.java b/src/org/traccar/protocol/Gt06ProtocolDecoder.java index e83ced668..d55ff1f83 100644 --- a/src/org/traccar/protocol/Gt06ProtocolDecoder.java +++ b/src/org/traccar/protocol/Gt06ProtocolDecoder.java @@ -16,6 +16,7 @@ package org.traccar.protocol; import java.net.SocketAddress; +import java.nio.charset.Charset; import java.util.TimeZone; import org.jboss.netty.buffer.ChannelBuffer; @@ -203,7 +204,27 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { } else if (hasDeviceId()) { - if (isSupported(type)) { + if (type == MSG_STRING) { + + Position position = new Position(); + position.setDeviceId(getDeviceId()); + position.setProtocol(getProtocolName()); + + getLastLocation(position, null); + + int commandLength = buf.readUnsignedByte(); + + buf.readUnsignedByte(); // server flag (reserved) + + position.set("command", buf.readBytes(commandLength - 1).toString(Charset.defaultCharset())); + + buf.readUnsignedShort(); // language + + sendResponse(channel, type, buf.readUnsignedShort()); + + return position; + + } else if (isSupported(type)) { Position position = new Position(); position.setDeviceId(getDeviceId()); diff --git a/test/org/traccar/protocol/Gt06ProtocolDecoderTest.java b/test/org/traccar/protocol/Gt06ProtocolDecoderTest.java index d925ffec3..3bcd2ec3a 100644 --- a/test/org/traccar/protocol/Gt06ProtocolDecoderTest.java +++ b/test/org/traccar/protocol/Gt06ProtocolDecoderTest.java @@ -16,6 +16,12 @@ public class Gt06ProtocolDecoderTest extends ProtocolTest { verifyNothing(decoder, binary( "78780D01086471700328358100093F040D0A")); + verifyAttributes(decoder, binary( + "78782d152500000000437574206f666620746865206675656c20737570706c793a2053756363657373210002013b898a0d0a")); + + verifyAttributes(decoder, binary( + "787829152100000000526573746f7265206675656c20737570706c793a2053756363657373210002014077ce0d0a")); + verifyNothing(decoder, binary( "78780D01012345678901234500018CDD0D0A")); |