aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol/M2mProtocolDecoder.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/M2mProtocolDecoder.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/M2mProtocolDecoder.java')
-rw-r--r--src/org/traccar/protocol/M2mProtocolDecoder.java17
1 files changed, 6 insertions, 11 deletions
diff --git a/src/org/traccar/protocol/M2mProtocolDecoder.java b/src/org/traccar/protocol/M2mProtocolDecoder.java
index 46442fb4f..0daa07422 100644
--- a/src/org/traccar/protocol/M2mProtocolDecoder.java
+++ b/src/org/traccar/protocol/M2mProtocolDecoder.java
@@ -31,12 +31,11 @@ import org.traccar.model.Position;
public class M2mProtocolDecoder extends BaseProtocolDecoder {
- public M2mProtocolDecoder(DataManager dataManager, String protocol, Properties properties) {
- super(dataManager, protocol, properties);
+ public M2mProtocolDecoder(String protocol) {
+ super(protocol);
}
private boolean firstPacket = true;
- private Long deviceId;
@Override
protected Object decode(
@@ -68,18 +67,14 @@ public class M2mProtocolDecoder extends BaseProtocolDecoder {
}
// Identification
- try {
- deviceId = getDataManager().getDeviceByImei(imei.toString()).getId();
- } catch(Exception error) {
- Log.warning("Unknown device - " + imei);
- }
-
- } else if (deviceId != null) {
+ identify(imei.toString());
+
+ } else if (hasDeviceId()) {
// Create new position
Position position = new Position();
ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol());
- position.setDeviceId(deviceId);
+ position.setDeviceId(getDeviceId());
// Date and time
Calendar time = Calendar.getInstance(TimeZone.getTimeZone("UTC"));