diff options
Diffstat (limited to 'src/org/traccar')
-rw-r--r-- | src/org/traccar/model/Position.java | 1 | ||||
-rw-r--r-- | src/org/traccar/protocol/Gt06ProtocolDecoder.java | 2 | ||||
-rw-r--r-- | src/org/traccar/protocol/Tk103ProtocolDecoder.java | 44 | ||||
-rw-r--r-- | src/org/traccar/protocol/TytanProtocolDecoder.java | 2 |
4 files changed, 39 insertions, 10 deletions
diff --git a/src/org/traccar/model/Position.java b/src/org/traccar/model/Position.java index 66a6f91ce..c188124af 100644 --- a/src/org/traccar/model/Position.java +++ b/src/org/traccar/model/Position.java @@ -75,6 +75,7 @@ public class Position extends Message { public static final String KEY_OPERATOR = "operator"; public static final String KEY_COMMAND = "command"; public static final String KEY_BLOCKED = "blocked"; + public static final String KEY_DOOR = "door"; public static final String KEY_DTCS = "dtcs"; public static final String KEY_OBD_SPEED = "obdSpeed"; // knots diff --git a/src/org/traccar/protocol/Gt06ProtocolDecoder.java b/src/org/traccar/protocol/Gt06ProtocolDecoder.java index 186867b9d..4cf4a79eb 100644 --- a/src/org/traccar/protocol/Gt06ProtocolDecoder.java +++ b/src/org/traccar/protocol/Gt06ProtocolDecoder.java @@ -531,7 +531,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { } else if (subType == 0x05) { int flags = buf.readUnsignedByte(); - position.set("door", BitUtil.check(flags, 0)); + position.set(Position.KEY_DOOR, BitUtil.check(flags, 0)); position.set(Position.PREFIX_IO + 1, BitUtil.check(flags, 2)); return position; 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)); diff --git a/src/org/traccar/protocol/TytanProtocolDecoder.java b/src/org/traccar/protocol/TytanProtocolDecoder.java index 030fbce78..0ae669784 100644 --- a/src/org/traccar/protocol/TytanProtocolDecoder.java +++ b/src/org/traccar/protocol/TytanProtocolDecoder.java @@ -111,7 +111,7 @@ public class TytanProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_OBD_ODOMETER, buf.readUnsignedInt() * 5); break; case 150: - position.set("door", buf.readUnsignedByte()); + position.set(Position.KEY_DOOR, buf.readUnsignedByte()); break; default: buf.skipBytes(length); |