aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2017-05-26 23:11:35 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2017-05-26 23:11:35 +1200
commitf2bcffcd0114b053e461257924eb687970766b5f (patch)
treea99adb26d6bb2a2d2222688bded7780b5d18f5dd /src/org/traccar/protocol
parent0b69523b721b2f719ff32abb4eb9555279a99208 (diff)
downloadtrackermap-server-f2bcffcd0114b053e461257924eb687970766b5f.tar.gz
trackermap-server-f2bcffcd0114b053e461257924eb687970766b5f.tar.bz2
trackermap-server-f2bcffcd0114b053e461257924eb687970766b5f.zip
Configurable alarms for Atrack protocol
Diffstat (limited to 'src/org/traccar/protocol')
-rw-r--r--src/org/traccar/protocol/AtrackProtocolDecoder.java18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/org/traccar/protocol/AtrackProtocolDecoder.java b/src/org/traccar/protocol/AtrackProtocolDecoder.java
index bbc7c4479..456ae7bee 100644
--- a/src/org/traccar/protocol/AtrackProtocolDecoder.java
+++ b/src/org/traccar/protocol/AtrackProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2013 - 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2013 - 2017 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.
@@ -30,8 +30,10 @@ import org.traccar.model.Position;
import java.net.SocketAddress;
import java.nio.charset.StandardCharsets;
import java.util.Date;
+import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
+import java.util.Map;
public class AtrackProtocolDecoder extends BaseProtocolDecoder {
@@ -41,6 +43,8 @@ public class AtrackProtocolDecoder extends BaseProtocolDecoder {
private boolean custom;
private String form;
+ private final Map<Integer, String> alarmMap = new HashMap<>();
+
public AtrackProtocolDecoder(AtrackProtocol protocol) {
super(protocol);
@@ -51,6 +55,13 @@ public class AtrackProtocolDecoder extends BaseProtocolDecoder {
if (form != null) {
custom = true;
}
+
+ for (String pair : Context.getConfig().getString(getProtocolName() + ".alarmMap", "").split(",")) {
+ if (!pair.isEmpty()) {
+ alarmMap.put(
+ Integer.parseInt(pair.substring(0, pair.indexOf('='))), pair.substring(pair.indexOf('=') + 1));
+ }
+ }
}
public void setLongDate(boolean longDate) {
@@ -240,7 +251,10 @@ public class AtrackProtocolDecoder extends BaseProtocolDecoder {
position.setLatitude(buf.readInt() * 0.000001);
position.setCourse(buf.readUnsignedShort());
- position.set(Position.KEY_TYPE, buf.readUnsignedByte());
+ int type = buf.readUnsignedByte();
+ position.set(Position.KEY_TYPE, type);
+ position.set(Position.KEY_ALARM, alarmMap.get(type));
+
position.set(Position.KEY_ODOMETER, buf.readUnsignedInt() * 100);
position.set(Position.KEY_HDOP, buf.readUnsignedShort() * 0.1);
position.set(Position.KEY_INPUT, buf.readUnsignedByte());