aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/java/org/traccar/protocol/RstProtocolDecoder.java10
-rw-r--r--src/test/java/org/traccar/protocol/RstProtocolDecoderTest.java4
2 files changed, 13 insertions, 1 deletions
diff --git a/src/main/java/org/traccar/protocol/RstProtocolDecoder.java b/src/main/java/org/traccar/protocol/RstProtocolDecoder.java
index d53675b7f..2493f0d9f 100644
--- a/src/main/java/org/traccar/protocol/RstProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/RstProtocolDecoder.java
@@ -42,7 +42,7 @@ public class RstProtocolDecoder extends BaseProtocolDecoder {
.expression("(.{5});") // firmware
.number("(d{9});") // serial number
.number("(d+);") // index
- .number("d+;") // type
+ .number("(d+);") // type
.groupBegin()
.number("(dd)-(dd)-(dddd) ") // event date
.number("(dd):(dd):(dd);") // event time
@@ -69,8 +69,10 @@ public class RstProtocolDecoder extends BaseProtocolDecoder {
.number("x{4};") // sensors
.number("(xx);") // status 1
.number("(xx);") // status 2
+ .expression("(.*)") // additional data
.groupEnd("?")
.any()
+ .text("FIM;")
.compile();
@Override
@@ -87,6 +89,7 @@ public class RstProtocolDecoder extends BaseProtocolDecoder {
String firmware = parser.next();
String serial = parser.next();
int index = parser.nextInt();
+ int type = parser.nextInt();
if (channel != null) {
String response = "RST;A;" + model + ";" + firmware + ";" + serial + ";" + index + ";6;FIM;";
@@ -133,6 +136,11 @@ public class RstProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.PREFIX_TEMP + 1, (int) parser.nextHexInt().byteValue());
position.set(Position.KEY_STATUS, (parser.nextHexInt() << 8) + parser.nextHexInt());
+ String[] values = parser.next().split(";");
+ if (type == 55) {
+ position.set(Position.KEY_DRIVER_UNIQUE_ID, values[0]);
+ }
+
return position;
} else {
diff --git a/src/test/java/org/traccar/protocol/RstProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/RstProtocolDecoderTest.java
index 0e8aefe51..fc932fe9e 100644
--- a/src/test/java/org/traccar/protocol/RstProtocolDecoderTest.java
+++ b/src/test/java/org/traccar/protocol/RstProtocolDecoderTest.java
@@ -11,6 +11,10 @@ public class RstProtocolDecoderTest extends ProtocolTest {
var decoder = inject(new RstProtocolDecoder(null));
+ verifyAttribute(decoder, text(
+ "RST;A;RST-MINIv5;V9.08;009767055;248;55;14-12-2023 19:34:20;14-12-2023 19:34:21;-12.923640;-38.388313;0;14;17;1;4;15;00;B0;00;1A;02;12.18;4.02;65;21;FE;0000;01;C0;001606017031;0002;FIM;"),
+ Position.KEY_DRIVER_UNIQUE_ID, "001606017031");
+
verifyNull(decoder, text(
"RST;A;RST-MINIv2;V7.04;008051261;124;29;04-04-2021 17:27:26;04-04-2021 17:27:26;-1.280811;-47.931755;7353;79;1;14;7315;26;10;0;1855;0;0;0;0;5;5;-1.280821;-47.931747;04-04-2021 17:52:23;6;-1.280863;-47.931770;04-04-2021 18:12:19;5;-1.280844;-47.931763;04-04-2021 17:28:02;5;-1.280900;-47.931770;04-04-2021 19:04:27;4;-1.280843;-47.931747;04-04-2021 18:21:45;04-04-2021 19:29:59;04-04-2021 19:29:59;-1.280770;-47.931595;1;15;0;0;0;0;FIM;"));