aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol/CalAmpProtocolDecoder.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/CalAmpProtocolDecoder.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/CalAmpProtocolDecoder.java')
-rw-r--r--src/org/traccar/protocol/CalAmpProtocolDecoder.java22
1 files changed, 6 insertions, 16 deletions
diff --git a/src/org/traccar/protocol/CalAmpProtocolDecoder.java b/src/org/traccar/protocol/CalAmpProtocolDecoder.java
index 8fe75bf93..04ac8f165 100644
--- a/src/org/traccar/protocol/CalAmpProtocolDecoder.java
+++ b/src/org/traccar/protocol/CalAmpProtocolDecoder.java
@@ -33,8 +33,8 @@ import org.traccar.model.Position;
public class CalAmpProtocolDecoder extends BaseProtocolDecoder {
- public CalAmpProtocolDecoder(DataManager dataManager, String protocol, Properties properties) {
- super(dataManager, protocol, properties);
+ public CalAmpProtocolDecoder(String protocol) {
+ super(protocol);
}
private static final int MSG_NULL = 0;
@@ -91,8 +91,6 @@ public class CalAmpProtocolDecoder extends BaseProtocolDecoder {
ChannelBuffer buf = (ChannelBuffer) msg;
- Long deviceId = null;
-
// Check options header
if ((buf.getByte(buf.readerIndex()) & 0x80) != 0) {
@@ -112,14 +110,7 @@ public class CalAmpProtocolDecoder extends BaseProtocolDecoder {
}
}
- // Find device in database
- String stringId = String.valueOf(id);
- try {
- deviceId = getDataManager().getDeviceByImei(stringId).getId();
- } catch(Exception error) {
- Log.warning("Unknown device - " + stringId);
- }
-
+ identify(String.valueOf(id));
}
// Identifier type
@@ -150,8 +141,7 @@ public class CalAmpProtocolDecoder extends BaseProtocolDecoder {
}
// Unidentified device
- if (deviceId == null) {
- Log.warning("Unknown device");
+ if (!hasDeviceId()) {
return null;
}
@@ -170,8 +160,8 @@ public class CalAmpProtocolDecoder extends BaseProtocolDecoder {
// Create new position
Position position = new Position();
- position.setDeviceId(deviceId);
- ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("calamp");
+ position.setDeviceId(getDeviceId());
+ ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol());
// Location data
position.setTime(new Date(buf.readUnsignedInt() * 1000));