From b149a7b71283f1a8481c9e3954d636afcff6169e Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Mon, 27 Nov 2017 22:56:22 +1300 Subject: Support eeLink UDP format --- src/org/traccar/protocol/EelinkProtocolDecoder.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'src/org/traccar/protocol/EelinkProtocolDecoder.java') 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; } -- cgit v1.2.3