diff options
Diffstat (limited to 'src/org/traccar')
-rw-r--r-- | src/org/traccar/protocol/EelinkProtocol.java | 10 | ||||
-rw-r--r-- | src/org/traccar/protocol/EelinkProtocolDecoder.java | 15 |
2 files changed, 22 insertions, 3 deletions
diff --git a/src/org/traccar/protocol/EelinkProtocol.java b/src/org/traccar/protocol/EelinkProtocol.java index 5499094d9..3c3424cd4 100644 --- a/src/org/traccar/protocol/EelinkProtocol.java +++ b/src/org/traccar/protocol/EelinkProtocol.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2016 Anton Tananaev (anton@traccar.org) + * Copyright 2015 - 2017 Anton Tananaev (anton@traccar.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,6 +15,7 @@ */ package org.traccar.protocol; +import org.jboss.netty.bootstrap.ConnectionlessBootstrap; import org.jboss.netty.bootstrap.ServerBootstrap; import org.jboss.netty.channel.ChannelPipeline; import org.jboss.netty.handler.codec.frame.LengthFieldBasedFrameDecoder; @@ -45,6 +46,13 @@ public class EelinkProtocol extends BaseProtocol { pipeline.addLast("objectDecoder", new EelinkProtocolDecoder(EelinkProtocol.this)); } }); + serverList.add(new TrackerServer(new ConnectionlessBootstrap(), getName()) { + @Override + protected void addSpecificHandlers(ChannelPipeline pipeline) { + pipeline.addLast("objectEncoder", new EelinkProtocolEncoder()); + pipeline.addLast("objectDecoder", new EelinkProtocolDecoder(EelinkProtocol.this)); + } + }); } } diff --git a/src/org/traccar/protocol/EelinkProtocolDecoder.java b/src/org/traccar/protocol/EelinkProtocolDecoder.java index 8d0f8016a..91ae16289 100644 --- a/src/org/traccar/protocol/EelinkProtocolDecoder.java +++ b/src/org/traccar/protocol/EelinkProtocolDecoder.java @@ -265,6 +265,16 @@ public class EelinkProtocolDecoder extends BaseProtocolDecoder { ChannelBuffer buf = (ChannelBuffer) msg; + DeviceSession deviceSession = null; + + if (buf.getByte(0) == 'E' && buf.getByte(1) == 'L') { + buf.skipBytes(2 + 2 + 2); // udp header + deviceSession = getDeviceSession( + channel, remoteAddress, ChannelBuffers.hexDump(buf.readBytes(8)).substring(1)); + } else { + deviceSession = getDeviceSession(channel, remoteAddress); + } + buf.skipBytes(2); // header int type = buf.readUnsignedByte(); buf.readShort(); // length @@ -276,11 +286,12 @@ public class EelinkProtocolDecoder extends BaseProtocolDecoder { if (type == MSG_LOGIN) { - getDeviceSession(channel, remoteAddress, ChannelBuffers.hexDump(buf.readBytes(8)).substring(1)); + if (deviceSession == null) { + getDeviceSession(channel, remoteAddress, ChannelBuffers.hexDump(buf.readBytes(8)).substring(1)); + } } else { - DeviceSession deviceSession = getDeviceSession(channel, remoteAddress); if (deviceSession == null) { return null; } |