aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2018-11-26 10:46:20 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2018-11-26 10:46:20 +1300
commite21c10d3c11e62ab7310eef37cc7e83fd6b16baf (patch)
tree5d5c1a4e316ed95050ebdad1006e6ee9f5997fd0
parent3099d53fae70aa2f7aba0c123b1feecd8f072ef1 (diff)
downloadtraccar-server-e21c10d3c11e62ab7310eef37cc7e83fd6b16baf.tar.gz
traccar-server-e21c10d3c11e62ab7310eef37cc7e83fd6b16baf.tar.bz2
traccar-server-e21c10d3c11e62ab7310eef37cc7e83fd6b16baf.zip
Support GT06 Lango OBD data
-rw-r--r--src/org/traccar/protocol/Gt06ProtocolDecoder.java48
-rw-r--r--test/org/traccar/protocol/Gt06ProtocolDecoderTest.java3
2 files changed, 51 insertions, 0 deletions
diff --git a/src/org/traccar/protocol/Gt06ProtocolDecoder.java b/src/org/traccar/protocol/Gt06ProtocolDecoder.java
index 9431af030..f9c65f08b 100644
--- a/src/org/traccar/protocol/Gt06ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gt06ProtocolDecoder.java
@@ -94,6 +94,9 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
public static final int MSG_FENCE_MULTI = 0xA4;
public static final int MSG_LBS_ALARM = 0xA5;
public static final int MSG_LBS_ADDRESS = 0xA7;
+ public static final int MSG_OBD = 0x8C;
+ public static final int MSG_DTC = 0x65;
+ public static final int MSG_PID = 0x66;
private static boolean isSupported(int type) {
return hasGps(type) || hasLbs(type) || hasStatus(type);
@@ -820,6 +823,51 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
return position;
+ } else if (type == MSG_OBD) {
+
+ DateBuilder dateBuilder = new DateBuilder(deviceSession.getTimeZone())
+ .setDate(buf.readUnsignedByte(), buf.readUnsignedByte(), buf.readUnsignedByte())
+ .setTime(buf.readUnsignedByte(), buf.readUnsignedByte(), buf.readUnsignedByte());
+
+ getLastLocation(position, dateBuilder.getDate());
+
+ position.set(Position.KEY_IGNITION, buf.readUnsignedByte() > 0);
+
+ String data = buf.readCharSequence(buf.readableBytes() - 18, StandardCharsets.US_ASCII).toString();
+ for (String pair : data.split(",")) {
+ String[] values = pair.split("=");
+ switch (Integer.parseInt(values[0].substring(0, 2), 16)) {
+ case 40:
+ position.set(Position.KEY_ODOMETER, Integer.parseInt(values[1], 16) * 0.01);
+ break;
+ case 43:
+ position.set(Position.KEY_FUEL_LEVEL, Integer.parseInt(values[1], 16) * 0.01);
+ break;
+ case 45:
+ position.set(Position.KEY_COOLANT_TEMP, Integer.parseInt(values[1], 16) * 0.01);
+ break;
+ case 53:
+ position.set(Position.KEY_OBD_SPEED, Integer.parseInt(values[1], 16) * 0.01);
+ break;
+ case 54:
+ position.set(Position.KEY_RPM, Integer.parseInt(values[1], 16) * 0.01);
+ break;
+ case 71:
+ position.set(Position.KEY_FUEL_USED, Integer.parseInt(values[1], 16) * 0.01);
+ break;
+ case 73:
+ position.set(Position.KEY_HOURS, Integer.parseInt(values[1], 16) * 0.01);
+ break;
+ case 74:
+ position.set(Position.KEY_VIN, values[1]);
+ break;
+ default:
+ break;
+ }
+ }
+
+ return position;
+
}
return null;
diff --git a/test/org/traccar/protocol/Gt06ProtocolDecoderTest.java b/test/org/traccar/protocol/Gt06ProtocolDecoderTest.java
index 10a8517c6..8b7034ca8 100644
--- a/test/org/traccar/protocol/Gt06ProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/Gt06ProtocolDecoderTest.java
@@ -17,6 +17,9 @@ public class Gt06ProtocolDecoderTest extends ProtocolTest {
"78780D01086471700328358100093F040D0A"));
verifyAttributes(decoder, binary(
+ "797900de8c120b1502121b013137333d302c3232333d312c3238333d30303030303030302c3436333d30303030303035362c3437333d30303030303030662c3438333d30303030303031312c3242333d30303030303030302c3244333d30303030313839632c3335333d30303030313661382c3336333d30303032386163382c3339333d30303030303230612c3330333d30303030303561612c3439333d30303030303030302c3441333d4b4e4146323431434d4b353031343235352c3341333d30303030303338352c3530333d30303030c0041df0940f89c06700000000c800910d0a"));
+
+ verifyAttributes(decoder, binary(
"79790020940A035985708053908307060104900402788950301217070401538F0003E8210D0A"));
verifyPosition(decoder, binary(