aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol/Mta6ProtocolDecoder.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/Mta6ProtocolDecoder.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/Mta6ProtocolDecoder.java')
-rw-r--r--src/org/traccar/protocol/Mta6ProtocolDecoder.java22
1 files changed, 9 insertions, 13 deletions
diff --git a/src/org/traccar/protocol/Mta6ProtocolDecoder.java b/src/org/traccar/protocol/Mta6ProtocolDecoder.java
index d8d1b9f98..f09cf32f1 100644
--- a/src/org/traccar/protocol/Mta6ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Mta6ProtocolDecoder.java
@@ -44,8 +44,8 @@ public class Mta6ProtocolDecoder extends BaseProtocolDecoder {
private boolean simple;
- public Mta6ProtocolDecoder(DataManager dataManager, String protocol, Properties properties, boolean simple) {
- super(dataManager, protocol, properties);
+ public Mta6ProtocolDecoder(String protocol, boolean simple) {
+ super(protocol);
this.simple = simple;
}
@@ -121,7 +121,7 @@ public class Mta6ProtocolDecoder extends BaseProtocolDecoder {
}
- private List<Position> parseFormatA(ChannelBuffer buf, long deviceId) {
+ private List<Position> parseFormatA(ChannelBuffer buf) {
List<Position> positions = new LinkedList<Position>();
FloatReader latitudeReader = new FloatReader();
@@ -131,7 +131,7 @@ public class Mta6ProtocolDecoder extends BaseProtocolDecoder {
try {
while (buf.readable()) {
Position position = new Position();
- position.setDeviceId(deviceId);
+ position.setDeviceId(getDeviceId());
ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol());
short flags = buf.readUnsignedByte();
@@ -211,9 +211,9 @@ public class Mta6ProtocolDecoder extends BaseProtocolDecoder {
return positions;
}
- private Position parseFormatA1(ChannelBuffer buf, long deviceId) {
+ private Position parseFormatA1(ChannelBuffer buf) {
Position position = new Position();
- position.setDeviceId(deviceId);
+ position.setDeviceId(getDeviceId());
ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol());
short flags = buf.readUnsignedByte();
@@ -303,11 +303,7 @@ public class Mta6ProtocolDecoder extends BaseProtocolDecoder {
buf.skipBytes("id=".length());
int index = ChannelBufferTools.find(buf, buf.readerIndex(), length, "&");
String uniqueId = buf.toString(buf.readerIndex(), index - buf.readerIndex(), Charset.defaultCharset());
- long deviceId;
- try {
- deviceId = getDataManager().getDeviceByImei(uniqueId).getId();
- } catch(Exception error) {
- Log.warning("Unknown device - " + uniqueId);
+ if (!identify(uniqueId)) {
return null;
}
buf.skipBytes(uniqueId.length());
@@ -330,9 +326,9 @@ public class Mta6ProtocolDecoder extends BaseProtocolDecoder {
// Parse data
if (packetId == 0x31 || packetId == 0x32 || packetId == 0x36) {
if (simple) {
- return parseFormatA1(buf, deviceId);
+ return parseFormatA1(buf);
} else {
- return parseFormatA(buf, deviceId);
+ return parseFormatA(buf);
}
} //else if (0x34 0x38 0x4F 0x59)