aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2018-11-28 15:28:55 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2018-11-28 15:28:55 +1300
commit2f41a4d95b5be4804b32cac6d96c1b152d53d7ec (patch)
treecd8e780c461123aa9c3fe87f1e050a730e1c6647
parente11d7edca8d25d8614034d023468102fcc9df563 (diff)
downloadtrackermap-server-2f41a4d95b5be4804b32cac6d96c1b152d53d7ec.tar.gz
trackermap-server-2f41a4d95b5be4804b32cac6d96c1b152d53d7ec.tar.bz2
trackermap-server-2f41a4d95b5be4804b32cac6d96c1b152d53d7ec.zip
Extend KHD / Sabo SPG02B support
-rw-r--r--src/org/traccar/protocol/KhdProtocolDecoder.java39
-rw-r--r--test/org/traccar/protocol/KhdProtocolDecoderTest.java3
2 files changed, 26 insertions, 16 deletions
diff --git a/src/org/traccar/protocol/KhdProtocolDecoder.java b/src/org/traccar/protocol/KhdProtocolDecoder.java
index f186fc0d5..0dd5b085a 100644
--- a/src/org/traccar/protocol/KhdProtocolDecoder.java
+++ b/src/org/traccar/protocol/KhdProtocolDecoder.java
@@ -50,7 +50,10 @@ public class KhdProtocolDecoder extends BaseProtocolDecoder {
public static final int MSG_POSITION_UPLOAD = 0x80;
public static final int MSG_POSITION_REUPLOAD = 0x8E;
public static final int MSG_ALARM = 0x82;
+ public static final int MSG_ADMIN_NUMBER = 0x83;
+ public static final int MSG_SEND_TEXT = 0x84;
public static final int MSG_REPLY = 0x85;
+ public static final int MSG_SMS_ALARM_SWITCH = 0x86;
public static final int MSG_PERIPHERAL = 0xA3;
@Override
@@ -63,6 +66,26 @@ public class KhdProtocolDecoder extends BaseProtocolDecoder {
int type = buf.readUnsignedByte();
buf.readUnsignedShort(); // size
+ if (type == MSG_LOGIN || type == MSG_ADMIN_NUMBER || type == MSG_SEND_TEXT
+ || type == MSG_SMS_ALARM_SWITCH || type == MSG_POSITION_REUPLOAD) {
+
+ ByteBuf response = Unpooled.buffer();
+ response.writeByte(0x29);
+ response.writeByte(0x29); // header
+ response.writeByte(MSG_CONFIRMATION);
+ response.writeShort(5); // size
+ response.writeByte(buf.getByte(buf.writerIndex() - 2));
+ response.writeByte(type);
+ response.writeByte(buf.writerIndex() > 9 ? buf.getByte(9) : 0); // 10th byte
+ response.writeByte(Checksum.xor(response.nioBuffer()));
+ response.writeByte(0x0D); // ending
+
+ if (channel != null) {
+ channel.writeAndFlush(new NetworkMessage(response, remoteAddress));
+ }
+
+ }
+
if (type == MSG_ON_DEMAND || type == MSG_POSITION_UPLOAD || type == MSG_POSITION_REUPLOAD
|| type == MSG_ALARM || type == MSG_REPLY || type == MSG_PERIPHERAL) {
@@ -126,22 +149,6 @@ public class KhdProtocolDecoder extends BaseProtocolDecoder {
return position;
- } else if (type == MSG_LOGIN && channel != null) {
-
- buf.skipBytes(4); // serial number
- buf.readByte(); // reserved
-
- ByteBuf response = Unpooled.buffer();
- response.writeByte(0x29); response.writeByte(0x29); // header
- response.writeByte(MSG_CONFIRMATION);
- response.writeShort(5); // size
- response.writeByte(buf.readUnsignedByte());
- response.writeByte(type);
- response.writeByte(0); // reserved
- response.writeByte(Checksum.xor(response.nioBuffer()));
- response.writeByte(0x0D); // ending
- channel.writeAndFlush(new NetworkMessage(response, remoteAddress));
-
}
return null;
diff --git a/test/org/traccar/protocol/KhdProtocolDecoderTest.java b/test/org/traccar/protocol/KhdProtocolDecoderTest.java
index 21494014c..62b6070b6 100644
--- a/test/org/traccar/protocol/KhdProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/KhdProtocolDecoderTest.java
@@ -14,6 +14,9 @@ public class KhdProtocolDecoderTest extends ProtocolTest {
"2929b1000605162935b80d"));
verifyPosition(decoder, binary(
+ "29298e006d1f29402d181117083846801193910365274500000000f80000227ffc3f00001e00500000000000060088000000220019ffc100000000000000000000000000000000007080002000000016ff893839323534303231303734313134323334333639000800233030302e30306e0d"));
+
+ verifyPosition(decoder, binary(
"2929a3002e1780c663170216203353003060811013839500000114f8000000ffff5000000a00000000000000060102003db70d"));
verifyPosition(decoder, binary(