aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2021-01-26 21:42:03 -0800
committerAnton Tananaev <anton.tananaev@gmail.com>2021-01-26 21:42:03 -0800
commit25bdd38bb7fb6afa1eb32a9108ed37f13d6079b6 (patch)
treee7ffa3371b8c222378d59c207652ed728ae81f4e
parent050941422cc6fe9581ac87f8cbd7196ed304ede8 (diff)
downloadtrackermap-server-25bdd38bb7fb6afa1eb32a9108ed37f13d6079b6.tar.gz
trackermap-server-25bdd38bb7fb6afa1eb32a9108ed37f13d6079b6.tar.bz2
trackermap-server-25bdd38bb7fb6afa1eb32a9108ed37f13d6079b6.zip
Decode ICCID result
-rw-r--r--src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java12
-rw-r--r--src/test/java/org/traccar/protocol/Gt06ProtocolDecoderTest.java4
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"));