aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/java/org/traccar/protocol/IntellitracProtocolDecoder.java56
-rw-r--r--src/test/java/org/traccar/protocol/IntellitracProtocolDecoderTest.java3
2 files changed, 44 insertions, 15 deletions
diff --git a/src/main/java/org/traccar/protocol/IntellitracProtocolDecoder.java b/src/main/java/org/traccar/protocol/IntellitracProtocolDecoder.java
index 897606270..e5339bded 100644
--- a/src/main/java/org/traccar/protocol/IntellitracProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/IntellitracProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2013 - 2018 Anton Tananaev (anton@traccar.org)
+ * Copyright 2013 - 2020 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.
@@ -44,7 +44,7 @@ public class IntellitracProtocolDecoder extends BaseProtocolDecoder {
.number("(d+.?d*),") // course
.number("(-?d+.?d*),") // altitude
.number("(d+),") // satellites
- .number("(d+),") // index
+ .number("(d+),") // event
.number("(d+),") // input
.number("(d+),?") // output
.number("(d+.d+)?,?") // adc1
@@ -65,6 +65,26 @@ public class IntellitracProtocolDecoder extends BaseProtocolDecoder {
.any()
.compile();
+ private String decodeAlarm(int value) {
+ switch (value) {
+ case 164:
+ return Position.ALARM_GEOFENCE_ENTER;
+ case 165:
+ return Position.ALARM_GEOFENCE_EXIT;
+ case 168:
+ case 169:
+ return Position.ALARM_LOW_POWER;
+ case 170:
+ return Position.ALARM_POWER_OFF;
+ case 176:
+ return Position.ALARM_POWER_RESTORED;
+ case 225:
+ return Position.ALARM_JAMMING;
+ default:
+ return null;
+ }
+ }
+
@Override
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
@@ -74,12 +94,12 @@ public class IntellitracProtocolDecoder extends BaseProtocolDecoder {
return null;
}
- Position position = new Position(getProtocolName());
-
DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, parser.next());
if (deviceSession == null) {
return null;
}
+
+ Position position = new Position(getProtocolName());
position.setDeviceId(deviceSession.getDeviceId());
position.setTime(parser.nextDateTime());
@@ -92,7 +112,11 @@ public class IntellitracProtocolDecoder extends BaseProtocolDecoder {
position.setAltitude(parser.nextDouble());
position.set(Position.KEY_SATELLITES, parser.nextInt());
- position.set(Position.KEY_INDEX, parser.nextLong());
+
+ int event = parser.nextInt();
+ position.set(Position.KEY_ALARM, decodeAlarm(event));
+ position.set(Position.KEY_EVENT, event);
+
position.set(Position.KEY_INPUT, parser.nextInt());
position.set(Position.KEY_OUTPUT, parser.nextInt());
@@ -100,16 +124,18 @@ public class IntellitracProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.PREFIX_ADC + 2, parser.nextDouble());
// J1939 data
- position.set(Position.KEY_OBD_SPEED, parser.nextInt());
- position.set(Position.KEY_RPM, parser.nextInt());
- position.set("coolant", parser.nextInt());
- position.set(Position.KEY_FUEL_LEVEL, parser.nextInt());
- position.set(Position.KEY_FUEL_CONSUMPTION, parser.nextInt());
- position.set(Position.PREFIX_TEMP + 1, parser.nextInt());
- position.set("chargerPressure", parser.nextInt());
- position.set("tpl", parser.nextInt());
- position.set(Position.KEY_AXLE_WEIGHT, parser.nextInt());
- position.set(Position.KEY_OBD_ODOMETER, parser.nextInt());
+ if (parser.hasNext(10)) {
+ position.set(Position.KEY_OBD_SPEED, parser.nextInt());
+ position.set(Position.KEY_RPM, parser.nextInt());
+ position.set("coolant", parser.nextInt());
+ position.set(Position.KEY_FUEL_LEVEL, parser.nextInt());
+ position.set(Position.KEY_FUEL_CONSUMPTION, parser.nextInt());
+ position.set(Position.PREFIX_TEMP + 1, parser.nextInt());
+ position.set("chargerPressure", parser.nextInt());
+ position.set("tpl", parser.nextInt());
+ position.set(Position.KEY_AXLE_WEIGHT, parser.nextInt());
+ position.set(Position.KEY_OBD_ODOMETER, parser.nextInt());
+ }
return position;
}
diff --git a/src/test/java/org/traccar/protocol/IntellitracProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/IntellitracProtocolDecoderTest.java
index 00b7de094..eb6480213 100644
--- a/src/test/java/org/traccar/protocol/IntellitracProtocolDecoderTest.java
+++ b/src/test/java/org/traccar/protocol/IntellitracProtocolDecoderTest.java
@@ -10,6 +10,9 @@ public class IntellitracProtocolDecoderTest extends ProtocolTest {
IntellitracProtocolDecoder decoder = new IntellitracProtocolDecoder(null);
+ verifyPosition(decoder, text(
+ "359316075744331,20201008181424,12.014662,57.826301,0,76,24,10,997,3,0,0.000,4.208,20201008181424,0"));
+
verifyNull(decoder, text(
"$OK:TRACKING"));