aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol/MeitrackProtocolDecoder.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2017-12-11 06:55:37 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2017-12-11 06:55:37 +1300
commitf7474589a77ca99a3543e16a0609dc4a010c0e4b (patch)
tree8b7d66724e035eab526a5fc676a334051d3b5c84 /src/org/traccar/protocol/MeitrackProtocolDecoder.java
parentd407e1d4d7a71a108d11483be40d4abec89dd266 (diff)
downloadtrackermap-server-f7474589a77ca99a3543e16a0609dc4a010c0e4b.tar.gz
trackermap-server-f7474589a77ca99a3543e16a0609dc4a010c0e4b.tar.bz2
trackermap-server-f7474589a77ca99a3543e16a0609dc4a010c0e4b.zip
Decode T333 taximeter data
Diffstat (limited to 'src/org/traccar/protocol/MeitrackProtocolDecoder.java')
-rw-r--r--src/org/traccar/protocol/MeitrackProtocolDecoder.java37
1 files changed, 35 insertions, 2 deletions
diff --git a/src/org/traccar/protocol/MeitrackProtocolDecoder.java b/src/org/traccar/protocol/MeitrackProtocolDecoder.java
index 5b67aebe3..1fd1bb3ac 100644
--- a/src/org/traccar/protocol/MeitrackProtocolDecoder.java
+++ b/src/org/traccar/protocol/MeitrackProtocolDecoder.java
@@ -75,13 +75,20 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder {
.number("(x+)|") // battery
.number("(x+)?,") // power
.groupBegin()
- .expression("([^,]+)?,") // event specific
+ .expression("([^,]+)?,").optional() // event specific
.expression("[^,]*,") // reserved
.number("(d+)?,") // protocol
.number("(x{4})?") // fuel
- .number("(?:,(x{6}(?:|x{6})*))?") // temperature
+ .groupBegin()
+ .number(",(x{6}(?:|x{6})*)?") // temperature
+ .groupBegin()
+ .number(",(d+)") // data count
+ .expression(",([^*]*)") // data
.groupEnd("?")
+ .groupEnd("?")
+ .or()
.any()
+ .groupEnd()
.text("*")
.number("xx")
.text("\r\n").optional()
@@ -234,9 +241,35 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder {
}
}
+ if (parser.hasNext(2)) {
+ decodeDataFields(position, parser.nextInt(), parser.next().split(","));
+ }
+
return position;
}
+ private void decodeDataFields(Position position, int count, String[] values) {
+
+ if (values.length > 1 && !values[1].isEmpty()) {
+ position.set("tempData", values[1]);
+ }
+
+ if (values.length > 5 && !values[5].isEmpty()) {
+ String[] data = values[5].split("\\|");
+ boolean started = data[0].charAt(0) == '0';
+ position.set("taximeterOn", started);
+ position.set("taximeterStart", data[1]);
+ if (!started) {
+ position.set("taximeterEnd", data[2]);
+ position.set("taximeterDistance", Integer.parseInt(data[3]));
+ position.set("taximeterFare", Integer.parseInt(data[4]));
+ position.set("taximeterTrip", data[5]);
+ position.set("taximeterWait", data[6]);
+ }
+ }
+
+ }
+
private List<Position> decodeBinaryC(Channel channel, SocketAddress remoteAddress, ChannelBuffer buf) {
List<Position> positions = new LinkedList<>();