aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2019-03-22 23:41:29 -0700
committerAnton Tananaev <anton.tananaev@gmail.com>2019-03-22 23:41:29 -0700
commitad087c64207c28b5aa0026e9ad198ec677f79fd4 (patch)
tree1f8049deda7e5c5d162c13030f3e238151ea2ec5 /src/org/traccar
parent409995a6ec0fe83ead8701f938fcac9e795d084a (diff)
downloadtrackermap-server-ad087c64207c28b5aa0026e9ad198ec677f79fd4.tar.gz
trackermap-server-ad087c64207c28b5aa0026e9ad198ec677f79fd4.tar.bz2
trackermap-server-ad087c64207c28b5aa0026e9ad198ec677f79fd4.zip
Support ITS alarms
Diffstat (limited to 'src/org/traccar')
-rw-r--r--src/org/traccar/protocol/ItsProtocolDecoder.java26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/org/traccar/protocol/ItsProtocolDecoder.java b/src/org/traccar/protocol/ItsProtocolDecoder.java
index a12b75961..482f34e65 100644
--- a/src/org/traccar/protocol/ItsProtocolDecoder.java
+++ b/src/org/traccar/protocol/ItsProtocolDecoder.java
@@ -49,7 +49,7 @@ public class ItsProtocolDecoder extends BaseProtocolDecoder {
.groupEnd()
.number("(d{15}),") // imei
.groupBegin()
- .expression("(?:NM|SP),") // status
+ .expression("(..),") // status
.or()
.expression("[^,]*,") // vehicle registration
.number("([01]),") // valid
@@ -86,6 +86,26 @@ public class ItsProtocolDecoder extends BaseProtocolDecoder {
.any()
.compile();
+ private String decodeAlarm(String status) {
+ switch (status) {
+ case "WD":
+ case "EA":
+ return Position.ALARM_SOS;
+ case "BL":
+ return Position.ALARM_LOW_BATTERY;
+ case "HB":
+ return Position.ALARM_BRAKING;
+ case "HA":
+ return Position.ALARM_ACCELERATION;
+ case "RT":
+ return Position.ALARM_CORNERING;
+ case "OS":
+ return Position.ALARM_OVERSPEED;
+ default:
+ return null;
+ }
+ }
+
@Override
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
@@ -110,6 +130,10 @@ public class ItsProtocolDecoder extends BaseProtocolDecoder {
position.setDeviceId(deviceSession.getDeviceId());
if (parser.hasNext()) {
+ position.set(Position.KEY_ALARM, decodeAlarm(parser.next()));
+ }
+
+ if (parser.hasNext()) {
position.setValid(parser.nextInt() == 1);
}
position.setTime(parser.nextDateTime(Parser.DateTimeFormat.DMY_HMS));