From 5a582f6316511199d43b4c15e7d1759932f9874b Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Mon, 18 Jun 2018 16:19:33 +1200 Subject: Decode JT600 status flags --- src/org/traccar/protocol/Jt600ProtocolDecoder.java | 10 +++++++++- test/org/traccar/protocol/Jt600ProtocolDecoderTest.java | 3 +++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/org/traccar/protocol/Jt600ProtocolDecoder.java b/src/org/traccar/protocol/Jt600ProtocolDecoder.java index 87996a0c3..109f8a68a 100644 --- a/src/org/traccar/protocol/Jt600ProtocolDecoder.java +++ b/src/org/traccar/protocol/Jt600ProtocolDecoder.java @@ -145,7 +145,15 @@ public class Jt600ProtocolDecoder extends BaseProtocolDecoder { buf.readUnsignedInt(); // vehicle id combined - position.set(Position.KEY_STATUS, buf.readUnsignedShort()); + int status = buf.readUnsignedShort(); + position.set(Position.KEY_ALARM, BitUtil.check(status, 1) ? Position.ALARM_GEOFENCE_ENTER : null); + position.set(Position.KEY_ALARM, BitUtil.check(status, 2) ? Position.ALARM_GEOFENCE_EXIT : null); + position.set(Position.KEY_ALARM, BitUtil.check(status, 3) ? Position.ALARM_POWER_CUT : null); + position.set(Position.KEY_ALARM, BitUtil.check(status, 4) ? Position.ALARM_VIBRATION : null); + position.set(Position.KEY_BLOCKED, BitUtil.check(status, 7)); + position.set(Position.KEY_ALARM, BitUtil.check(status, 8 + 3) ? Position.ALARM_LOW_BATTERY : null); + position.set(Position.KEY_ALARM, BitUtil.check(status, 8 + 6) ? Position.ALARM_FAULT : null); + position.set(Position.KEY_STATUS, status); int battery = buf.readUnsignedByte(); if (battery == 0xff) { diff --git a/test/org/traccar/protocol/Jt600ProtocolDecoderTest.java b/test/org/traccar/protocol/Jt600ProtocolDecoderTest.java index ed583e012..3baa17667 100644 --- a/test/org/traccar/protocol/Jt600ProtocolDecoderTest.java +++ b/test/org/traccar/protocol/Jt600ProtocolDecoderTest.java @@ -11,6 +11,9 @@ public class Jt600ProtocolDecoderTest extends ProtocolTest { Jt600ProtocolDecoder decoder = new Jt600ProtocolDecoder(new Jt600Protocol()); + verifyPositions(decoder, binary( + "2475801263981711002713061813333723501622090221558f012f0000002a070000000020c055b88552191f000f0f0f07")); + verifyPositions(decoder, binary( "24408111888821001B09060908045322564025113242329F0598000001003F0000002D00AB")); -- cgit v1.2.3