From 44241abf9dbafaec4faa982e673ebf1d447176fd Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Wed, 22 Jul 2020 22:34:41 -0700 Subject: Add acknowledgement message --- .../org/traccar/protocol/HuabaoProtocolDecoder.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java b/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java index 40b05cbab..335dcd796 100644 --- a/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java @@ -44,6 +44,7 @@ public class HuabaoProtocolDecoder extends BaseProtocolDecoder { } public static final int MSG_GENERAL_RESPONSE = 0x8001; + public static final int MSG_GENERAL_RESPONSE_2 = 0x4401; public static final int MSG_TERMINAL_REGISTER = 0x0100; public static final int MSG_TERMINAL_REGISTER_RESPONSE = 0x8100; public static final int MSG_TERMINAL_CONTROL = 0x8105; @@ -82,6 +83,17 @@ public class HuabaoProtocolDecoder extends BaseProtocolDecoder { } } + private void sendGeneralResponse2( + Channel channel, SocketAddress remoteAddress, ByteBuf id, int index) { + if (channel != null) { + ByteBuf response = Unpooled.buffer(); + response.writeShort(index); + response.writeByte(RESULT_SUCCESS); + channel.writeAndFlush(new NetworkMessage( + formatMessage(MSG_GENERAL_RESPONSE_2, id, response), remoteAddress)); + } + } + private String decodeAlarm(long value) { if (BitUtil.check(value, 0)) { return Position.ALARM_SOS; @@ -123,7 +135,7 @@ public class HuabaoProtocolDecoder extends BaseProtocolDecoder { buf.readUnsignedByte(); // start marker int type = buf.readUnsignedShort(); - buf.readUnsignedShort(); // body length + int attribute = buf.readUnsignedShort(); ByteBuf id = buf.readSlice(6); // phone number int index; if (type == MSG_LOCATION_REPORT_2 || type == MSG_LOCATION_REPORT_BLIND) { @@ -162,6 +174,10 @@ public class HuabaoProtocolDecoder extends BaseProtocolDecoder { } else if (type == MSG_LOCATION_REPORT_2 || type == MSG_LOCATION_REPORT_BLIND) { + if (BitUtil.check(attribute, 15)) { + sendGeneralResponse2(channel, remoteAddress, id, index); + } + return decodeLocation2(deviceSession, buf, type); } else if (type == MSG_LOCATION_BATCH) { -- cgit v1.2.3