aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2021-11-11 20:44:24 -0800
committerAnton Tananaev <anton.tananaev@gmail.com>2021-11-11 20:44:24 -0800
commitee709450564299831dc90e648f6f11bb9e19b6d0 (patch)
tree82ba563e834b11716fbd739a6cbba2401066f819 /src
parent113f9a7a1295eb84174c40cb7f4bed61bdec2423 (diff)
downloadtraccar-server-ee709450564299831dc90e648f6f11bb9e19b6d0.tar.gz
traccar-server-ee709450564299831dc90e648f6f11bb9e19b6d0.tar.bz2
traccar-server-ee709450564299831dc90e648f6f11bb9e19b6d0.zip
Support new GT06 variation
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java18
-rw-r--r--src/test/java/org/traccar/protocol/Gt06ProtocolDecoderTest.java3
2 files changed, 13 insertions, 8 deletions
diff --git a/src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java b/src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java
index 45218aba2..0dcdab892 100644
--- a/src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java
@@ -56,7 +56,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
public static final int MSG_LOGIN = 0x01;
public static final int MSG_GPS = 0x10;
- public static final int MSG_LBS = 0x11;
+ public static final int MSG_GPS_LBS_6 = 0x11;
public static final int MSG_GPS_LBS_1 = 0x12;
public static final int MSG_GPS_LBS_2 = 0x22;
public static final int MSG_GPS_LBS_3 = 0x37;
@@ -124,6 +124,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
case MSG_GPS_LBS_3:
case MSG_GPS_LBS_4:
case MSG_GPS_LBS_5:
+ case MSG_GPS_LBS_6:
case MSG_GPS_LBS_STATUS_1:
case MSG_GPS_LBS_STATUS_2:
case MSG_GPS_LBS_STATUS_3:
@@ -141,13 +142,13 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
private static boolean hasLbs(int type) {
switch (type) {
- case MSG_LBS:
case MSG_LBS_STATUS:
case MSG_GPS_LBS_1:
case MSG_GPS_LBS_2:
case MSG_GPS_LBS_3:
case MSG_GPS_LBS_4:
case MSG_GPS_LBS_5:
+ case MSG_GPS_LBS_6:
case MSG_GPS_LBS_STATUS_1:
case MSG_GPS_LBS_STATUS_2:
case MSG_GPS_LBS_STATUS_3:
@@ -275,7 +276,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
return true;
}
- private boolean decodeLbs(Position position, ByteBuf buf, boolean hasLength) {
+ private boolean decodeLbs(Position position, ByteBuf buf, int type, boolean hasLength) {
int length = 0;
if (hasLength) {
@@ -296,10 +297,11 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
}
int mcc = buf.readUnsignedShort();
- int mnc = BitUtil.check(mcc, 15) ? buf.readUnsignedShort() : buf.readUnsignedByte();
+ int mnc = BitUtil.check(mcc, 15) || type == MSG_GPS_LBS_6 ? buf.readUnsignedShort() : buf.readUnsignedByte();
+ int lac = buf.readUnsignedShort();
+ long cid = type == MSG_GPS_LBS_6 ? buf.readUnsignedInt() : buf.readUnsignedMedium();
- position.setNetwork(new Network(CellTower.from(
- BitUtil.to(mcc, 15), mnc, buf.readUnsignedShort(), buf.readUnsignedMedium())));
+ position.setNetwork(new Network(CellTower.from(BitUtil.to(mcc, 15), mnc, lac, cid)));
if (length > 9) {
buf.skipBytes(length - 9);
@@ -885,7 +887,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
}
if (hasLbs(type)) {
- decodeLbs(position, buf, hasStatus(type));
+ decodeLbs(position, buf, type, hasStatus(type));
}
if (hasStatus(type)) {
@@ -1053,7 +1055,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
getLastLocation(position, position.getDeviceTime());
}
- if (decodeLbs(position, buf, true)) {
+ if (decodeLbs(position, buf, type, true)) {
position.set(Position.KEY_RSSI, buf.readUnsignedByte());
}
diff --git a/src/test/java/org/traccar/protocol/Gt06ProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/Gt06ProtocolDecoderTest.java
index 3caba32e6..d2d090c04 100644
--- a/src/test/java/org/traccar/protocol/Gt06ProtocolDecoderTest.java
+++ b/src/test/java/org/traccar/protocol/Gt06ProtocolDecoderTest.java
@@ -18,6 +18,9 @@ public class Gt06ProtocolDecoderTest extends ProtocolTest {
"78780D01086471700328358100093F040D0A"));
verifyNotNull(decoder, binary(
+ "78782111150b0b022c30c804b7af7808810cb0003c00012e02d075df0084890c000679950d0a"));
+
+ verifyNotNull(decoder, binary(
"797900377000000001020035000103002c0004616219d00043000b013601048153931500001a0001000808652820400643521000000101004e46760d0a"));
verifyNull(decoder, binary(