aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2019-01-23 00:11:11 -0800
committerAnton Tananaev <anton.tananaev@gmail.com>2019-01-23 00:11:11 -0800
commit9ca14dcccffc65b9c4c2683bc53e13b796fa1228 (patch)
treecb38e939a1e251106ec8bfda68f9c364a8f37680
parentc8d39587a20ecc0d0b591fe09018e9d55694bf22 (diff)
downloadtrackermap-server-9ca14dcccffc65b9c4c2683bc53e13b796fa1228.tar.gz
trackermap-server-9ca14dcccffc65b9c4c2683bc53e13b796fa1228.tar.bz2
trackermap-server-9ca14dcccffc65b9c4c2683bc53e13b796fa1228.zip
Special GT06 LBS responses
-rw-r--r--src/org/traccar/protocol/Gt06ProtocolDecoder.java34
-rw-r--r--test/org/traccar/protocol/Gt06ProtocolDecoderTest.java6
2 files changed, 28 insertions, 12 deletions
diff --git a/src/org/traccar/protocol/Gt06ProtocolDecoder.java b/src/org/traccar/protocol/Gt06ProtocolDecoder.java
index f9c65f08b..18b3f508d 100644
--- a/src/org/traccar/protocol/Gt06ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gt06ProtocolDecoder.java
@@ -67,7 +67,6 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
public static final int MSG_GPS_LBS_STATUS_3 = 0x27;
public static final int MSG_LBS_MULTIPLE = 0x28;
public static final int MSG_LBS_WIFI = 0x2C;
- public static final int MSG_LBS_PHONE = 0x17;
public static final int MSG_LBS_EXTEND = 0x18;
public static final int MSG_LBS_STATUS = 0x19;
public static final int MSG_GPS_PHONE = 0x1A;
@@ -389,7 +388,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
return position;
}
- private Object decodeBasic(Channel channel, SocketAddress remoteAddress, ByteBuf buf) throws Exception {
+ private Object decodeBasic(Channel channel, SocketAddress remoteAddress, ByteBuf buf) {
int length = buf.readUnsignedByte();
int dataLength = length - 5;
@@ -488,7 +487,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
} else if (type == MSG_WIFI || type == MSG_WIFI_2) {
- return decodeWifi(buf, deviceSession);
+ return decodeWifi(channel, buf, deviceSession, type);
} else if (type == MSG_INFO) {
@@ -559,18 +558,19 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
return null;
}
- private Object decodeWifi(ByteBuf buf, DeviceSession deviceSession) throws Exception {
+ private Object decodeWifi(Channel channel, ByteBuf buf, DeviceSession deviceSession, int type) {
Position position = new Position(getProtocolName());
position.setDeviceId(deviceSession.getDeviceId());
+ ByteBuf time = buf.readSlice(6);
DateBuilder dateBuilder = new DateBuilder()
- .setYear(BcdUtil.readInteger(buf, 2))
- .setMonth(BcdUtil.readInteger(buf, 2))
- .setDay(BcdUtil.readInteger(buf, 2))
- .setHour(BcdUtil.readInteger(buf, 2))
- .setMinute(BcdUtil.readInteger(buf, 2))
- .setSecond(BcdUtil.readInteger(buf, 2));
+ .setYear(BcdUtil.readInteger(time, 2))
+ .setMonth(BcdUtil.readInteger(time, 2))
+ .setDay(BcdUtil.readInteger(time, 2))
+ .setHour(BcdUtil.readInteger(time, 2))
+ .setMinute(BcdUtil.readInteger(time, 2))
+ .setSecond(BcdUtil.readInteger(time, 2));
getLastLocation(position, dateBuilder.getDate());
Network network = new Network();
@@ -593,11 +593,21 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
position.setNetwork(network);
+ if (channel != null) {
+ ByteBuf response = Unpooled.buffer();
+ response.writeByte(0);
+ response.writeByte(type);
+ response.writeBytes(time.resetReaderIndex());
+ response.writeByte('\r');
+ response.writeByte('\n');
+ channel.writeAndFlush(new NetworkMessage(response, channel.remoteAddress()));
+ }
+
return position;
}
private Object decodeBasicOther(Channel channel, ByteBuf buf,
- DeviceSession deviceSession, int type, int dataLength) throws Exception {
+ DeviceSession deviceSession, int type, int dataLength) {
Position position = new Position(getProtocolName());
position.setDeviceId(deviceSession.getDeviceId());
@@ -701,7 +711,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
return position;
}
- private Object decodeExtended(Channel channel, SocketAddress remoteAddress, ByteBuf buf) throws Exception {
+ private Object decodeExtended(Channel channel, SocketAddress remoteAddress, ByteBuf buf) {
DeviceSession deviceSession = getDeviceSession(channel, remoteAddress);
if (deviceSession == null) {
diff --git a/test/org/traccar/protocol/Gt06ProtocolDecoderTest.java b/test/org/traccar/protocol/Gt06ProtocolDecoderTest.java
index 8b7034ca8..6cc2d3f86 100644
--- a/test/org/traccar/protocol/Gt06ProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/Gt06ProtocolDecoderTest.java
@@ -16,6 +16,12 @@ public class Gt06ProtocolDecoderTest extends ProtocolTest {
verifyNull(decoder, binary(
"78780D01086471700328358100093F040D0A"));
+ verifyNotNull(decoder, binary(
+ "7878006919012105090303028f01007549e05a00bc9c5c5a007a8d1a5a0d0a"));
+
+ verifyNotNull(decoder, binary(
+ "7878001719011910543607028f0100bc2e695a00bcb3635a00bc27c56400bc447b6400bc46c96400bc33ce6400bc64ca640d0a"));
+
verifyAttributes(decoder, binary(
"797900de8c120b1502121b013137333d302c3232333d312c3238333d30303030303030302c3436333d30303030303035362c3437333d30303030303030662c3438333d30303030303031312c3242333d30303030303030302c3244333d30303030313839632c3335333d30303030313661382c3336333d30303032386163382c3339333d30303030303230612c3330333d30303030303561612c3439333d30303030303030302c3441333d4b4e4146323431434d4b353031343235352c3341333d30303030303338352c3530333d30303030c0041df0940f89c06700000000c800910d0a"));