aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol/KhdProtocolDecoder.java
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 /src/org/traccar/protocol/KhdProtocolDecoder.java
parente11d7edca8d25d8614034d023468102fcc9df563 (diff)
downloadtrackermap-server-2f41a4d95b5be4804b32cac6d96c1b152d53d7ec.tar.gz
trackermap-server-2f41a4d95b5be4804b32cac6d96c1b152d53d7ec.tar.bz2
trackermap-server-2f41a4d95b5be4804b32cac6d96c1b152d53d7ec.zip
Extend KHD / Sabo SPG02B support
Diffstat (limited to 'src/org/traccar/protocol/KhdProtocolDecoder.java')
-rw-r--r--src/org/traccar/protocol/KhdProtocolDecoder.java39
1 files changed, 23 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;