diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2016-07-02 22:32:51 +1200 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2016-07-02 22:32:51 +1200 |
commit | 8e725d35d9a55bdb4b17002a41231203fabee359 (patch) | |
tree | 0236471fadaf6ed54b371be3a2e0fcf9ce4a23b5 /src/org/traccar/protocol | |
parent | 20d9e6d46fb692f42c9f2a73bcd354691bdd9385 (diff) | |
download | traccar-server-8e725d35d9a55bdb4b17002a41231203fabee359.tar.gz traccar-server-8e725d35d9a55bdb4b17002a41231203fabee359.tar.bz2 traccar-server-8e725d35d9a55bdb4b17002a41231203fabee359.zip |
Decode Meitrack temperature (fix #2065)
Diffstat (limited to 'src/org/traccar/protocol')
-rw-r--r-- | src/org/traccar/protocol/MeitrackProtocolDecoder.java | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/org/traccar/protocol/MeitrackProtocolDecoder.java b/src/org/traccar/protocol/MeitrackProtocolDecoder.java index a03a3aeec..a7fca89fc 100644 --- a/src/org/traccar/protocol/MeitrackProtocolDecoder.java +++ b/src/org/traccar/protocol/MeitrackProtocolDecoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2012 - 2015 Anton Tananaev (anton.tananaev@gmail.com) + * Copyright 2012 - 2016 Anton Tananaev (anton.tananaev@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -73,8 +73,10 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder { .expression("[^,]*,") // reserved .number("d*,") // protocol .number("(x{4})?") // fuel - .groupEnd("?") + .number("(?:,(x{6}(?:|x{6})*))?") // temperature + .or() .any() + .groupEnd() .text("*") .number("xx") .text("\r\n").optional() @@ -153,6 +155,14 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder { Integer.parseInt(fuel.substring(0, 2), 16) + Integer.parseInt(fuel.substring(2), 16) * 0.01); } + if (parser.hasNext()) { + for (String temp : parser.next().split("\\|")) { + int index = Integer.valueOf(temp.substring(0, 2), 16); + int value = Integer.valueOf(temp.substring(2), 16); + position.set(Position.PREFIX_TEMP + index, value); + } + } + return position; } |