From 2d920ecec746615281802e068044a3122a0ae90b Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Wed, 4 May 2016 12:00:39 +1200 Subject: Support for GT06 command response --- src/org/traccar/protocol/Gt06ProtocolDecoder.java | 23 +++++++++++++++++++++- .../traccar/protocol/Gt06ProtocolDecoderTest.java | 6 ++++++ 2 files changed, 28 insertions(+), 1 deletion(-) 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")); -- cgit v1.2.3