aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/traccar/protocol')
-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;
}