aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2019-03-21 22:35:57 -0700
committerAnton Tananaev <anton.tananaev@gmail.com>2019-03-21 22:35:57 -0700
commita7c067243085ad62eefe5e6643b48ddd99793ad0 (patch)
tree5ca6e3c19d0fd96d4fb3a6b78b272f2d9850af3a
parentc249e72c20c2046eef91fd602279e11e218159a3 (diff)
downloadtraccar-server-a7c067243085ad62eefe5e6643b48ddd99793ad0.tar.gz
traccar-server-a7c067243085ad62eefe5e6643b48ddd99793ad0.tar.bz2
traccar-server-a7c067243085ad62eefe5e6643b48ddd99793ad0.zip
Additional ITS attributes
-rw-r--r--src/org/traccar/protocol/ItsProtocolDecoder.java26
-rw-r--r--test/org/traccar/protocol/ItsProtocolDecoderTest.java3
2 files changed, 29 insertions, 0 deletions
diff --git a/src/org/traccar/protocol/ItsProtocolDecoder.java b/src/org/traccar/protocol/ItsProtocolDecoder.java
index a200ff8b7..a12b75961 100644
--- a/src/org/traccar/protocol/ItsProtocolDecoder.java
+++ b/src/org/traccar/protocol/ItsProtocolDecoder.java
@@ -63,6 +63,22 @@ public class ItsProtocolDecoder extends BaseProtocolDecoder {
.number("(d+.?d*),") // speed
.number("(d+.?d*),") // course
.number("(d+),") // satellites
+ .groupBegin()
+ .number("(d+.?d*),") // altitude
+ .number("d+.?d*,") // pdop
+ .number("d+.?d*,") // hdop
+ .expression("[^,]*,")
+ .number("([01]),") // ignition
+ .number("([01]),") // charging
+ .number("(d+.?d*),") // power
+ .number("(d+.?d*),") // battery
+ .number("[01],") // emergency
+ .expression("[CO]?,") // tamper
+ .number("(?:x+,){5}") // main cell
+ .number("(?:-?x+,){12}") // other cells
+ .number("([01]{4}),") // inputs
+ .number("([01]{2}),") // outputs
+ .groupEnd("?")
.or()
.number("(-?d+.d+),") // altitude
.number("(d+.d+),") // speed
@@ -109,6 +125,16 @@ public class ItsProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_SATELLITES, parser.nextInt());
}
+ if (parser.hasNext(7)) {
+ position.setAltitude(parser.nextDouble());
+ position.set(Position.KEY_IGNITION, parser.nextInt() > 0);
+ position.set(Position.KEY_CHARGE, parser.nextInt() > 0);
+ position.set(Position.KEY_POWER, parser.nextDouble());
+ position.set(Position.KEY_BATTERY, parser.nextDouble());
+ position.set(Position.KEY_INPUT, parser.nextBinInt());
+ position.set(Position.KEY_OUTPUT, parser.nextBinInt());
+ }
+
if (parser.hasNext(2)) {
position.setAltitude(parser.nextDouble());
position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble()));
diff --git a/test/org/traccar/protocol/ItsProtocolDecoderTest.java b/test/org/traccar/protocol/ItsProtocolDecoderTest.java
index 0281320a9..8fef81bbc 100644
--- a/test/org/traccar/protocol/ItsProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/ItsProtocolDecoderTest.java
@@ -11,6 +11,9 @@ public class ItsProtocolDecoderTest extends ProtocolTest {
ItsProtocolDecoder decoder = new ItsProtocolDecoder(null);
verifyPosition(decoder, text(
+ "$,03,XYZ123,0.0.1,TA,16,L,869867035297185,MH12AB1234,1,20,02,2019,10,59,13,023.482630,N,086.399673,E,000.1,015.19,21,212.3,01.12,00.58,NOSERV,0,1,00.0,4.6,1,C,11,404,75,082a,db3a,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,01,000013,01dbd51f,"));
+
+ verifyPosition(decoder, text(
"$NRM,ROADRPA,1.7AIS,NR,01,L,869867036345389,,1,25022019,051716,25.12891000,N,75.85587833,E,7.6,350.00,14,284.8,1.00,1.00,AIRTEL,1,1,28.0,4.2,0,C,13,404,70,4E3B,3C84,11,4E3B,39B8,08,4E3B,3965,07,4E3B,48B5,07,4E3B,3C85,0000,00,000551,71978C6B"));
verifyPosition(decoder, text(