diff options
author | Anton Tananaev <anton@traccar.org> | 2022-10-13 07:22:20 -0700 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2022-10-13 07:22:20 -0700 |
commit | acedd28b8584a18022d9e2343558f9acbad1666f (patch) | |
tree | e9862c94c93a9674bfca48aa3f437be4d3731f87 | |
parent | c801d33f44ae346d01e19e47a3b97c8405f4d5b4 (diff) | |
download | trackermap-server-acedd28b8584a18022d9e2343558f9acbad1666f.tar.gz trackermap-server-acedd28b8584a18022d9e2343558f9acbad1666f.tar.bz2 trackermap-server-acedd28b8584a18022d9e2343558f9acbad1666f.zip |
Support OBD6 status message
-rw-r--r-- | src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java | 38 | ||||
-rw-r--r-- | src/test/java/org/traccar/protocol/Gt06ProtocolDecoderTest.java | 4 |
2 files changed, 30 insertions, 12 deletions
diff --git a/src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java b/src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java index a93c11cbc..212b4245f 100644 --- a/src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java @@ -118,6 +118,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { S5, SPACE10X, STANDARD, + OBD6, } private Variant variant; @@ -346,7 +347,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { return true; } - private void decodeStatus(Position position, ByteBuf buf, boolean batteryLevel) { + private void decodeStatus(Position position, ByteBuf buf) { int status = buf.readUnsignedByte(); @@ -381,13 +382,6 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { default: break; } - - if (batteryLevel) { - position.set(Position.KEY_BATTERY_LEVEL, buf.readUnsignedByte() * 100 / 6); - } else { - position.set(Position.KEY_POWER, buf.readUnsignedShort() * 0.01); - } - position.set(Position.KEY_RSSI, buf.readUnsignedByte()); } private String decodeAlarm(short value) { @@ -793,8 +787,22 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { } if (hasStatus(type)) { - decodeStatus(position, buf, true); - position.set(Position.KEY_ALARM, decodeAlarm(buf.readUnsignedByte())); + decodeStatus(position, buf); + if (variant == Variant.OBD6) { + int signal = buf.readUnsignedShort(); + int satellites = BitUtil.between(signal, 10, 15) + BitUtil.between(signal, 5, 10); + position.set(Position.KEY_SATELLITES, satellites); + position.set(Position.KEY_RSSI, BitUtil.to(signal, 5)); + position.set(Position.KEY_ALARM, decodeAlarm(buf.readUnsignedByte())); + buf.readUnsignedByte(); // language + position.set(Position.KEY_BATTERY_LEVEL, buf.readUnsignedByte()); + buf.readUnsignedByte(); // working mode + position.set(Position.KEY_POWER, buf.readUnsignedShort() / 100.0); + } else { + position.set(Position.KEY_BATTERY_LEVEL, buf.readUnsignedByte() * 100 / 6); + position.set(Position.KEY_RSSI, buf.readUnsignedByte()); + position.set(Position.KEY_ALARM, decodeAlarm(buf.readUnsignedByte())); + } } if (type == MSG_GPS_LBS_1) { @@ -823,10 +831,14 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { } } } else if (variant == Variant.VXT01) { - decodeStatus(position, buf, false); + decodeStatus(position, buf); + position.set(Position.KEY_POWER, buf.readUnsignedShort() * 0.01); + position.set(Position.KEY_RSSI, buf.readUnsignedByte()); buf.readUnsignedByte(); // alarm extension } else if (variant == Variant.S5) { - decodeStatus(position, buf, false); + decodeStatus(position, buf); + position.set(Position.KEY_POWER, buf.readUnsignedShort() * 0.01); + position.set(Position.KEY_RSSI, buf.readUnsignedByte()); position.set(Position.KEY_ALARM, decodeAlarm(buf.readUnsignedByte())); position.set("oil", buf.readUnsignedShort()); int temperature = buf.readUnsignedByte(); @@ -1355,6 +1367,8 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { variant = Variant.S5; } else if (header == 0x7878 && type == MSG_LBS_STATUS && length >= 0x17) { variant = Variant.SPACE10X; + } else if (header == 0x7878 && type == MSG_STATUS && length == 0x13) { + variant = Variant.OBD6; } else { variant = Variant.STANDARD; } diff --git a/src/test/java/org/traccar/protocol/Gt06ProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/Gt06ProtocolDecoderTest.java index ebda38823..d1789bb16 100644 --- a/src/test/java/org/traccar/protocol/Gt06ProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/Gt06ProtocolDecoderTest.java @@ -18,6 +18,10 @@ public class Gt06ProtocolDecoderTest extends ProtocolTest { "78780D01086471700328358100093F040D0A")); verifyAttribute(decoder, binary( + "7878131302801900002e42016f000000003a0177ef180d0a"), + Position.KEY_POWER, 3.67); + + verifyAttribute(decoder, binary( "78782526160913063918c002780fab0c44750f00040008027f14084c0038420600030c020007398e0d0a"), Position.KEY_ALARM, Position.ALARM_TAMPERING); |