aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2020-09-28 11:18:29 -0700
committerAnton Tananaev <anton.tananaev@gmail.com>2020-09-28 11:18:29 -0700
commitc7e630f4904e073127c573951336be25735bf687 (patch)
treea6ec06a57be0d09709bc58d16200b214262238f1 /src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java
parente8291e33039ec3fb56ddc8fc806c5ef4f348039d (diff)
downloadtrackermap-server-c7e630f4904e073127c573951336be25735bf687.tar.gz
trackermap-server-c7e630f4904e073127c573951336be25735bf687.tar.bz2
trackermap-server-c7e630f4904e073127c573951336be25735bf687.zip
Fix acknowledgement format
Diffstat (limited to 'src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java')
-rw-r--r--src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java b/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java
index f67cc3d8f..0d574203c 100644
--- a/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java
@@ -57,13 +57,17 @@ public class HuabaoProtocolDecoder extends BaseProtocolDecoder {
public static final int RESULT_SUCCESS = 0;
- public static ByteBuf formatMessage(int type, ByteBuf id, ByteBuf data) {
+ public static ByteBuf formatMessage(int type, ByteBuf id, boolean shortIndex, ByteBuf data) {
ByteBuf buf = Unpooled.buffer();
buf.writeByte(0x7e);
buf.writeShort(type);
buf.writeShort(data.readableBytes());
buf.writeBytes(id);
- buf.writeShort(0); // index
+ if (shortIndex) {
+ buf.writeByte(1);
+ } else {
+ buf.writeShort(1);
+ }
buf.writeBytes(data);
data.release();
buf.writeByte(Checksum.xor(buf.nioBuffer(1, buf.readableBytes() - 1)));
@@ -79,18 +83,18 @@ public class HuabaoProtocolDecoder extends BaseProtocolDecoder {
response.writeShort(type);
response.writeByte(RESULT_SUCCESS);
channel.writeAndFlush(new NetworkMessage(
- formatMessage(MSG_GENERAL_RESPONSE, id, response), remoteAddress));
+ formatMessage(MSG_GENERAL_RESPONSE, id, false, response), remoteAddress));
}
}
private void sendGeneralResponse2(
- Channel channel, SocketAddress remoteAddress, ByteBuf id, int index) {
+ Channel channel, SocketAddress remoteAddress, ByteBuf id, int type) {
if (channel != null) {
ByteBuf response = Unpooled.buffer();
- response.writeShort(index);
+ response.writeShort(type);
response.writeByte(RESULT_SUCCESS);
channel.writeAndFlush(new NetworkMessage(
- formatMessage(MSG_GENERAL_RESPONSE_2, id, response), remoteAddress));
+ formatMessage(MSG_GENERAL_RESPONSE_2, id, true, response), remoteAddress));
}
}
@@ -161,7 +165,7 @@ public class HuabaoProtocolDecoder extends BaseProtocolDecoder {
response.writeByte(RESULT_SUCCESS);
response.writeBytes(ByteBufUtil.hexDump(id).getBytes(StandardCharsets.US_ASCII));
channel.writeAndFlush(new NetworkMessage(
- formatMessage(MSG_TERMINAL_REGISTER_RESPONSE, id, response), remoteAddress));
+ formatMessage(MSG_TERMINAL_REGISTER_RESPONSE, id, false, response), remoteAddress));
}
} else if (type == MSG_TERMINAL_AUTH) {
@@ -175,7 +179,7 @@ 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);
+ sendGeneralResponse2(channel, remoteAddress, id, type);
}
return decodeLocation2(deviceSession, buf, type);