aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2021-06-16 20:49:33 -0700
committerAnton Tananaev <anton.tananaev@gmail.com>2021-06-16 20:49:33 -0700
commitdb45cf357db965691f87bff6d206608189afb25e (patch)
tree742ca081d6b10cf118187fba2fffc9a605676f77
parent372743857314a0dfad83eef65ed2418a62dae04b (diff)
downloadtraccar-server-db45cf357db965691f87bff6d206608189afb25e.tar.gz
traccar-server-db45cf357db965691f87bff6d206608189afb25e.tar.bz2
traccar-server-db45cf357db965691f87bff6d206608189afb25e.zip
Support AM01 protocol
-rw-r--r--src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java17
-rw-r--r--src/test/java/org/traccar/protocol/Gt06ProtocolDecoderTest.java6
2 files changed, 17 insertions, 6 deletions
diff --git a/src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java b/src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java
index 6d49be0ce..3f3a96109 100644
--- a/src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java
@@ -60,6 +60,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
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;
+ public static final int MSG_GPS_LBS_4 = 0x2D;
public static final int MSG_STATUS = 0x13;
public static final int MSG_SATELLITE = 0x14;
public static final int MSG_STRING = 0x15;
@@ -67,7 +68,8 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
public static final int MSG_WIFI = 0x17;
public static final int MSG_GPS_LBS_STATUS_2 = 0x26;
public static final int MSG_GPS_LBS_STATUS_3 = 0x27;
- public static final int MSG_LBS_MULTIPLE = 0x28;
+ public static final int MSG_LBS_MULTIPLE_1 = 0x28;
+ public static final int MSG_LBS_MULTIPLE_2 = 0x2E;
public static final int MSG_LBS_WIFI = 0x2C;
public static final int MSG_LBS_EXTEND = 0x18;
public static final int MSG_LBS_STATUS = 0x19;
@@ -117,6 +119,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
case MSG_GPS_LBS_1:
case MSG_GPS_LBS_2:
case MSG_GPS_LBS_3:
+ case MSG_GPS_LBS_4:
case MSG_GPS_LBS_STATUS_1:
case MSG_GPS_LBS_STATUS_2:
case MSG_GPS_LBS_STATUS_3:
@@ -138,6 +141,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
case MSG_GPS_LBS_1:
case MSG_GPS_LBS_2:
case MSG_GPS_LBS_3:
+ case MSG_GPS_LBS_4:
case MSG_GPS_LBS_STATUS_1:
case MSG_GPS_LBS_STATUS_2:
case MSG_GPS_LBS_STATUS_3:
@@ -170,7 +174,8 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
case MSG_GPS_PHONE:
case MSG_HEARTBEAT:
case MSG_GPS_LBS_STATUS_3:
- case MSG_LBS_MULTIPLE:
+ case MSG_LBS_MULTIPLE_1:
+ case MSG_LBS_MULTIPLE_2:
case MSG_LBS_2:
case MSG_FENCE_MULTI:
return true;
@@ -680,8 +685,8 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
Position position = new Position(getProtocolName());
position.setDeviceId(deviceSession.getDeviceId());
- if (type == MSG_LBS_MULTIPLE || type == MSG_LBS_EXTEND || type == MSG_LBS_WIFI
- || type == MSG_LBS_2 || type == MSG_WIFI_3) {
+ if (type == MSG_LBS_MULTIPLE_1 || type == MSG_LBS_MULTIPLE_2 || type == MSG_LBS_EXTEND
+ || type == MSG_LBS_WIFI || type == MSG_LBS_2 || type == MSG_WIFI_3) {
boolean longFormat = type == MSG_LBS_2 || type == MSG_WIFI_3;
@@ -705,7 +710,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
buf.readUnsignedByte(); // time leads
- if (type != MSG_LBS_MULTIPLE && type != MSG_LBS_2) {
+ if (type != MSG_LBS_MULTIPLE_1 && type != MSG_LBS_MULTIPLE_2 && type != MSG_LBS_2) {
int wifiCount = buf.readUnsignedByte();
for (int i = 0; i < wifiCount; i++) {
String mac = ByteBufUtil.hexDump(buf.readSlice(6)).replaceAll("(..)", "$1:");
@@ -912,7 +917,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
}
}
- if ((type == MSG_GPS_LBS_2 || type == MSG_GPS_LBS_3) && buf.readableBytes() >= 3 + 6) {
+ if ((type == MSG_GPS_LBS_2 || type == MSG_GPS_LBS_3 || type == MSG_GPS_LBS_4) && buf.readableBytes() >= 3 + 6) {
position.set(Position.KEY_IGNITION, buf.readUnsignedByte() > 0);
position.set(Position.KEY_EVENT, buf.readUnsignedByte()); // reason
position.set(Position.KEY_ARCHIVE, buf.readUnsignedByte() > 0);
diff --git a/src/test/java/org/traccar/protocol/Gt06ProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/Gt06ProtocolDecoderTest.java
index ab1fc33f4..f3e5779e8 100644
--- a/src/test/java/org/traccar/protocol/Gt06ProtocolDecoderTest.java
+++ b/src/test/java/org/traccar/protocol/Gt06ProtocolDecoderTest.java
@@ -17,6 +17,12 @@ public class Gt06ProtocolDecoderTest extends ProtocolTest {
verifyNull(decoder, binary(
"78780D01086471700328358100093F040D0A"));
+ verifyNotNull(decoder, binary(
+ "78783B2E10010D02020201CC00287D001F713E287D001F7231287D001E232D287D001F4018000000000000000000000000000000000000FF00020005B14B0D0A"));
+
+ verifyPosition(decoder, binary(
+ "787822220F0C1D023305C9027AC8180C46586000140001CC00287D001F71000001000820860D0A"));
+
verifyAttribute(decoder, binary(
"78782b1215050d03041bcf031ff30a0be795bc001c17014e14a065dd95314504b6040000001c00000cd90ab8fb6f0d0a"),
Position.PREFIX_TEMP + 1, 0x1c);