diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2017-11-27 22:56:22 +1300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2017-11-27 22:56:22 +1300 |
commit | b149a7b71283f1a8481c9e3954d636afcff6169e (patch) | |
tree | c0682f9493518cb096bfe2e7f609513566c523ff /src/org/traccar/protocol | |
parent | 4f772b76b08d7515cf27c7bfda819612aeea26f9 (diff) | |
download | trackermap-server-b149a7b71283f1a8481c9e3954d636afcff6169e.tar.gz trackermap-server-b149a7b71283f1a8481c9e3954d636afcff6169e.tar.bz2 trackermap-server-b149a7b71283f1a8481c9e3954d636afcff6169e.zip |
Support eeLink UDP format
Diffstat (limited to 'src/org/traccar/protocol')
-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; } |