diff options
Diffstat (limited to 'src/org')
-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; |