aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/protocol/PstProtocolDecoder.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2020-07-29 20:58:02 -0700
committerAnton Tananaev <anton.tananaev@gmail.com>2020-07-29 20:58:02 -0700
commit250dc821dd304ca72058012b5a387194489cbe72 (patch)
treeb8aba5cdd8c40442734e8e20b7ab05c03fdad813 /src/main/java/org/traccar/protocol/PstProtocolDecoder.java
parent02156420e2b7e8ca60982c60c26245c77069dd6e (diff)
downloadtrackermap-server-250dc821dd304ca72058012b5a387194489cbe72.tar.gz
trackermap-server-250dc821dd304ca72058012b5a387194489cbe72.tar.bz2
trackermap-server-250dc821dd304ca72058012b5a387194489cbe72.zip
Implement PST commands
Diffstat (limited to 'src/main/java/org/traccar/protocol/PstProtocolDecoder.java')
-rw-r--r--src/main/java/org/traccar/protocol/PstProtocolDecoder.java21
1 files changed, 7 insertions, 14 deletions
diff --git a/src/main/java/org/traccar/protocol/PstProtocolDecoder.java b/src/main/java/org/traccar/protocol/PstProtocolDecoder.java
index 62cc203d2..e3fe1af62 100644
--- a/src/main/java/org/traccar/protocol/PstProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/PstProtocolDecoder.java
@@ -38,6 +38,7 @@ public class PstProtocolDecoder extends BaseProtocolDecoder {
public static final int MSG_ACK = 0x00;
public static final int MSG_STATUS = 0x05;
+ public static final int MSG_COMMAND = 0x06;
private Date readDate(ByteBuf buf) {
long value = buf.readUnsignedInt();
@@ -61,21 +62,13 @@ public class PstProtocolDecoder extends BaseProtocolDecoder {
Channel channel, SocketAddress remoteAddress, long id, int version, long index, int type) {
if (channel != null) {
- ByteBuf content = Unpooled.buffer();
- content.writeInt((int) id);
- content.writeByte(version);
- content.writeInt((int) index);
- content.writeByte(MSG_ACK);
- content.writeByte(type);
-
- int checksum = Checksum.crc16(Checksum.CRC16_XMODEM, content.nioBuffer());
-
ByteBuf response = Unpooled.buffer();
- response.writeByte('(');
- response.writeBytes(content);
- content.release();
- response.writeShort(checksum);
- response.writeByte(')');
+ response.writeInt((int) id);
+ response.writeByte(version);
+ response.writeInt((int) index);
+ response.writeByte(MSG_ACK);
+ response.writeByte(type);
+ response.writeShort(Checksum.crc16(Checksum.CRC16_XMODEM, response.nioBuffer()));
channel.writeAndFlush(new NetworkMessage(response, remoteAddress));