aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/traccar/protocol/KhdProtocolDecoder.java22
-rw-r--r--src/test/java/org/traccar/protocol/KhdProtocolDecoderTest.java4
2 files changed, 23 insertions, 3 deletions
diff --git a/src/main/java/org/traccar/protocol/KhdProtocolDecoder.java b/src/main/java/org/traccar/protocol/KhdProtocolDecoder.java
index dd2e1dbfd..e88b34478 100644
--- a/src/main/java/org/traccar/protocol/KhdProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/KhdProtocolDecoder.java
@@ -20,6 +20,7 @@ import io.netty.buffer.ByteBufUtil;
import io.netty.buffer.Unpooled;
import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
+import org.traccar.helper.BufferUtil;
import org.traccar.session.DeviceSession;
import org.traccar.NetworkMessage;
import org.traccar.Protocol;
@@ -169,7 +170,9 @@ public class KhdProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_FUEL_LEVEL, BitUtil.from(odometer, 16));
}
- position.set(Position.KEY_STATUS, buf.readUnsignedInt());
+ long status = buf.readUnsignedInt();
+ position.set(Position.KEY_IGNITION, BitUtil.check(status, 7 + 3 * 8));
+ position.set(Position.KEY_STATUS, status);
buf.readUnsignedShort();
buf.readUnsignedByte();
@@ -185,8 +188,7 @@ public class KhdProtocolDecoder extends BaseProtocolDecoder {
buf.readUnsignedShort(); // data length
int dataType = buf.readUnsignedByte();
-
- buf.readUnsignedByte(); // content length
+ int dataLength = buf.readUnsignedByte();
switch (dataType) {
case 0x01:
@@ -197,6 +199,20 @@ public class KhdProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.PREFIX_TEMP + 1,
buf.readUnsignedByte() * 100 + buf.readUnsignedByte());
break;
+ case 0x05:
+ int sign = buf.readUnsignedByte();
+ switch (sign) {
+ case 1:
+ position.set("sign", true);
+ break;
+ case 2:
+ position.set("sign", false);
+ break;
+ default:
+ break;
+ }
+ position.set(Position.KEY_DRIVER_UNIQUE_ID, BufferUtil.readString(buf, dataLength - 1));
+ break;
case 0x18:
for (int i = 1; i <= 4; i++) {
double value = buf.readUnsignedShort();
diff --git a/src/test/java/org/traccar/protocol/KhdProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/KhdProtocolDecoderTest.java
index 7cc65002b..3097c02e8 100644
--- a/src/test/java/org/traccar/protocol/KhdProtocolDecoderTest.java
+++ b/src/test/java/org/traccar/protocol/KhdProtocolDecoderTest.java
@@ -12,6 +12,10 @@ public class KhdProtocolDecoderTest extends ProtocolTest {
var decoder = inject(new KhdProtocolDecoder(null));
verifyAttribute(decoder, binary(
+ "2929A300403099934C2004030943310000000000000000000000007B0000007FFF0E0000E70014000000000018050B01303030314330334437312102007B2203140DDA610D"),
+ Position.KEY_DRIVER_UNIQUE_ID, "0001C03D71");
+
+ verifyAttribute(decoder, binary(
"2929a3003e1680ba0a2304180759500000000000000000000000007b00000080001914000000000000000000162001641b0b0000249002bc58030001cc46020000e70d"),
Position.KEY_BATTERY_LEVEL, 100);