aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2016-10-20 21:13:01 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2016-10-20 21:13:12 +1300
commitdd6170837ebcda6303410f741b14e162e2ff2a29 (patch)
treefb25599bbe6fff12518fa7f7a39c8048815426a2
parent1b903a5fb7d54201b81805ae549a8ece31300366 (diff)
downloadtrackermap-server-dd6170837ebcda6303410f741b14e162e2ff2a29.tar.gz
trackermap-server-dd6170837ebcda6303410f741b14e162e2ff2a29.tar.bz2
trackermap-server-dd6170837ebcda6303410f741b14e162e2ff2a29.zip
Decode HuaSheng validity flag
-rw-r--r--src/org/traccar/protocol/HuaShengProtocolDecoder.java8
-rw-r--r--test/org/traccar/protocol/HuaShengProtocolDecoderTest.java3
2 files changed, 10 insertions, 1 deletions
diff --git a/src/org/traccar/protocol/HuaShengProtocolDecoder.java b/src/org/traccar/protocol/HuaShengProtocolDecoder.java
index cbe931bd0..d83cea2ee 100644
--- a/src/org/traccar/protocol/HuaShengProtocolDecoder.java
+++ b/src/org/traccar/protocol/HuaShengProtocolDecoder.java
@@ -20,6 +20,7 @@ import org.jboss.netty.buffer.ChannelBuffers;
import org.jboss.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
+import org.traccar.helper.BitUtil;
import org.traccar.helper.DateBuilder;
import org.traccar.helper.UnitsConverter;
import org.traccar.model.Position;
@@ -98,7 +99,12 @@ public class HuaShengProtocolDecoder extends BaseProtocolDecoder {
position.setProtocol(getProtocolName());
position.setDeviceId(deviceSession.getDeviceId());
- position.set(Position.KEY_STATUS, buf.readUnsignedShort());
+ int status = buf.readUnsignedShort();
+
+ position.setValid(BitUtil.check(status, 15));
+
+ position.set(Position.KEY_STATUS, status);
+ position.set(Position.KEY_IGNITION, BitUtil.check(status, 14));
position.set(Position.KEY_EVENT, buf.readUnsignedShort());
String time = buf.readBytes(12).toString(StandardCharsets.US_ASCII);
diff --git a/test/org/traccar/protocol/HuaShengProtocolDecoderTest.java b/test/org/traccar/protocol/HuaShengProtocolDecoderTest.java
index d1165b226..e6c918ff3 100644
--- a/test/org/traccar/protocol/HuaShengProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/HuaShengProtocolDecoderTest.java
@@ -14,6 +14,9 @@ public class HuaShengProtocolDecoderTest extends ProtocolTest {
"c000000077aa0200000000000e000100143347315f48312e315f56312e30372e54000300133335353835353035303434303635380004000b3531323030303000050005010006000400070004000800050000090018383936313032353431343533333239313833360d000a000f796573696e7465726e6574c0"));
verifyPosition(decoder, binary(
+ "c00000004baa0000000000000f8000000031363130323030373236333600e6d4f9ffcc78c700000022003600000001001500000000000000000000059bffffffffff0005000a040300000253c0"));
+
+ verifyPosition(decoder, binary(
"c00000004baa000000000000098000000031363130303732323236343700e6d4efffcc789f000000000026000000010015000000000000000000000488ffffffffff0005000a10060000008dc0"));
/*verifyPosition(decoder, binary(