From 2c48057bd628c523fbfad0559b3a1627daa46e47 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Tue, 26 Jul 2016 01:39:50 +1200 Subject: Fix HuaSheng decoder response --- src/org/traccar/protocol/HuaShengProtocolDecoder.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'src/org/traccar') diff --git a/src/org/traccar/protocol/HuaShengProtocolDecoder.java b/src/org/traccar/protocol/HuaShengProtocolDecoder.java index 6901f37fb..e7c83d3b3 100644 --- a/src/org/traccar/protocol/HuaShengProtocolDecoder.java +++ b/src/org/traccar/protocol/HuaShengProtocolDecoder.java @@ -38,7 +38,7 @@ public class HuaShengProtocolDecoder extends BaseProtocolDecoder { public static final int MSG_LOGIN = 0xAA02; public static final int MSG_LOGIN_RSP = 0xFF03; - private static void sendResponse(Channel channel, int type, ChannelBuffer content) { + private static void sendResponse(Channel channel, int type, int index, ChannelBuffer content) { if (channel != null) { ChannelBuffer response = ChannelBuffers.dynamicBuffer(); response.writeByte(0xC0); @@ -46,7 +46,7 @@ public class HuaShengProtocolDecoder extends BaseProtocolDecoder { response.writeShort(12 + content.readableBytes()); response.writeShort(type); response.writeShort(0); - response.writeInt(1); + response.writeInt(index); response.writeBytes(content); response.writeByte(0xC0); channel.write(response); @@ -80,7 +80,7 @@ public class HuaShengProtocolDecoder extends BaseProtocolDecoder { if (deviceSession != null && channel != null) { ChannelBuffer content = ChannelBuffers.dynamicBuffer(); content.writeByte(0); // success - sendResponse(channel, MSG_LOGIN_RSP, content); + sendResponse(channel, MSG_LOGIN_RSP, index, content); } } else { buf.skipBytes(length); @@ -127,9 +127,7 @@ public class HuaShengProtocolDecoder extends BaseProtocolDecoder { buf.skipBytes(length); } - ChannelBuffer content = ChannelBuffers.dynamicBuffer(); - content.writeInt(index); - sendResponse(channel, MSG_POSITION_RSP, content); + sendResponse(channel, MSG_POSITION_RSP, index, ChannelBuffers.dynamicBuffer()); return position; -- cgit v1.2.3