From aefc13c7e57d4c6c8c9a22cdd8203f8d1d9f0878 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sun, 10 Nov 2019 15:41:08 -0800 Subject: Decode binary alerts --- src/main/java/org/traccar/protocol/SuntechProtocolDecoder.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/traccar/protocol/SuntechProtocolDecoder.java b/src/main/java/org/traccar/protocol/SuntechProtocolDecoder.java index 951a5e17b..08d8252a3 100644 --- a/src/main/java/org/traccar/protocol/SuntechProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/SuntechProtocolDecoder.java @@ -508,7 +508,7 @@ public class SuntechProtocolDecoder extends BaseProtocolDecoder { private Position decodeBinary( Channel channel, SocketAddress remoteAddress, ByteBuf buf) { - buf.readUnsignedByte(); // header + int type = buf.readUnsignedByte(); buf.readUnsignedShort(); // length DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, ByteBufUtil.hexDump(buf.readSlice(5))); @@ -603,6 +603,13 @@ public class SuntechProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_OUTPUT, buf.readUnsignedByte()); } + if (BitUtil.check(mask, 19)) { + int value = buf.readUnsignedByte(); + if (type == 0x82) { + position.set(Position.KEY_ALARM, decodeAlert(value)); + } + } + return position; } -- cgit v1.2.3