aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/protocol
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2021-01-25 22:46:13 -0800
committerAnton Tananaev <anton.tananaev@gmail.com>2021-01-25 22:46:19 -0800
commit050941422cc6fe9581ac87f8cbd7196ed304ede8 (patch)
treefa0d2f8afa6e1b14c00d6e75f8b9873c373501c3 /src/main/java/org/traccar/protocol
parent136d44701594bd88e19aef026b929eff764d9f2d (diff)
downloadtrackermap-server-050941422cc6fe9581ac87f8cbd7196ed304ede8.tar.gz
trackermap-server-050941422cc6fe9581ac87f8cbd7196ed304ede8.tar.bz2
trackermap-server-050941422cc6fe9581ac87f8cbd7196ed304ede8.zip
Alternative identifier method
Diffstat (limited to 'src/main/java/org/traccar/protocol')
-rw-r--r--src/main/java/org/traccar/protocol/KhdProtocolDecoder.java15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/main/java/org/traccar/protocol/KhdProtocolDecoder.java b/src/main/java/org/traccar/protocol/KhdProtocolDecoder.java
index 343b78cb5..16ad616ed 100644
--- a/src/main/java/org/traccar/protocol/KhdProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/KhdProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2014 - 2018 Anton Tananaev (anton@traccar.org)
+ * Copyright 2014 - 2021 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,6 +16,7 @@
package org.traccar.protocol;
import io.netty.buffer.ByteBuf;
+import io.netty.buffer.ByteBufUtil;
import io.netty.buffer.Unpooled;
import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
@@ -38,12 +39,18 @@ public class KhdProtocolDecoder extends BaseProtocolDecoder {
super(protocol);
}
- private String readSerialNumber(ByteBuf buf) {
+ private String[] readIdentifiers(ByteBuf buf) {
+ String[] identifiers = new String[2];
+
+ identifiers[0] = ByteBufUtil.hexDump(buf, buf.readerIndex(), 4);
+
int b1 = buf.readUnsignedByte();
int b2 = buf.readUnsignedByte() - 0x80;
int b3 = buf.readUnsignedByte() - 0x80;
int b4 = buf.readUnsignedByte();
- return String.format("%02d%02d%02d%02d", b1, b2, b3, b4);
+ identifiers[1] = String.format("%02d%02d%02d%02d", b1, b2, b3, b4);
+
+ return identifiers;
}
public static final int MSG_LOGIN = 0xB1;
@@ -93,7 +100,7 @@ public class KhdProtocolDecoder extends BaseProtocolDecoder {
Position position = new Position(getProtocolName());
- DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, readSerialNumber(buf));
+ DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, readIdentifiers(buf));
if (deviceSession == null) {
return null;
}