aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol/GalileoProtocolDecoder.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/GalileoProtocolDecoder.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/GalileoProtocolDecoder.java')
-rw-r--r--src/org/traccar/protocol/GalileoProtocolDecoder.java18
1 files changed, 6 insertions, 12 deletions
diff --git a/src/org/traccar/protocol/GalileoProtocolDecoder.java b/src/org/traccar/protocol/GalileoProtocolDecoder.java
index 0fa881949..99b745175 100644
--- a/src/org/traccar/protocol/GalileoProtocolDecoder.java
+++ b/src/org/traccar/protocol/GalileoProtocolDecoder.java
@@ -32,8 +32,8 @@ import org.traccar.model.Position;
public class GalileoProtocolDecoder extends BaseProtocolDecoder {
- public GalileoProtocolDecoder(DataManager dataManager, String protocol, Properties properties) {
- super(dataManager, protocol, properties);
+ public GalileoProtocolDecoder(String protocol) {
+ super(protocol);
}
private static final int TAG_IMEI = 0x03;
@@ -77,9 +77,7 @@ public class GalileoProtocolDecoder extends BaseProtocolDecoder {
channel.write(reply);
}
}
-
- private Long deviceId;
-
+
@Override
protected Object decode(
ChannelHandlerContext ctx, Channel channel, Object msg)
@@ -113,11 +111,7 @@ public class GalileoProtocolDecoder extends BaseProtocolDecoder {
case TAG_IMEI:
String imei = buf.toString(buf.readerIndex(), 15, Charset.defaultCharset());
buf.skipBytes(imei.length());
- try {
- deviceId = getDataManager().getDeviceByImei(imei).getId();
- } catch(Exception error) {
- Log.warning("Unknown device - " + imei);
- }
+ identify(imei);
break;
case TAG_DATE:
@@ -165,7 +159,7 @@ public class GalileoProtocolDecoder extends BaseProtocolDecoder {
position.setExtendedInfo(extendedInfo.toString());
positions.add(position);
- if (deviceId == null) {
+ if (!hasDeviceId()) {
Log.warning("Unknown device");
return null;
}
@@ -175,7 +169,7 @@ public class GalileoProtocolDecoder extends BaseProtocolDecoder {
for (Iterator<Position> i = positions.iterator(); i.hasNext(); ) {
Position p = i.next();
- p.setDeviceId(deviceId);
+ p.setDeviceId(getDeviceId());
if (p.getAltitude() == null) {
p.setAltitude(0.0);