aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2017-09-24 12:14:38 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2017-09-24 12:14:38 +1300
commitfd59d77dbd6037c7b72eb6f4d132db4bde6877a0 (patch)
tree2f50903cf24bc66dccc430355c567072a2b7a20f
parenta5643fa4ddbf3b2788eaf100e065b7ff30a49f13 (diff)
downloadtrackermap-server-fd59d77dbd6037c7b72eb6f4d132db4bde6877a0.tar.gz
trackermap-server-fd59d77dbd6037c7b72eb6f4d132db4bde6877a0.tar.bz2
trackermap-server-fd59d77dbd6037c7b72eb6f4d132db4bde6877a0.zip
Support all Meitrack versions (fix #3535)
-rw-r--r--src/org/traccar/protocol/MeitrackProtocolDecoder.java18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/org/traccar/protocol/MeitrackProtocolDecoder.java b/src/org/traccar/protocol/MeitrackProtocolDecoder.java
index 2d0590f5e..4714e24ea 100644
--- a/src/org/traccar/protocol/MeitrackProtocolDecoder.java
+++ b/src/org/traccar/protocol/MeitrackProtocolDecoder.java
@@ -73,12 +73,11 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder {
.groupBegin()
.expression("([^,]+)?,") // event specific
.expression("[^,]*,") // reserved
- .number("d*,") // protocol
+ .number("(d+)?,") // protocol
.number("(x{4})?") // fuel
.number("(?:,(x{6}(?:|x{6})*))?") // temperature
- .or()
+ .groupEnd("?")
.any()
- .groupEnd()
.text("*")
.number("xx")
.text("\r\n").optional()
@@ -209,6 +208,8 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder {
}
}
+ int protocol = parser.nextInt(0);
+
if (parser.hasNext()) {
String fuel = parser.next();
position.set(Position.KEY_FUEL_LEVEL,
@@ -218,9 +219,14 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder {
if (parser.hasNext()) {
for (String temp : parser.next().split("\\|")) {
int index = Integer.valueOf(temp.substring(0, 2), 16);
- double value = Byte.valueOf(temp.substring(2, 4), 16);
- value += (value < 0 ? -0.01 : 0.01) * Integer.valueOf(temp.substring(4), 16);
- position.set(Position.PREFIX_TEMP + index, value);
+ if (protocol >= 3) {
+ double value = Short.valueOf(temp.substring(2), 16);
+ position.set(Position.PREFIX_TEMP + index, value * 0.01);
+ } else {
+ double value = Byte.valueOf(temp.substring(2, 4), 16);
+ value += (value < 0 ? -0.01 : 0.01) * Integer.valueOf(temp.substring(4), 16);
+ position.set(Position.PREFIX_TEMP + index, value);
+ }
}
}