aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/traccar/protocol/ItsProtocolDecoder.java8
-rw-r--r--src/test/java/org/traccar/protocol/ItsProtocolDecoderTest.java5
2 files changed, 12 insertions, 1 deletions
diff --git a/src/main/java/org/traccar/protocol/ItsProtocolDecoder.java b/src/main/java/org/traccar/protocol/ItsProtocolDecoder.java
index 482f34e65..17833dda9 100644
--- a/src/main/java/org/traccar/protocol/ItsProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/ItsProtocolDecoder.java
@@ -45,7 +45,7 @@ public class ItsProtocolDecoder extends BaseProtocolDecoder {
.number("d+,")
.expression("[LH],") // history
.or()
- .expression("[^,]+,") // type
+ .expression("([^,]+),") // type
.groupEnd()
.number("(d{15}),") // imei
.groupBegin()
@@ -121,6 +121,8 @@ public class ItsProtocolDecoder extends BaseProtocolDecoder {
return null;
}
+ String type = parser.next();
+
DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, parser.next());
if (deviceSession == null) {
return null;
@@ -129,6 +131,10 @@ public class ItsProtocolDecoder extends BaseProtocolDecoder {
Position position = new Position(getProtocolName());
position.setDeviceId(deviceSession.getDeviceId());
+ if (type != null && type.equals("EMR")) {
+ position.set(Position.KEY_ALARM, Position.ALARM_SOS);
+ }
+
if (parser.hasNext()) {
position.set(Position.KEY_ALARM, decodeAlarm(parser.next()));
}
diff --git a/src/test/java/org/traccar/protocol/ItsProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/ItsProtocolDecoderTest.java
index 94095b2f2..f833cb6b9 100644
--- a/src/test/java/org/traccar/protocol/ItsProtocolDecoderTest.java
+++ b/src/test/java/org/traccar/protocol/ItsProtocolDecoderTest.java
@@ -2,6 +2,7 @@ package org.traccar.protocol;
import org.junit.Test;
import org.traccar.ProtocolTest;
+import org.traccar.model.Position;
public class ItsProtocolDecoderTest extends ProtocolTest {
@@ -10,6 +11,10 @@ public class ItsProtocolDecoderTest extends ProtocolTest {
ItsProtocolDecoder decoder = new ItsProtocolDecoder(null);
+ verifyAttribute(decoder, text(
+ "$EPB,EMR,869867036066035,NM,03042019,192008,V,000.00000000,N,000.00000000,E,0000000000.0,0000.0,00.000,G,,0,404,22,ECFB,36EF*226F7BD1"),
+ Position.KEY_ALARM, Position.ALARM_SOS);
+
verifyPosition(decoder, text(
"$,CP,ATL,1.4D3_AIS140_1.0,EA,10,H,868728037717441,,1,31032019,140054,28.533699,N,77.269020,E,0.0,188.00,14,76.0,1.3,0.0,Idea,0,1,12.7,3.9,1,O,22,404,11,69,979c,fc1,69,18,fbf,69,15,e36e,69,14,ba2f,3ff,13,0111,00,249404,"));