From 2a3fad9496decd83f06ae5abf067f8d4337ec741 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Thu, 23 Apr 2015 15:49:56 +1200 Subject: Major code refacroting --- src/org/traccar/protocol/NavisProtocolDecoder.java | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) (limited to 'src/org/traccar/protocol/NavisProtocolDecoder.java') diff --git a/src/org/traccar/protocol/NavisProtocolDecoder.java b/src/org/traccar/protocol/NavisProtocolDecoder.java index 4646d215f..8a5afc17f 100644 --- a/src/org/traccar/protocol/NavisProtocolDecoder.java +++ b/src/org/traccar/protocol/NavisProtocolDecoder.java @@ -37,15 +37,12 @@ import org.traccar.model.Position; public class NavisProtocolDecoder extends BaseProtocolDecoder { private String prefix; - private long deviceId, serverId; + private long deviceUniqueId, serverId; private static final Charset charset = Charset.defaultCharset(); - private String imei; - private Long databaseDeviceId; - - public NavisProtocolDecoder(DataManager dataManager, String protocol, Properties properties) { - super(dataManager, protocol, properties); + public NavisProtocolDecoder(String protocol) { + super(protocol); } // Format types @@ -88,7 +85,7 @@ public class NavisProtocolDecoder extends BaseProtocolDecoder { Position position = new Position(); ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); - position.setDeviceId(databaseDeviceId); + position.setDeviceId(getDeviceId()); position.setAltitude(0.0); // Format type @@ -262,12 +259,8 @@ public class NavisProtocolDecoder extends BaseProtocolDecoder { private Object processHandshake(Channel channel, ChannelBuffer buf) { buf.readByte(); // semicolon symbol - imei = buf.toString(Charset.defaultCharset()); - try { - databaseDeviceId = getDataManager().getDeviceByImei(imei).getId(); + if (identify(buf.toString(Charset.defaultCharset()))) { sendReply(channel, ChannelBuffers.copiedBuffer(ByteOrder.LITTLE_ENDIAN, "*