aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol/AutoFon45ProtocolDecoder.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/traccar/protocol/AutoFon45ProtocolDecoder.java')
-rw-r--r--src/org/traccar/protocol/AutoFon45ProtocolDecoder.java12
1 files changed, 4 insertions, 8 deletions
diff --git a/src/org/traccar/protocol/AutoFon45ProtocolDecoder.java b/src/org/traccar/protocol/AutoFon45ProtocolDecoder.java
index df98fa93b..c72139c50 100644
--- a/src/org/traccar/protocol/AutoFon45ProtocolDecoder.java
+++ b/src/org/traccar/protocol/AutoFon45ProtocolDecoder.java
@@ -32,15 +32,14 @@ import org.traccar.model.Position;
import java.util.*;
public class AutoFon45ProtocolDecoder extends BaseProtocolDecoder {
- private long deviceId;
private static double convertCoordinate(short degrees, int raw) {
double seconds = (raw >> 4 & 0xffffff) / 600000.0;
return (degrees + seconds) * ((raw & 0x0f) == 0 ? -1 : 1);
}
- public AutoFon45ProtocolDecoder(DataManager dataManager, String protocol, Properties properties) {
- super(dataManager, protocol, properties);
+ public AutoFon45ProtocolDecoder(String protocol) {
+ super(protocol);
}
@Override
@@ -54,10 +53,7 @@ public class AutoFon45ProtocolDecoder extends BaseProtocolDecoder {
buf.readBytes(bytes);
String imei = ChannelBufferTools.readHexString(ChannelBuffers.wrappedBuffer(bytes, 1, 16), 16).substring(1);
- try {
- deviceId = getDataManager().getDeviceByImei(imei).getId();
- } catch(Exception error) {
- Log.warning("Unknown device - " + imei);
+ if (!identify(imei)) {
return null;
}
@@ -74,7 +70,7 @@ public class AutoFon45ProtocolDecoder extends BaseProtocolDecoder {
// Create new position
Position position = new Position();
ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol());
- position.setDeviceId(deviceId);
+ position.setDeviceId(getDeviceId());
short status = buf.readUnsignedByte();
extendedInfo.set("alarm", (status & 0x80) != 0);