diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2017-03-23 07:43:46 +1300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2017-03-23 07:43:46 +1300 |
commit | 0c659701a72b6a03b69b91a8d85ab82a656e323a (patch) | |
tree | 270432822f0f46dd3959af1b9487bfe18ae13fed /src/org/traccar | |
parent | 05e5643fdeceff7896a095ddfcef4a4516e271b3 (diff) | |
download | traccar-server-0c659701a72b6a03b69b91a8d85ab82a656e323a.tar.gz traccar-server-0c659701a72b6a03b69b91a8d85ab82a656e323a.tar.bz2 traccar-server-0c659701a72b6a03b69b91a8d85ab82a656e323a.zip |
Extend Telic protocol decoder
Diffstat (limited to 'src/org/traccar')
-rw-r--r-- | src/org/traccar/protocol/TelicProtocolDecoder.java | 53 |
1 files changed, 30 insertions, 23 deletions
diff --git a/src/org/traccar/protocol/TelicProtocolDecoder.java b/src/org/traccar/protocol/TelicProtocolDecoder.java index 0ed1ce2d9..f6be15cce 100644 --- a/src/org/traccar/protocol/TelicProtocolDecoder.java +++ b/src/org/traccar/protocol/TelicProtocolDecoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2014 - 2016 Anton Tananaev (anton@traccar.org) + * Copyright 2014 - 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. @@ -58,6 +58,28 @@ public class TelicProtocolDecoder extends BaseProtocolDecoder { .any() .compile(); + private String decodeAlarm(int eventId) { + + switch (eventId) { + case 1: + return Position.ALARM_POWER_ON; + case 2: + return Position.ALARM_SOS; + case 5: + return Position.ALARM_POWER_OFF; + case 7: + return Position.ALARM_GEOFENCE_ENTER; + case 8: + return Position.ALARM_GEOFENCE_EXIT; + case 22: + return Position.ALARM_LOW_BATTERY; + case 25: + return Position.ALARM_MOVEMENT; + default: + return null; + } + } + @Override protected Object decode( Channel channel, SocketAddress remoteAddress, Object msg) throws Exception { @@ -77,10 +99,16 @@ public class TelicProtocolDecoder extends BaseProtocolDecoder { position.setDeviceId(deviceSession.getDeviceId()); int event = parser.nextInt(); - position.set(Position.KEY_TYPE, event); + position.set(Position.KEY_EVENT, event); position.set(Position.KEY_ALARM, decodeAlarm(event)); + if (event == 11) { + position.set(Position.KEY_IGNITION, true); + } else if (event == 12) { + position.set(Position.KEY_IGNITION, false); + } + position.setTime(parser.nextDateTime(Parser.DateTimeFormat.DMY_HMS)); if (parser.hasNext(6)) { @@ -104,25 +132,4 @@ public class TelicProtocolDecoder extends BaseProtocolDecoder { return position; } - private String decodeAlarm(int eventId) { - - switch (eventId) { - case 1: - return Position.ALARM_POWER_ON; - case 2: - return Position.ALARM_SOS; - case 5: - return Position.ALARM_POWER_OFF; - case 7: - return Position.ALARM_GEOFENCE_ENTER; - case 8: - return Position.ALARM_GEOFENCE_EXIT; - case 22: - return Position.ALARM_LOW_BATTERY; - case 25: - return Position.ALARM_MOVEMENT; - default: - return null; - } - } } |