From 36d09739e518f715800c924c90f0b598a9912433 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sat, 30 Sep 2017 20:22:05 +1300 Subject: Decode StarLink alarms --- .../traccar/protocol/StarLinkProtocolDecoder.java | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/org') diff --git a/src/org/traccar/protocol/StarLinkProtocolDecoder.java b/src/org/traccar/protocol/StarLinkProtocolDecoder.java index 38f6980f6..79f013fac 100644 --- a/src/org/traccar/protocol/StarLinkProtocolDecoder.java +++ b/src/org/traccar/protocol/StarLinkProtocolDecoder.java @@ -69,6 +69,29 @@ public class StarLinkProtocolDecoder extends BaseProtocolDecoder { return value.charAt(0) == '+' ? result : -result; } + private String decodeAlarm(int event) { + switch (event) { + case 6: + return Position.ALARM_OVERSPEED; + case 7: + return Position.ALARM_GEOFENCE_ENTER; + case 8: + return Position.ALARM_GEOFENCE_EXIT; + case 9: + return Position.ALARM_POWER_CUT; + case 11: + return Position.ALARM_LOW_BATTERY; + case 26: + return Position.ALARM_TOW; + case 36: + return Position.ALARM_SOS; + case 42: + return Position.ALARM_JAMMING; + default: + return null; + } + } + @Override protected Object decode( Channel channel, SocketAddress remoteAddress, Object msg) throws Exception { @@ -109,6 +132,7 @@ public class StarLinkProtocolDecoder extends BaseProtocolDecoder { break; case "#EID#": event = Integer.parseInt(data[i]); + position.set(Position.KEY_ALARM, decodeAlarm(event)); position.set(Position.KEY_EVENT, event); break; case "#PDT#": -- cgit v1.2.3