aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorssmipp <sami@toosa.org>2017-01-27 13:55:36 +0200
committerssmipp <sami@toosa.org>2017-01-27 13:55:36 +0200
commit6f6422186015e372ec314e0a3df557d4ee14cc49 (patch)
tree3319fb4a19201f9d33a04297978f88055f4fbaaa /src
parent6b77ba3ae328e3eeecb3d770a2a2de39afe81341 (diff)
downloadtraccar-server-6f6422186015e372ec314e0a3df557d4ee14cc49.tar.gz
traccar-server-6f6422186015e372ec314e0a3df557d4ee14cc49.tar.bz2
traccar-server-6f6422186015e372ec314e0a3df557d4ee14cc49.zip
Added some Telic events (alarm) #2793
Diffstat (limited to 'src')
-rw-r--r--src/org/traccar/protocol/TelicProtocolDecoder.java90
1 files changed, 74 insertions, 16 deletions
diff --git a/src/org/traccar/protocol/TelicProtocolDecoder.java b/src/org/traccar/protocol/TelicProtocolDecoder.java
index 4d496426d..a9b794c38 100644
--- a/src/org/traccar/protocol/TelicProtocolDecoder.java
+++ b/src/org/traccar/protocol/TelicProtocolDecoder.java
@@ -26,6 +26,7 @@ import org.traccar.model.Position;
import java.net.SocketAddress;
import java.util.regex.Pattern;
+import org.traccar.helper.Log;
public class TelicProtocolDecoder extends BaseProtocolDecoder {
@@ -35,27 +36,27 @@ public class TelicProtocolDecoder extends BaseProtocolDecoder {
private static final Pattern PATTERN = new PatternBuilder()
.number("dddd")
- .number("(d{6})") // device id
- .number("(d+),") // type
- .number("d{12},") // event time
+ .number("(d{6})") // device id
+ .number("(d+),") // type
+ .number("d{12},") // event time
.number("d+,")
- .number("(dd)(dd)(dd)") // date
- .number("(dd)(dd)(dd),") // time
+ .number("(dd)(dd)(dd)") // date
+ .number("(dd)(dd)(dd),") // time
.groupBegin()
- .number("(ddd)(dd)(dddd),") // longitude
- .number("(dd)(dd)(dddd),") // latitude
+ .number("(ddd)(dd)(dddd),") // longitude
+ .number("(dd)(dd)(dddd),") // latitude
.or()
- .number("(-?d+),") // longitude
- .number("(-?d+),") // latitude
+ .number("(-?d+),") // longitude
+ .number("(-?d+),") // latitude
.groupEnd()
- .number("(d),") // validity
- .number("(d+),") // speed
- .number("(d+),") // course
- .number("(d+),") // satellites
+ .number("(d),") // validity
+ .number("(d+),") // speed
+ .number("(d+),") // course
+ .number("(d+),") // satellites
.expression("(?:[^,]*,){7}")
- .number("(d+),") // battery
+ .number("(d+),") // battery
.expression("[^,]*,")
- .number("(d+),") // external
+ .number("(d+),") // external
.any()
.compile();
@@ -77,7 +78,11 @@ public class TelicProtocolDecoder extends BaseProtocolDecoder {
}
position.setDeviceId(deviceSession.getDeviceId());
- position.set(Position.KEY_TYPE, parser.next());
+ String eventValue = parser.next();
+ position.set(Position.KEY_TYPE, eventValue);
+
+ // alarm
+ position.set(Position.KEY_ALARM, decodeAlarm(eventValue));
DateBuilder dateBuilder = new DateBuilder()
.setDateReverse(parser.nextInt(), parser.nextInt(), parser.nextInt())
@@ -105,4 +110,57 @@ public class TelicProtocolDecoder extends BaseProtocolDecoder {
return position;
}
+ private String decodeAlarm(String event) {
+
+ int eventId = 0;
+
+ try {
+ eventId = Integer.parseInt(event);
+ } catch (Exception e) {
+ Log.error("TelicProtocolDecoder: Error parsing event (" + eventId + "): " + e.toString());
+ }
+
+ switch (eventId) {
+ case 1:
+ return Position.ALARM_POWER_ON; // Power on
+ case 2:
+ return Position.ALARM_SOS; // Emergency
+ case 3:
+ return null; // Position lock alarm
+ case 4:
+ return null; // Alarm Tracking
+ case 5:
+ return Position.ALARM_POWER_OFF; // Power off
+ case 6:
+ return null; // Course change
+ case 7:
+ return Position.ALARM_GEOFENCE_ENTER; // Geofence area enter
+ case 8:
+ return Position.ALARM_GEOFENCE_EXIT; // Geofence area exit
+ case 9:
+ return null; // GPS fix lost
+ case 10:
+ return null; // Periodic wakeup / Routine message
+ case 13:
+ return null; // Digital input 2 Low -> High / Charger connected
+ case 14:
+ return null; // Digital input 2 High -> Low / Charger disconnected
+ case 15:
+ return null; // Digital input 3 Low -> High
+ case 16:
+ return null; // Digital input 3 High -> Low
+ case 21:
+ return null; // Analog input 1 High / Battery level OK
+ case 22:
+ return Position.ALARM_LOW_BATTERY; // Analog input 1 Low / Battery level low
+ case 25:
+ return Position.ALARM_MOVEMENT; // Device is moving
+ case 26:
+ return null; // Device is stationary
+ case 29:
+ return null; // Force GPRS reconnection
+ default:
+ return null;
+ }
+ }
}