aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2016-07-26 01:39:50 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2016-07-26 01:39:50 +1200
commit2c48057bd628c523fbfad0559b3a1627daa46e47 (patch)
treea4e3c8d2233607e91249851fb6a3096af6425585
parent4064f864e20d3d40025a94e10cf56084d2c78287 (diff)
downloadtrackermap-server-2c48057bd628c523fbfad0559b3a1627daa46e47.tar.gz
trackermap-server-2c48057bd628c523fbfad0559b3a1627daa46e47.tar.bz2
trackermap-server-2c48057bd628c523fbfad0559b3a1627daa46e47.zip
Fix HuaSheng decoder response
-rw-r--r--src/org/traccar/protocol/HuaShengProtocolDecoder.java10
-rw-r--r--test/org/traccar/protocol/HuaShengProtocolDecoderTest.java4
2 files changed, 6 insertions, 8 deletions
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;
diff --git a/test/org/traccar/protocol/HuaShengProtocolDecoderTest.java b/test/org/traccar/protocol/HuaShengProtocolDecoderTest.java
index 083397c77..7cb6b65a0 100644
--- a/test/org/traccar/protocol/HuaShengProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/HuaShengProtocolDecoderTest.java
@@ -13,8 +13,8 @@ public class HuaShengProtocolDecoderTest extends ProtocolTest {
verifyNothing(decoder, binary(
"c000000077aa0200000000000e000100143347315f48312e315f56312e30372e54000300133335353835353035303434303635380004000b3531323030303000050005010006000400070004000800050000090018383936313032353431343533333239313833360d000a000f796573696e7465726e6574c0"));
- //verifyPosition(decoder, binary(
- // "c00000003faa0000000000003ba5a5005a3f00dbdc00000031363037303530373132353700e6d186ffcc7a25002201160010000000010015000000000000000000c0"));
+ verifyPosition(decoder, binary(
+ "c00000004baa00000000000005c400000131363037303630323537303800e6c82effcc7cb0003900a30089000000010015000000000000000000f20559ff577ce3980005000a060500000087c0"));
verifyNothing(decoder, binary(
"c0010c003e0002000000000010020012a0014f42445f3347315f56312e302e330013a0043335353835353035303434303635380006a08701000006a0a1035fc0"));