aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2019-01-22 21:50:29 -0800
committerAnton Tananaev <anton.tananaev@gmail.com>2019-01-22 21:50:29 -0800
commit4c876606ca3afa794366bcc0688fdafaa6b02f4f (patch)
tree0042904070bda9da18a27e0c999de8f9d41a8768
parent873e2ce995df4fb920a2fd19aaadc1bc78f5581a (diff)
downloadtrackermap-server-4c876606ca3afa794366bcc0688fdafaa6b02f4f.tar.gz
trackermap-server-4c876606ca3afa794366bcc0688fdafaa6b02f4f.tar.bz2
trackermap-server-4c876606ca3afa794366bcc0688fdafaa6b02f4f.zip
Fix eelink login response
-rw-r--r--src/org/traccar/protocol/EelinkProtocolDecoder.java21
-rw-r--r--src/org/traccar/protocol/EelinkProtocolEncoder.java1
2 files changed, 14 insertions, 8 deletions
diff --git a/src/org/traccar/protocol/EelinkProtocolDecoder.java b/src/org/traccar/protocol/EelinkProtocolDecoder.java
index dcc87dccc..14bf44fbf 100644
--- a/src/org/traccar/protocol/EelinkProtocolDecoder.java
+++ b/src/org/traccar/protocol/EelinkProtocolDecoder.java
@@ -17,6 +17,7 @@ package org.traccar.protocol;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufUtil;
+import io.netty.buffer.Unpooled;
import io.netty.channel.Channel;
import io.netty.channel.socket.DatagramChannel;
import org.traccar.BaseProtocolDecoder;
@@ -62,13 +63,6 @@ public class EelinkProtocolDecoder extends BaseProtocolDecoder {
public static final int MSG_CAMERA_INFO = 0x1E;
public static final int MSG_CAMERA_DATA = 0x1F;
- private void sendResponse(Channel channel, SocketAddress remoteAddress, String uniqueId, int type, int index) {
- if (channel != null) {
- channel.writeAndFlush(new NetworkMessage(EelinkProtocolEncoder.encodeContent(
- channel instanceof DatagramChannel, uniqueId, type, index, null), remoteAddress));
- }
- }
-
private String decodeAlarm(Short value) {
switch (value) {
case 0x01:
@@ -356,7 +350,18 @@ public class EelinkProtocolDecoder extends BaseProtocolDecoder {
int index = buf.readUnsignedShort();
if (type != MSG_GPS && type != MSG_DATA) {
- sendResponse(channel, remoteAddress, uniqueId, type, index);
+ ByteBuf content = Unpooled.buffer();
+ if (type == MSG_LOGIN) {
+ content.writeInt((int) (System.currentTimeMillis() / 1000));
+ content.writeByte(1); // protocol version
+ content.writeByte(0); // action mask
+ }
+ ByteBuf response = EelinkProtocolEncoder.encodeContent(
+ channel instanceof DatagramChannel, uniqueId, type, index, content);
+ content.release();
+ if (channel != null) {
+ channel.writeAndFlush(new NetworkMessage(response, remoteAddress));
+ }
}
if (type == MSG_LOGIN) {
diff --git a/src/org/traccar/protocol/EelinkProtocolEncoder.java b/src/org/traccar/protocol/EelinkProtocolEncoder.java
index c005fbc67..8f33441fb 100644
--- a/src/org/traccar/protocol/EelinkProtocolEncoder.java
+++ b/src/org/traccar/protocol/EelinkProtocolEncoder.java
@@ -69,6 +69,7 @@ public class EelinkProtocolEncoder extends BaseProtocolEncoder {
}
result.writeBytes(buf);
+ buf.release();
return result;
}