aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/traccar/protocol')
-rw-r--r--src/org/traccar/protocol/Gt06ProtocolDecoder.java3
-rw-r--r--src/org/traccar/protocol/MeitrackProtocolDecoder.java24
-rw-r--r--src/org/traccar/protocol/TaipProtocolDecoder.java16
-rw-r--r--src/org/traccar/protocol/TelicProtocolDecoder.java13
4 files changed, 46 insertions, 10 deletions
diff --git a/src/org/traccar/protocol/Gt06ProtocolDecoder.java b/src/org/traccar/protocol/Gt06ProtocolDecoder.java
index bbba639c1..d94df7531 100644
--- a/src/org/traccar/protocol/Gt06ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gt06ProtocolDecoder.java
@@ -184,9 +184,8 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
case 0x11:
return Position.ALARM_POWER_OFF;
default:
- break;
+ return null;
}
- return null;
}
@Override
diff --git a/src/org/traccar/protocol/MeitrackProtocolDecoder.java b/src/org/traccar/protocol/MeitrackProtocolDecoder.java
index bd6f3e8be..9189d2a66 100644
--- a/src/org/traccar/protocol/MeitrackProtocolDecoder.java
+++ b/src/org/traccar/protocol/MeitrackProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012 - 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2012 - 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.
@@ -84,6 +84,27 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder {
.text("\r\n").optional()
.compile();
+ private String decodeAlarm(int event) {
+ switch (event) {
+ case 1:
+ return Position.ALARM_SOS;
+ case 17:
+ return Position.ALARM_LOW_BATTERY;
+ case 18:
+ return Position.ALARM_POWER_CUT;
+ case 19:
+ return Position.ALARM_OVERSPEED;
+ case 20:
+ return Position.ALARM_GEOFENCE_ENTER;
+ case 21:
+ return Position.ALARM_GEOFENCE_EXIT;
+ case 36:
+ return Position.ALARM_TOW;
+ default:
+ return null;
+ }
+ }
+
private Position decodeRegularMessage(Channel channel, SocketAddress remoteAddress, ChannelBuffer buf) {
Parser parser = new Parser(PATTERN, buf.toString(StandardCharsets.US_ASCII));
@@ -102,6 +123,7 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder {
int event = parser.nextInt();
position.set(Position.KEY_EVENT, event);
+ position.set(Position.KEY_ALARM, decodeAlarm(event));
position.setLatitude(parser.nextDouble());
position.setLongitude(parser.nextDouble());
diff --git a/src/org/traccar/protocol/TaipProtocolDecoder.java b/src/org/traccar/protocol/TaipProtocolDecoder.java
index 309263cd5..a46cdefe3 100644
--- a/src/org/traccar/protocol/TaipProtocolDecoder.java
+++ b/src/org/traccar/protocol/TaipProtocolDecoder.java
@@ -54,8 +54,13 @@ public class TaipProtocolDecoder extends BaseProtocolDecoder {
.number("(dd)(dd)(dd)") // date (mmddyy)
.number("(dd)(dd)(dd)") // time (hhmmss)
.groupEnd()
+ .groupBegin()
.number("([-+]dd)(d{5})") // latitude
.number("([-+]ddd)(d{5})") // longitude
+ .or()
+ .number("([-+])(dd)(dd.dddd)") // latitude
+ .number("([-+])(ddd)(dd.dddd)") // longitude
+ .groupEnd()
.number("(ddd)") // speed
.number("(ddd)") // course
.groupBegin()
@@ -112,8 +117,15 @@ public class TaipProtocolDecoder extends BaseProtocolDecoder {
position.setTime(parser.nextDateTime(Parser.DateTimeFormat.DMY_HMS));
}
- position.setLatitude(parser.nextCoordinate(Parser.CoordinateFormat.DEG_DEG));
- position.setLongitude(parser.nextCoordinate(Parser.CoordinateFormat.DEG_DEG));
+ if (parser.hasNext(4)) {
+ position.setLatitude(parser.nextCoordinate(Parser.CoordinateFormat.DEG_DEG));
+ position.setLongitude(parser.nextCoordinate(Parser.CoordinateFormat.DEG_DEG));
+ }
+ if (parser.hasNext(6)) {
+ position.setLatitude(parser.nextCoordinate(Parser.CoordinateFormat.HEM_DEG_MIN));
+ position.setLongitude(parser.nextCoordinate(Parser.CoordinateFormat.HEM_DEG_MIN));
+ }
+
position.setSpeed(UnitsConverter.knotsFromMph(parser.nextDouble()));
position.setCourse(parser.nextDouble());
diff --git a/src/org/traccar/protocol/TelicProtocolDecoder.java b/src/org/traccar/protocol/TelicProtocolDecoder.java
index f6be15cce..bbd4b0574 100644
--- a/src/org/traccar/protocol/TelicProtocolDecoder.java
+++ b/src/org/traccar/protocol/TelicProtocolDecoder.java
@@ -50,11 +50,11 @@ public class TelicProtocolDecoder extends BaseProtocolDecoder {
.number("(d),") // validity
.number("(d+),") // speed
.number("(d+),") // course
- .number("(d+),") // satellites
+ .number("(d+)?,") // satellites
.expression("(?:[^,]*,){7}")
.number("(d+),") // battery
.expression("[^,]*,")
- .number("(d+),") // external
+ .number("(d+)") // external
.any()
.compile();
@@ -125,9 +125,12 @@ public class TelicProtocolDecoder extends BaseProtocolDecoder {
position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble()));
position.setCourse(parser.nextDouble());
- position.set(Position.KEY_SATELLITES, parser.next());
- position.set(Position.KEY_BATTERY, 3.4 + parser.nextInt() * 0.00345);
- position.set(Position.KEY_POWER, 6.0 + parser.nextInt() * 0.125);
+ if (parser.hasNext()) {
+ position.set(Position.KEY_SATELLITES, parser.nextInt());
+ }
+
+ position.set(Position.KEY_BATTERY, parser.nextInt());
+ position.set(Position.KEY_POWER, parser.nextInt());
return position;
}