aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-07-07 17:28:49 -0700
committerAnton Tananaev <anton@traccar.org>2022-07-07 17:28:49 -0700
commit30d920c2e49c4022af8590c7d200907cde16d1c9 (patch)
tree7e8157b8b5709a0a8c056907e123e7266fd41e86 /src
parent09eebb35449c4ffb43b6a72bb4c3f723ec1c84be (diff)
downloadtrackermap-server-30d920c2e49c4022af8590c7d200907cde16d1c9.tar.gz
trackermap-server-30d920c2e49c4022af8590c7d200907cde16d1c9.tar.bz2
trackermap-server-30d920c2e49c4022af8590c7d200907cde16d1c9.zip
Decode Concox CRX1 serial
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java15
-rw-r--r--src/test/java/org/traccar/protocol/Gt06ProtocolDecoderTest.java4
2 files changed, 14 insertions, 5 deletions
diff --git a/src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java b/src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java
index c53fbfe5a..63210b2fa 100644
--- a/src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java
@@ -1004,11 +1004,16 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
} else if (subType == 0x1b) {
- buf.readUnsignedByte(); // header
- buf.readUnsignedByte(); // type
- position.set(Position.KEY_DRIVER_UNIQUE_ID, ByteBufUtil.hexDump(buf.readSlice(4)));
- buf.readUnsignedByte(); // checksum
- buf.readUnsignedByte(); // footer
+ if (Character.isLetter(buf.getUnsignedByte(buf.readerIndex()))) {
+ String data = buf.readCharSequence(buf.readableBytes() - 6, StandardCharsets.US_ASCII).toString();
+ position.set("serial", data.trim());
+ } else {
+ buf.readUnsignedByte(); // header
+ buf.readUnsignedByte(); // type
+ position.set(Position.KEY_DRIVER_UNIQUE_ID, ByteBufUtil.hexDump(buf.readSlice(4)));
+ buf.readUnsignedByte(); // checksum
+ buf.readUnsignedByte(); // footer
+ }
return position;
}
diff --git a/src/test/java/org/traccar/protocol/Gt06ProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/Gt06ProtocolDecoderTest.java
index 5b355e4f5..8c54fe3e4 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(
+ "79790019941b524649443a3030384642324245424133390d0a000c14930d0a"),
+ "serial", "RFID:008FB2BEBA39");
+
+ verifyAttribute(decoder, binary(
"7878241216040e102c22cf00915ffb04c6016300195a02d402283b00753f400571040001dda4880d0a"),
Position.KEY_IGNITION, false);