aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol/CellocatorProtocolDecoder.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/CellocatorProtocolDecoder.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/CellocatorProtocolDecoder.java')
-rw-r--r--src/org/traccar/protocol/CellocatorProtocolDecoder.java16
1 files changed, 7 insertions, 9 deletions
diff --git a/src/org/traccar/protocol/CellocatorProtocolDecoder.java b/src/org/traccar/protocol/CellocatorProtocolDecoder.java
index 178e17530..a61c5b79f 100644
--- a/src/org/traccar/protocol/CellocatorProtocolDecoder.java
+++ b/src/org/traccar/protocol/CellocatorProtocolDecoder.java
@@ -33,8 +33,8 @@ import org.traccar.model.Position;
public class CellocatorProtocolDecoder extends BaseProtocolDecoder {
- public CellocatorProtocolDecoder(DataManager dataManager, String protocol, Properties properties) {
- super(dataManager, protocol, properties);
+ public CellocatorProtocolDecoder(String protocol) {
+ super(protocol);
}
private String readImei(ChannelBuffer buf) {
@@ -93,7 +93,7 @@ public class CellocatorProtocolDecoder extends BaseProtocolDecoder {
buf.skipBytes(4); // system code
int type = buf.readUnsignedByte();
- long deviceId = buf.readUnsignedInt();
+ long deviceUniqueId = buf.readUnsignedInt();
if (type != MSG_CLIENT_SERIAL) {
buf.readUnsignedShort(); // communication control
@@ -101,7 +101,7 @@ public class CellocatorProtocolDecoder extends BaseProtocolDecoder {
byte packetNumber = buf.readByte();
// Send reply
- sendReply(channel, deviceId, packetNumber);
+ sendReply(channel, deviceUniqueId, packetNumber);
// Parse location
if (type == MSG_CLIENT_STATUS) {
@@ -109,13 +109,11 @@ public class CellocatorProtocolDecoder extends BaseProtocolDecoder {
ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol());
// Device identifier
- try {
- position.setDeviceId(getDataManager().getDeviceByImei(String.valueOf(deviceId)).getId());
- } catch(Exception error) {
- Log.warning("Unknown device - " + deviceId);
+ if (!identify(String.valueOf(deviceUniqueId))) {
return null;
}
-
+ position.setDeviceId(getDeviceId());
+
buf.readUnsignedByte(); // hardware version
buf.readUnsignedByte(); // software version
buf.readUnsignedByte(); // protocol version