diff options
-rw-r--r-- | src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java | 12 | ||||
-rw-r--r-- | src/test/java/org/traccar/protocol/Gt06ProtocolDecoderTest.java | 4 |
2 files changed, 12 insertions, 4 deletions
diff --git a/src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java b/src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java index 755cfe33e..c5e8809e3 100644 --- a/src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2012 - 2020 Anton Tananaev (anton@traccar.org) + * Copyright 2012 - 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. @@ -719,9 +719,13 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { int commandLength = buf.readUnsignedByte(); if (commandLength > 0) { - buf.readUnsignedByte(); // server flag (reserved) - position.set(Position.KEY_RESULT, - buf.readSlice(commandLength - 1).toString(StandardCharsets.US_ASCII)); + buf.readUnsignedInt(); // server flag (reserved) + String data = buf.readSlice(commandLength - 4).toString(StandardCharsets.US_ASCII); + if (data.startsWith("<ICCID:")) { + position.set(Position.KEY_ICCID, data.substring(7, 27)); + } else { + position.set(Position.KEY_RESULT, data); + } } } else if (type == MSG_BMS || type == MSG_BMS_2) { diff --git a/src/test/java/org/traccar/protocol/Gt06ProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/Gt06ProtocolDecoderTest.java index 4bdd5572e..eeafbbdc4 100644 --- a/src/test/java/org/traccar/protocol/Gt06ProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/Gt06ProtocolDecoderTest.java @@ -17,6 +17,10 @@ public class Gt06ProtocolDecoderTest extends ProtocolTest { verifyNull(decoder, binary( "78780D01086471700328358100093F040D0A")); + verifyAttribute(decoder, binary( + "7878281520000000003c49434349443a38393838323339303030303039373330323635303e00020d446f260d0a"), + Position.KEY_ICCID, "89882390000097302650"); + verifyNull(decoder, binary( "797900099b0380d600046f91e90d0a")); |