aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/org/traccar/protocol/Ivt401ProtocolDecoder.java62
-rw-r--r--test/org/traccar/protocol/Ivt401ProtocolDecoderTest.java21
2 files changed, 76 insertions, 7 deletions
diff --git a/src/org/traccar/protocol/Ivt401ProtocolDecoder.java b/src/org/traccar/protocol/Ivt401ProtocolDecoder.java
index 936965707..6e11a763c 100644
--- a/src/org/traccar/protocol/Ivt401ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Ivt401ProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 - 2018 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.
@@ -43,7 +43,7 @@ public class Ivt401ProtocolDecoder extends BaseProtocolDecoder {
.number("(d+),") // speed
.number("(d+),") // course
.number("(-?d+.?d*),") // altitude
- .number("(d+),") // satellites
+ .number("d+,") // satellites or battery status
.number("(d),") // gps status
.number("(d+),") // rssi
.number("(d+),") // input
@@ -51,6 +51,13 @@ public class Ivt401ProtocolDecoder extends BaseProtocolDecoder {
.number("(d+.d+),") // adc
.number("(d+.d+),") // power
.number("(d+.d+),") // battery
+ .number("(-?d+.?d*),") // pcb temp
+ .expression("([^,]+),") // temp
+ .number("(d+),") // movement
+ .number("(d+.d+),") // acceleration
+ .number("(-?d+),") // tilt
+ .number("(d+),") // trip
+ .number("(d+),") // odometer
.any()
.compile();
@@ -78,17 +85,58 @@ public class Ivt401ProtocolDecoder extends BaseProtocolDecoder {
position.setSpeed(UnitsConverter.knotsFromKph(parser.nextInt()));
position.setCourse(parser.nextInt());
position.setAltitude(parser.nextDouble());
-
- position.set(Position.KEY_SATELLITES, parser.nextInt());
-
position.setValid(parser.nextInt() > 0);
position.set(Position.KEY_RSSI, parser.nextInt());
- position.set(Position.KEY_INPUT, parser.nextBinInt());
- position.set(Position.KEY_OUTPUT, parser.nextBinInt());
+
+ String input = parser.next();
+ for (int i = 0; i < input.length(); i++) {
+ int value = Character.getNumericValue(input.charAt(i));
+ if (value < 2) {
+ position.set(Position.PREFIX_IN + (i + 1), value > 0);
+ }
+ }
+
+ String output = parser.next();
+ for (int i = 0; i < output.length(); i++) {
+ position.set(Position.PREFIX_OUT + (i + 1), Character.getNumericValue(output.charAt(i)) > 0);
+ }
+
position.set(Position.PREFIX_ADC + 1, parser.nextDouble());
position.set(Position.KEY_POWER, parser.nextDouble());
position.set(Position.KEY_BATTERY, parser.nextDouble());
+ position.set(Position.KEY_DEVICE_TEMP, parser.nextDouble());
+
+ String temp = parser.next();
+ if (temp.startsWith("M")) {
+ int index = 1;
+ int startIndex = 1;
+ int endIndex;
+ while (startIndex < temp.length()) {
+ endIndex = temp.indexOf('-', startIndex + 1);
+ if (endIndex < 0) {
+ endIndex = temp.indexOf('+', startIndex + 1);
+ }
+ if (endIndex < 0) {
+ endIndex = temp.length();
+ }
+ if (endIndex > 0) {
+ double value = Double.parseDouble(temp.substring(startIndex, endIndex));
+ position.set(Position.PREFIX_TEMP + index++, value);
+ }
+ startIndex = endIndex;
+ }
+ } else {
+ position.set(Position.PREFIX_TEMP + 1, Double.parseDouble(temp));
+ }
+
+ position.set(Position.KEY_MOTION, parser.nextInt() > 0);
+ position.set(Position.KEY_ACCELERATION, parser.nextDouble());
+
+ parser.nextInt(); // tilt
+ parser.nextInt(); // trip state
+
+ position.set(Position.KEY_ODOMETER, parser.nextLong());
return position;
}
diff --git a/test/org/traccar/protocol/Ivt401ProtocolDecoderTest.java b/test/org/traccar/protocol/Ivt401ProtocolDecoderTest.java
index c0f076014..032d252b4 100644
--- a/test/org/traccar/protocol/Ivt401ProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/Ivt401ProtocolDecoderTest.java
@@ -11,6 +11,27 @@ public class Ivt401ProtocolDecoderTest extends ProtocolTest {
Ivt401ProtocolDecoder decoder = new Ivt401ProtocolDecoder(new Ivt401Protocol());
verifyPosition(decoder, text(
+ "(TLN,865933030026336,250118,063827,+18.598098,+73.806518,0,79,0,1,1,5,1200,0,0.0,11.50,4.00,36,0,0,1.00,0,0,12702,202,0)"));
+
+ verifyPosition(decoder, text(
+ "(TLA,865933030026336,250118,063838,+18.598110,+73.806518,0,334,0,1,1,5,1200,0,0.0,12.20,4.10,36,0,0,1.00,0,0,12704,0,0,0,0,0,0,0,0,0,0,0,0,1,0,3,203,0)"));
+
+ verifyNull(decoder, text(
+ "(TLB,356917050440515,0,0,+0.0,+0.0,0,0,0,0,0,0,000,00,0.00,12.21,7.95,26.57,0.0,1,1.12,0,0,0,1,90)"));
+
+ verifyPosition(decoder, text(
+ "(TLN,356917050440515,250118,094723,+0.0,+0.0,0,0,0,0,3,5,000,00,0.00,12.25,7.95,27.11,0.0,0,1.13,0,0,0,4,86)"));
+
+ verifyPosition(decoder, text(
+ "(TLA,356917050440515,250118,094733,+0.0,+0.0,0,0,0,0,3,5,000,00,0.00,12.25,7.95,27.20,0.0,0,1.12,0,0,0,0,0,0,0,000000000,0,1,0,0,0,0,0,1,0,0,5,70)"));
+
+ verifyPosition(decoder, text(
+ "(TLN,356917050440515,250118,094733,+0.0,+0.0,0,0,0,0,3,5,000,00,0.00,12.25,7.95,27.20,0.0,0,1.13,0,0,0,6,87)"));
+
+ verifyPosition(decoder, text(
+ "(TLN,356917050440515,250118,103541,+17.015546,+54.080841,0,0,31,12,1,5,000,00,0.0,0.00,8.04,28.59,M+0+0+0+0+0,0,1.12,0,0,2,48,30)"));
+
+ verifyPosition(decoder, text(
"(TLN,356917050291991,090315,133525,+12.990582,+77.589080,0,0,944,13,1,5,000,00,0.00,10.88,6.31,29.55,0.00,0,0.99,66,0,0,88,95)"));
verifyPosition(decoder, text(