aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol/Tk103ProtocolDecoder.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2017-08-19 12:01:27 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2017-08-19 12:01:27 +1200
commite90e38d8c5db452adc5ab704a6f9dd84db16ce20 (patch)
treedb58627a43f9d17a659e5c65c02ea26d78d28c82 /src/org/traccar/protocol/Tk103ProtocolDecoder.java
parent8c85694fcbdeb709e7088edb833a1e1a412206f2 (diff)
downloadtrackermap-server-e90e38d8c5db452adc5ab704a6f9dd84db16ce20.tar.gz
trackermap-server-e90e38d8c5db452adc5ab704a6f9dd84db16ce20.tar.bz2
trackermap-server-e90e38d8c5db452adc5ab704a6f9dd84db16ce20.zip
Advanced TK103 attributes
Diffstat (limited to 'src/org/traccar/protocol/Tk103ProtocolDecoder.java')
-rw-r--r--src/org/traccar/protocol/Tk103ProtocolDecoder.java44
1 files changed, 36 insertions, 8 deletions
diff --git a/src/org/traccar/protocol/Tk103ProtocolDecoder.java b/src/org/traccar/protocol/Tk103ProtocolDecoder.java
index 0106e5bf3..14278085b 100644
--- a/src/org/traccar/protocol/Tk103ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Tk103ProtocolDecoder.java
@@ -50,7 +50,14 @@ public class Tk103ProtocolDecoder extends BaseProtocolDecoder {
.number("(d+.d)(?:d*,)?") // speed
.number("(dd)(dd)(dd),?") // time (hhmmss)
.number("(d+.?d{1,2}),?") // course
- .number("(?:([01]{8})|(x{8}))?,?") // state
+ .groupBegin()
+ .number("([01])") // charge
+ .number("([01])") // ignition
+ .number("(x)") // io
+ .number("(x)") // io
+ .number("(x)") // io
+ .number("(xxx),?") // fuel
+ .groupEnd("?")
.number("(?:L(x+))?") // odometer
.any()
.number("([+-]ddd.d)?") // temperature
@@ -260,15 +267,36 @@ public class Tk103ProtocolDecoder extends BaseProtocolDecoder {
position.setCourse(parser.nextDouble(0));
- String status = parser.next();
- if (status != null) {
- position.set(Position.KEY_STATUS, status); // binary status
+ if (parser.hasNext(6)) {
+ position.set(Position.KEY_CHARGE, parser.nextInt() == 0);
+ position.set(Position.KEY_IGNITION, parser.nextInt() == 1);
- int value = Integer.parseInt(new StringBuilder(status).reverse().toString(), 2);
- position.set(Position.KEY_CHARGE, !BitUtil.check(value, 0));
- position.set(Position.KEY_IGNITION, BitUtil.check(value, 1));
+ int mask1 = parser.nextHexInt();
+ position.set(Position.PREFIX_IN + 2, BitUtil.check(mask1, 0));
+ position.set(Position.PREFIX_OUT + 2, BitUtil.check(mask1, 2));
+ if (BitUtil.check(mask1, 3)) {
+ position.set(Position.KEY_BLOCKED, true);
+ }
+
+ int mask2 = parser.nextHexInt();
+ for (int i = 0; i < 3; i++) {
+ if (BitUtil.check(mask2, i)) {
+ position.set("hs" + (3 - i), true);
+ }
+ }
+ if (BitUtil.check(mask2, 3)) {
+ position.set(Position.KEY_DOOR, true);
+ }
+
+ int mask3 = parser.nextHexInt();
+ for (int i = 1; i <= 3; i++) {
+ if (BitUtil.check(mask3, i)) {
+ position.set("hs" + (3 - i + 1), true);
+ }
+ }
+
+ position.set(Position.KEY_FUEL_LEVEL, parser.nextHexInt());
}
- position.set(Position.KEY_STATUS, parser.next()); // hex status
if (parser.hasNext()) {
position.set(Position.KEY_ODOMETER, parser.nextLong(16, 0));