aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/protocol
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2019-07-31 08:40:14 -0700
committerAnton Tananaev <anton.tananaev@gmail.com>2019-07-31 08:40:14 -0700
commit678c6bb04f4f97e2d7f607ffb0d5d21953282bde (patch)
tree643d272f1861c221c51c490416c206baa3f93c34 /src/main/java/org/traccar/protocol
parent32a3e0e512602afd25a1ad90d1861d71f918a9f4 (diff)
downloadtrackermap-server-678c6bb04f4f97e2d7f607ffb0d5d21953282bde.tar.gz
trackermap-server-678c6bb04f4f97e2d7f607ffb0d5d21953282bde.tar.bz2
trackermap-server-678c6bb04f4f97e2d7f607ffb0d5d21953282bde.zip
Decoder alarm codes
Diffstat (limited to 'src/main/java/org/traccar/protocol')
-rw-r--r--src/main/java/org/traccar/protocol/MictrackProtocolDecoder.java21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/main/java/org/traccar/protocol/MictrackProtocolDecoder.java b/src/main/java/org/traccar/protocol/MictrackProtocolDecoder.java
index 60916e4ca..e83318fa9 100644
--- a/src/main/java/org/traccar/protocol/MictrackProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/MictrackProtocolDecoder.java
@@ -44,6 +44,23 @@ public class MictrackProtocolDecoder extends BaseProtocolDecoder {
return dateFormat.parse(data);
}
+ private String decodeAlarm(int event) {
+ switch (event) {
+ case 5:
+ return Position.ALARM_SOS;
+ case 8:
+ return Position.ALARM_LOW_BATTERY;
+ case 9:
+ return Position.ALARM_GEOFENCE_ENTER;
+ case 10:
+ return Position.ALARM_GEOFENCE_EXIT;
+ case 12:
+ return Position.ALARM_POWER_OFF;
+ default:
+ return null;
+ }
+ }
+
private void decodeLocation(Position position, String data) throws ParseException {
int index = 0;
String[] values = data.split("\\+");
@@ -57,7 +74,9 @@ public class MictrackProtocolDecoder extends BaseProtocolDecoder {
position.setSpeed(UnitsConverter.knotsFromMps(Double.parseDouble(values[index++])));
position.setCourse(Integer.parseInt(values[index++]));
- position.set(Position.KEY_EVENT, Integer.parseInt(values[index++]));
+ int event = Integer.parseInt(values[index++]);
+ position.set(Position.KEY_ALARM, decodeAlarm(event));
+ position.set(Position.KEY_EVENT, event);
position.set(Position.KEY_BATTERY, Integer.parseInt(values[index++]) * 0.001);
}