aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2017-12-08 04:03:53 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2017-12-08 04:03:53 +1300
commitaf8875896e06ac3ac034c493b5a355d32cffb026 (patch)
tree362321c6c8f9672becf01a0ba133fab1fcbdb743
parent58210703a05a5c241fafbbf367ae877911aa6349 (diff)
downloadtrackermap-server-af8875896e06ac3ac034c493b5a355d32cffb026.tar.gz
trackermap-server-af8875896e06ac3ac034c493b5a355d32cffb026.tar.bz2
trackermap-server-af8875896e06ac3ac034c493b5a355d32cffb026.zip
Support HS3000 handshake
-rw-r--r--src/org/traccar/protocol/HuaShengProtocolDecoder.java18
-rw-r--r--test/org/traccar/protocol/HuaShengProtocolDecoderTest.java3
2 files changed, 16 insertions, 5 deletions
diff --git a/src/org/traccar/protocol/HuaShengProtocolDecoder.java b/src/org/traccar/protocol/HuaShengProtocolDecoder.java
index a0a1eb0ab..96f87fd94 100644
--- a/src/org/traccar/protocol/HuaShengProtocolDecoder.java
+++ b/src/org/traccar/protocol/HuaShengProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2017 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -38,17 +38,21 @@ public class HuaShengProtocolDecoder extends BaseProtocolDecoder {
public static final int MSG_POSITION_RSP = 0xFF01;
public static final int MSG_LOGIN = 0xAA02;
public static final int MSG_LOGIN_RSP = 0xFF03;
+ public static final int MSG_HSO_REQ = 0x0002;
+ public static final int MSG_HSO_RSP = 0x0003;
- private static void sendResponse(Channel channel, int type, int index, ChannelBuffer content) {
+ private void sendResponse(Channel channel, int type, int index, ChannelBuffer content) {
if (channel != null) {
ChannelBuffer response = ChannelBuffers.dynamicBuffer();
response.writeByte(0xC0);
response.writeShort(0x0100);
- response.writeShort(12 + content.readableBytes());
+ response.writeShort(12 + (content != null ? content.readableBytes() : 0));
response.writeShort(type);
response.writeShort(0);
response.writeInt(index);
- response.writeBytes(content);
+ if (content != null) {
+ response.writeBytes(content);
+ }
response.writeByte(0xC0);
channel.write(response);
}
@@ -88,6 +92,10 @@ public class HuaShengProtocolDecoder extends BaseProtocolDecoder {
}
}
+ } else if (type == MSG_HSO_REQ) {
+
+ sendResponse(channel, MSG_HSO_RSP, index, null);
+
} else if (type == MSG_POSITION) {
DeviceSession deviceSession = getDeviceSession(channel, remoteAddress);
@@ -133,7 +141,7 @@ public class HuaShengProtocolDecoder extends BaseProtocolDecoder {
buf.skipBytes(length);
}
- sendResponse(channel, MSG_POSITION_RSP, index, ChannelBuffers.dynamicBuffer());
+ sendResponse(channel, MSG_POSITION_RSP, index, null);
return position;
diff --git a/test/org/traccar/protocol/HuaShengProtocolDecoderTest.java b/test/org/traccar/protocol/HuaShengProtocolDecoderTest.java
index 424d7959b..97bcf9954 100644
--- a/test/org/traccar/protocol/HuaShengProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/HuaShengProtocolDecoderTest.java
@@ -11,6 +11,9 @@ public class HuaShengProtocolDecoderTest extends ProtocolTest {
HuaShengProtocolDecoder decoder = new HuaShengProtocolDecoder(new HuaShengProtocol());
verifyNull(decoder, binary(
+ "c0010c003c0002000000000044020010a0014f42445f3347315f56322e320013a0043335353835353035313032303536360006a08700000006a0a105c9c0"));
+
+ verifyNull(decoder, binary(
"c000000077aa0200000000000e000100143347315f48312e315f56312e30372e54000300133335353835353035303434303635380004000b3531323030303000050005010006000400070004000800050000090018383936313032353431343533333239313833360d000a000f796573696e7465726e6574c0"));
verifyPosition(decoder, binary(