aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/org/traccar/protocol/Jt600ProtocolDecoder.java39
-rw-r--r--test/org/traccar/protocol/Jt600ProtocolDecoderTest.java3
2 files changed, 40 insertions, 2 deletions
diff --git a/src/org/traccar/protocol/Jt600ProtocolDecoder.java b/src/org/traccar/protocol/Jt600ProtocolDecoder.java
index f5d8a79a4..5a53f362a 100644
--- a/src/org/traccar/protocol/Jt600ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Jt600ProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012 - 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2012 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -49,6 +49,41 @@ public class Jt600ProtocolDecoder extends BaseProtocolDecoder {
return degrees + minutes / 60;
}
+ private void decodeStatus(Position position, ChannelBuffer buf) {
+
+ int value = buf.readUnsignedByte();
+
+ position.set(Position.KEY_IGNITION, BitUtil.check(value, 0));
+ position.set(Position.KEY_DOOR, BitUtil.check(value, 6));
+
+ value = buf.readUnsignedByte();
+
+ position.set(Position.KEY_CHARGE, BitUtil.check(value, 0));
+ position.set(Position.KEY_BLOCKED, BitUtil.check(value, 1));
+
+ if (BitUtil.check(value, 2)) {
+ position.set(Position.KEY_ALARM, Position.ALARM_SOS);
+ }
+ if (BitUtil.check(value, 3) || BitUtil.check(value, 4)) {
+ position.set(Position.KEY_ALARM, Position.ALARM_GPS_ANTENNA_CUT);
+ }
+ if (BitUtil.check(value, 4)) {
+ position.set(Position.KEY_ALARM, Position.ALARM_OVERSPEED);
+ }
+
+ value = buf.readUnsignedByte();
+
+ if (BitUtil.check(value, 2)) {
+ position.set(Position.KEY_ALARM, Position.ALARM_FATIGUE_DRIVING);
+ }
+ if (BitUtil.check(value, 3)) {
+ position.set(Position.KEY_ALARM, Position.ALARM_TOW);
+ }
+
+ buf.readUnsignedByte(); // reserved
+
+ }
+
private List<Position> decodeBinary(ChannelBuffer buf, Channel channel, SocketAddress remoteAddress) {
List<Position> positions = new LinkedList<>();
@@ -152,7 +187,7 @@ public class Jt600ProtocolDecoder extends BaseProtocolDecoder {
int fuel = buf.readUnsignedByte() << 8;
- position.set(Position.KEY_STATUS, buf.readUnsignedInt());
+ decodeStatus(position, buf);
position.set(Position.KEY_ODOMETER, buf.readUnsignedInt() * 1000);
fuel += buf.readUnsignedByte();
diff --git a/test/org/traccar/protocol/Jt600ProtocolDecoderTest.java b/test/org/traccar/protocol/Jt600ProtocolDecoderTest.java
index dd01ef783..ed583e012 100644
--- a/test/org/traccar/protocol/Jt600ProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/Jt600ProtocolDecoderTest.java
@@ -12,6 +12,9 @@ public class Jt600ProtocolDecoderTest extends ProtocolTest {
Jt600ProtocolDecoder decoder = new Jt600ProtocolDecoder(new Jt600Protocol());
verifyPositions(decoder, binary(
+ "24408111888821001B09060908045322564025113242329F0598000001003F0000002D00AB"));
+
+ verifyPositions(decoder, binary(
"2475609213701711002701010000020200000000000000000e00000000000f000000000020c164cd7b00d516000f0f0f02"));
verifyPositions(decoder, binary(