aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2019-11-11 20:54:14 -0800
committerAnton Tananaev <anton.tananaev@gmail.com>2019-11-11 20:54:14 -0800
commita681b0608a18416ad58bfeedacda0b036a856da4 (patch)
tree323243e3e9d9d3d72f9c76ecd2eddfeefc02549e
parent985c3a324a566f803ec83658680974a7f75b0b7d (diff)
downloadtrackermap-server-a681b0608a18416ad58bfeedacda0b036a856da4.tar.gz
trackermap-server-a681b0608a18416ad58bfeedacda0b036a856da4.tar.bz2
trackermap-server-a681b0608a18416ad58bfeedacda0b036a856da4.zip
Update response format
-rw-r--r--src/main/java/org/traccar/protocol/TopinProtocolDecoder.java16
1 files changed, 7 insertions, 9 deletions
diff --git a/src/main/java/org/traccar/protocol/TopinProtocolDecoder.java b/src/main/java/org/traccar/protocol/TopinProtocolDecoder.java
index 9393fbca9..4334ae5cb 100644
--- a/src/main/java/org/traccar/protocol/TopinProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/TopinProtocolDecoder.java
@@ -39,13 +39,16 @@ public class TopinProtocolDecoder extends BaseProtocolDecoder {
public static final int MSG_GPS_OFFLINE = 0x11;
public static final int MSG_STATUS = 0x13;
- private void sendResponse(Channel channel, ByteBuf content) {
+ private void sendResponse(Channel channel, int type, ByteBuf content) {
if (channel != null) {
ByteBuf response = Unpooled.buffer();
response.writeShort(0x7878);
+ response.writeByte(1 + content.readableBytes());
+ response.writeByte(type);
response.writeBytes(content);
response.writeByte('\r');
response.writeByte('\n');
+ content.release();
channel.writeAndFlush(new NetworkMessage(response, channel.remoteAddress()));
}
}
@@ -66,9 +69,8 @@ public class TopinProtocolDecoder extends BaseProtocolDecoder {
String imei = ByteBufUtil.hexDump(buf.readSlice(8)).substring(1);
deviceSession = getDeviceSession(channel, remoteAddress, imei);
ByteBuf content = Unpooled.buffer();
- content.writeByte(type);
content.writeByte(deviceSession != null ? 0x01 : 0x44);
- sendResponse(channel, content);
+ sendResponse(channel, type, content);
return null;
} else {
deviceSession = getDeviceSession(channel, remoteAddress);
@@ -87,10 +89,8 @@ public class TopinProtocolDecoder extends BaseProtocolDecoder {
Gt06ProtocolDecoder.decodeGps(position, buf, false, TimeZone.getTimeZone("UTC"));
ByteBuf content = Unpooled.buffer();
- content.writeByte(0);
- content.writeByte(type);
content.writeBytes(time);
- sendResponse(channel, content);
+ sendResponse(channel, type, content);
return position;
@@ -115,8 +115,6 @@ public class TopinProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_VERSION_FW, firmware);
ByteBuf content = Unpooled.buffer();
- content.writeByte(length);
- content.writeByte(type);
content.writeByte(battery);
content.writeByte(firmware);
content.writeByte(timezone);
@@ -124,7 +122,7 @@ public class TopinProtocolDecoder extends BaseProtocolDecoder {
if (length >= 7) {
content.writeByte(signal);
}
- sendResponse(channel, content);
+ sendResponse(channel, type, content);
return position;