From a83353fd0b21ae5ff75680e45e3a06b89c4f2de4 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sat, 20 Jan 2018 16:42:21 +1300 Subject: Decode Mictrack status --- src/org/traccar/protocol/Tlt2hProtocolDecoder.java | 41 +++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/org/traccar/protocol/Tlt2hProtocolDecoder.java b/src/org/traccar/protocol/Tlt2hProtocolDecoder.java index cbc851de0..4be1fc865 100644 --- a/src/org/traccar/protocol/Tlt2hProtocolDecoder.java +++ b/src/org/traccar/protocol/Tlt2hProtocolDecoder.java @@ -57,6 +57,45 @@ public class Tlt2hProtocolDecoder extends BaseProtocolDecoder { .any() .compile(); + private void decodeStatus(Position position, String status) { + switch (status) { + case "AUTOSTART": + case "AUTO": + position.set(Position.KEY_IGNITION, true); + break; + case "AUTOSTOP": + case "AUTOLOW": + position.set(Position.KEY_IGNITION, false); + break; + case "TOWED": + position.set(Position.KEY_ALARM, Position.ALARM_TOW); + break; + case "SOS": + position.set(Position.KEY_ALARM, Position.ALARM_SOS); + break; + case "DEF": + position.set(Position.KEY_ALARM, Position.ALARM_POWER_CUT); + break; + case "BLP": + position.set(Position.KEY_ALARM, Position.ALARM_LOW_BATTERY); + break; + case "CLP": + position.set(Position.KEY_ALARM, Position.ALARM_LOW_POWER); + break; + case "OS": + position.set(Position.KEY_ALARM, Position.ALARM_GEOFENCE_EXIT); + break; + case "RS": + position.set(Position.KEY_ALARM, Position.ALARM_GEOFENCE_ENTER); + break; + case "OVERSPEED": + position.set(Position.KEY_ALARM, Position.ALARM_OVERSPEED); + break; + default: + break; + } + } + @Override protected Object decode( Channel channel, SocketAddress remoteAddress, Object msg) throws Exception { @@ -102,7 +141,7 @@ public class Tlt2hProtocolDecoder extends BaseProtocolDecoder { dateBuilder.setDateReverse(parser.nextInt(0), parser.nextInt(0), parser.nextInt(0)); position.setTime(dateBuilder.getDate()); - position.set(Position.KEY_STATUS, status); + decodeStatus(position, status); positions.add(position); } -- cgit v1.2.3