aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol/TytanProtocolDecoder.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-04-23 15:49:56 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2015-04-23 15:49:56 +1200
commit2a3fad9496decd83f06ae5abf067f8d4337ec741 (patch)
tree69837f0bf89cf6ff78915d70380118575cc5c47a /src/org/traccar/protocol/TytanProtocolDecoder.java
parenta8d2a0170b7ac891ffe784320ac2d1389f11bf68 (diff)
downloadtrackermap-server-2a3fad9496decd83f06ae5abf067f8d4337ec741.tar.gz
trackermap-server-2a3fad9496decd83f06ae5abf067f8d4337ec741.tar.bz2
trackermap-server-2a3fad9496decd83f06ae5abf067f8d4337ec741.zip
Major code refacroting
Diffstat (limited to 'src/org/traccar/protocol/TytanProtocolDecoder.java')
-rw-r--r--src/org/traccar/protocol/TytanProtocolDecoder.java17
1 files changed, 5 insertions, 12 deletions
diff --git a/src/org/traccar/protocol/TytanProtocolDecoder.java b/src/org/traccar/protocol/TytanProtocolDecoder.java
index 5b3772d31..e0dc7f68e 100644
--- a/src/org/traccar/protocol/TytanProtocolDecoder.java
+++ b/src/org/traccar/protocol/TytanProtocolDecoder.java
@@ -34,13 +34,10 @@ import org.traccar.model.Position;
public class TytanProtocolDecoder extends BaseProtocolDecoder {
- public TytanProtocolDecoder(DataManager dataManager, String protocol, Properties properties) {
- super(dataManager, protocol, properties);
+ public TytanProtocolDecoder(String protocol) {
+ super(protocol);
}
- private static final int MSG_HEARTBEAT = 0x1A;
- private static final int MSG_DATA = 0x10;
-
@Override
protected Object decode(
ChannelHandlerContext ctx, Channel channel, SocketAddress remoteAddress, Object msg)
@@ -58,21 +55,17 @@ public class TytanProtocolDecoder extends BaseProtocolDecoder {
}
String id = String.valueOf(buf.readUnsignedInt());
- long deviceId;
- try {
- deviceId = getDataManager().getDeviceByImei(id).getId();
- } catch(Exception error) {
- Log.warning("Unknown device - " + id);
+ if (!identify(id)) {
return null;
}
-
+
List<Position> positions = new LinkedList<Position>();
while (buf.readable()) {
Position position = new Position();
ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol());
- position.setDeviceId(deviceId);
+ position.setDeviceId(getDeviceId());
int end = buf.readerIndex() + buf.readUnsignedByte();