diff options
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/org/traccar/protocol/MictrackProtocolDecoder.java | 29 | ||||
-rw-r--r-- | src/main/java/org/traccar/protocol/T800xProtocolDecoder.java | 2 |
2 files changed, 27 insertions, 4 deletions
diff --git a/src/main/java/org/traccar/protocol/MictrackProtocolDecoder.java b/src/main/java/org/traccar/protocol/MictrackProtocolDecoder.java index 60916e4ca..7204769b2 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); } @@ -98,7 +117,9 @@ public class MictrackProtocolDecoder extends BaseProtocolDecoder { position.setNetwork(network); - 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); } @@ -112,7 +133,9 @@ public class MictrackProtocolDecoder extends BaseProtocolDecoder { index += 4; // fix values - 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); } diff --git a/src/main/java/org/traccar/protocol/T800xProtocolDecoder.java b/src/main/java/org/traccar/protocol/T800xProtocolDecoder.java index 940d43a56..5c2c26da7 100644 --- a/src/main/java/org/traccar/protocol/T800xProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/T800xProtocolDecoder.java @@ -264,7 +264,7 @@ public class T800xProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_BATTERY, BcdUtil.readInteger(buf, 2) * 0.1); position.set("solarPanel", BcdUtil.readInteger(buf, 2) * 0.1); position.set(Position.KEY_ODOMETER, buf.readUnsignedInt()); - position.set(Position.KEY_STATUS, buf.readUnsignedShort()); + position.set(Position.KEY_IGNITION, BitUtil.check(buf.readUnsignedShort(), 2)); } else if (buf.readableBytes() >= 2) { |