aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2021-02-27 16:01:41 -0800
committerAnton Tananaev <anton.tananaev@gmail.com>2021-02-27 16:01:41 -0800
commit74555e6c149dd4782afd28efea3f45a876892b2c (patch)
tree5b7e1b751739def5dd59638ea055e097da1e1b15
parentfb8fcb940ee0faedecff130554ae62971f5ccb85 (diff)
downloadtraccar-server-74555e6c149dd4782afd28efea3f45a876892b2c.tar.gz
traccar-server-74555e6c149dd4782afd28efea3f45a876892b2c.tar.bz2
traccar-server-74555e6c149dd4782afd28efea3f45a876892b2c.zip
Support RTPL protocol
-rw-r--r--src/main/java/org/traccar/protocol/SiwiProtocolDecoder.java35
-rw-r--r--src/test/java/org/traccar/protocol/SiwiProtocolDecoderTest.java9
2 files changed, 40 insertions, 4 deletions
diff --git a/src/main/java/org/traccar/protocol/SiwiProtocolDecoder.java b/src/main/java/org/traccar/protocol/SiwiProtocolDecoder.java
index 6b97f5fe0..bf8bfab77 100644
--- a/src/main/java/org/traccar/protocol/SiwiProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/SiwiProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 - 2018 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 - 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.
@@ -38,12 +38,12 @@ public class SiwiProtocolDecoder extends BaseProtocolDecoder {
.number("(d+),") // device id
.number("d+,") // unit no
.expression("([A-Z]),") // reason
- .number("d+,") // command code
+ .number("d*,") // command code
.number("[^,]*,") // command value
.expression("([01]),") // ignition
.expression("[01],") // power cut
- .expression("[01],") // box open
- .number("d+,") // message key
+ .number("d+,") // flags
+ .number("[^,]+,")
.number("(d+),") // odometer
.number("(d+),") // speed
.number("(d+),") // satellites
@@ -54,6 +54,19 @@ public class SiwiProtocolDecoder extends BaseProtocolDecoder {
.number("(d+),") // course
.number("(dd)(dd)(dd),") // time (hhmmss)
.number("(dd)(dd)(dd),") // date (ddmmyy)
+ .number("d+,") // signal strength
+ .number("d+,") // gsm status
+ .number("d+,") // error code
+ .number("d+,") // internal status
+ .number("(d+),") // battery
+ .number("(d+),") // adc
+ .number("(d+),") // digital inputs
+ .number("(d+),") // sensor 1
+ .number("(d+),") // sensor 2
+ .number("(d+),") // sensor 3
+ .number("(d+),") // sensor 4
+ .expression("([^,]+),") // hw version
+ .expression("([^,]+),") // sw version
.any()
.compile();
@@ -90,6 +103,20 @@ public class SiwiProtocolDecoder extends BaseProtocolDecoder {
position.setTime(parser.nextDateTime(Parser.DateTimeFormat.HMS_DMY, "IST"));
+ position.set(Position.KEY_BATTERY, parser.nextInt() * 0.001);
+ position.set(Position.PREFIX_ADC + 1, parser.nextInt() * 0.01);
+ position.set(Position.KEY_INPUT, parser.nextInt());
+
+ for (int i = 1; i <= 4; i++) {
+ int value = parser.nextInt();
+ if (value != 0) {
+ position.set(Position.PREFIX_IO + i, value);
+ }
+ }
+
+ position.set(Position.KEY_VERSION_HW, parser.next());
+ position.set(Position.KEY_VERSION_FW, parser.next());
+
return position;
}
diff --git a/src/test/java/org/traccar/protocol/SiwiProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/SiwiProtocolDecoderTest.java
index 3a91d8482..79c7d888b 100644
--- a/src/test/java/org/traccar/protocol/SiwiProtocolDecoderTest.java
+++ b/src/test/java/org/traccar/protocol/SiwiProtocolDecoderTest.java
@@ -11,6 +11,15 @@ public class SiwiProtocolDecoderTest extends ProtocolTest {
SiwiProtocolDecoder decoder = new SiwiProtocolDecoder(null);
verifyPosition(decoder, text(
+ "$SIWI,868957040831465,44,E,,,1,1,1,16.79,0,0,5,A,17.204447,78.355087,534,44,140955,180221,11,1,15,5,4322,0,0,0,0,0,0,1.0,1.6CPTASF_6.60,0!"));
+
+ verifyPosition(decoder, text(
+ "$SIWI,868957040777510,13,E,,,0,1,1,24.15,1118097,0,18,A,16.080666,80.331451,0,29,142451,180221,24,1,15,5,4282,2269,0,0,0,0,0,1.0,1.6CPASF_6.60,0!"));
+
+ verifyPosition(decoder, text(
+ "$RTPL,1234567890123,45,E,,89917650642221590319,0,1,0,12.36,141313,0,9,A,21.981985,85.221165,804,280,105113,220420,17,1,13,5,4071,1,0,8,0,0,0,1.0,1.2CPLUS_6.52,0!"));
+
+ verifyPosition(decoder, text(
"$SIWI,9803932,23992,E,0,,0,1,1,0,5055,0,5,A,22.289887,70.807192,152,168,102922,090317,28,1,12,5,4098,1,0,13,0,0,0,1.0,3.1CHKS_4.82,0!"));
verifyPosition(decoder, text(