diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2020-07-22 22:34:41 -0700 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2020-07-22 22:34:41 -0700 |
commit | 44241abf9dbafaec4faa982e673ebf1d447176fd (patch) | |
tree | d9c04c123f67d83823f5a232f5bd46db223dc0c6 /src/main | |
parent | 878b809b14cf6d247305194777ddeab0bc58c2c1 (diff) | |
download | trackermap-server-44241abf9dbafaec4faa982e673ebf1d447176fd.tar.gz trackermap-server-44241abf9dbafaec4faa982e673ebf1d447176fd.tar.bz2 trackermap-server-44241abf9dbafaec4faa982e673ebf1d447176fd.zip |
Add acknowledgement message
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java | 18 |
1 files changed, 17 insertions, 1 deletions
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) { |