diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2018-11-26 10:46:20 +1300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2018-11-26 10:46:20 +1300 |
commit | e21c10d3c11e62ab7310eef37cc7e83fd6b16baf (patch) | |
tree | 5d5c1a4e316ed95050ebdad1006e6ee9f5997fd0 /src | |
parent | 3099d53fae70aa2f7aba0c123b1feecd8f072ef1 (diff) | |
download | traccar-server-e21c10d3c11e62ab7310eef37cc7e83fd6b16baf.tar.gz traccar-server-e21c10d3c11e62ab7310eef37cc7e83fd6b16baf.tar.bz2 traccar-server-e21c10d3c11e62ab7310eef37cc7e83fd6b16baf.zip |
Support GT06 Lango OBD data
Diffstat (limited to 'src')
-rw-r--r-- | src/org/traccar/protocol/Gt06ProtocolDecoder.java | 48 |
1 files changed, 48 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; |