aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2012-12-04 22:22:07 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2012-12-04 22:22:07 +1300
commit206600cd599e03eaa095619fc8a52b742d3413a1 (patch)
treeaf6c677f54c987c7c7ba5e1d75c1c30796e1b860 /src/org/traccar/protocol
parenta59ca5006a4d3547fbbb2931ad8a163f332ad65b (diff)
downloadtrackermap-server-206600cd599e03eaa095619fc8a52b742d3413a1.tar.gz
trackermap-server-206600cd599e03eaa095619fc8a52b742d3413a1.tar.bz2
trackermap-server-206600cd599e03eaa095619fc8a52b742d3413a1.zip
Added unknown device logging (fix #102)
Diffstat (limited to 'src/org/traccar/protocol')
-rw-r--r--src/org/traccar/protocol/Avl08ProtocolDecoder.java8
-rw-r--r--src/org/traccar/protocol/EnforaProtocolDecoder.java7
-rw-r--r--src/org/traccar/protocol/Ev603ProtocolDecoder.java8
-rw-r--r--src/org/traccar/protocol/Gl100ProtocolDecoder.java8
-rw-r--r--src/org/traccar/protocol/Gl200ProtocolDecoder.java8
-rw-r--r--src/org/traccar/protocol/Gps103ProtocolDecoder.java7
-rw-r--r--src/org/traccar/protocol/H02ProtocolDecoder.java8
-rw-r--r--src/org/traccar/protocol/Jt600ProtocolDecoder.java15
-rw-r--r--src/org/traccar/protocol/MaxonProtocolDecoder.java8
-rw-r--r--src/org/traccar/protocol/MeiligaoProtocolDecoder.java9
-rw-r--r--src/org/traccar/protocol/NavisProtocolDecoder.java3
-rw-r--r--src/org/traccar/protocol/ProgressProtocolDecoder.java7
-rw-r--r--src/org/traccar/protocol/Pt502ProtocolDecoder.java7
-rw-r--r--src/org/traccar/protocol/T55ProtocolDecoder.java7
-rw-r--r--src/org/traccar/protocol/Tk103ProtocolDecoder.java8
-rw-r--r--src/org/traccar/protocol/Tr20ProtocolDecoder.java8
-rw-r--r--src/org/traccar/protocol/V680ProtocolDecoder.java8
-rw-r--r--src/org/traccar/protocol/Xexun2ProtocolDecoder.java8
-rw-r--r--src/org/traccar/protocol/XexunProtocolDecoder.java8
19 files changed, 129 insertions, 21 deletions
diff --git a/src/org/traccar/protocol/Avl08ProtocolDecoder.java b/src/org/traccar/protocol/Avl08ProtocolDecoder.java
index c8766b642..a01771c35 100644
--- a/src/org/traccar/protocol/Avl08ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Avl08ProtocolDecoder.java
@@ -22,6 +22,7 @@ import java.util.regex.Pattern;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.traccar.GenericProtocolDecoder;
+import org.traccar.helper.Log;
import org.traccar.model.DataManager;
import org.traccar.model.Position;
@@ -88,7 +89,12 @@ public class Avl08ProtocolDecoder extends GenericProtocolDecoder {
// Get device by IMEI
String imei = parser.group(index++);
- position.setDeviceId(getDataManager().getDeviceByImei(imei).getId());
+ try {
+ position.setDeviceId(getDataManager().getDeviceByImei(imei).getId());
+ } catch(Exception error) {
+ Log.warning("Unknown device - " + imei);
+ return null;
+ }
// Alarm type
extendedInfo.append("<alarm>");
diff --git a/src/org/traccar/protocol/EnforaProtocolDecoder.java b/src/org/traccar/protocol/EnforaProtocolDecoder.java
index fc40dcbba..aa6dbaf13 100644
--- a/src/org/traccar/protocol/EnforaProtocolDecoder.java
+++ b/src/org/traccar/protocol/EnforaProtocolDecoder.java
@@ -107,7 +107,12 @@ public class EnforaProtocolDecoder extends GenericProtocolDecoder {
Integer index = 1;
// Get device by IMEI
- position.setDeviceId(getDataManager().getDeviceByImei(imei).getId());
+ try {
+ position.setDeviceId(getDataManager().getDeviceByImei(imei).getId());
+ } catch(Exception error) {
+ Log.warning("Unknown device - " + imei);
+ return null;
+ }
// Time
Calendar time = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
diff --git a/src/org/traccar/protocol/Ev603ProtocolDecoder.java b/src/org/traccar/protocol/Ev603ProtocolDecoder.java
index 83689f760..6d89120a8 100644
--- a/src/org/traccar/protocol/Ev603ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Ev603ProtocolDecoder.java
@@ -23,6 +23,7 @@ import java.util.regex.Pattern;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.traccar.GenericProtocolDecoder;
+import org.traccar.helper.Log;
import org.traccar.model.DataManager;
import org.traccar.model.Position;
@@ -68,7 +69,12 @@ public class Ev603ProtocolDecoder extends GenericProtocolDecoder{
// Detect device ID
if (sentence.startsWith("!1,")) {
String imei = sentence.substring(3);
- deviceId = getDataManager().getDeviceByImei(imei).getId();
+ try {
+ deviceId = getDataManager().getDeviceByImei(imei).getId();
+ } catch(Exception error) {
+ Log.warning("Unknown device - " + imei);
+ return null;
+ }
}
else if (sentence.startsWith("!A,")) {
diff --git a/src/org/traccar/protocol/Gl100ProtocolDecoder.java b/src/org/traccar/protocol/Gl100ProtocolDecoder.java
index 2e8b40a61..760e91f68 100644
--- a/src/org/traccar/protocol/Gl100ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gl100ProtocolDecoder.java
@@ -22,6 +22,7 @@ import java.util.regex.Pattern;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.traccar.GenericProtocolDecoder;
+import org.traccar.helper.Log;
import org.traccar.model.DataManager;
import org.traccar.model.Position;
@@ -88,7 +89,12 @@ public class Gl100ProtocolDecoder extends GenericProtocolDecoder {
// Get device by IMEI
String imei = parser.group(index++);
- position.setDeviceId(getDataManager().getDeviceByImei(imei).getId());
+ try {
+ position.setDeviceId(getDataManager().getDeviceByImei(imei).getId());
+ } catch(Exception error) {
+ Log.warning("Unknown device - " + imei);
+ return null;
+ }
// Validity
position.setValid(Integer.valueOf(parser.group(index++)) == 0 ? false : true);
diff --git a/src/org/traccar/protocol/Gl200ProtocolDecoder.java b/src/org/traccar/protocol/Gl200ProtocolDecoder.java
index c109ea4c7..019c839cd 100644
--- a/src/org/traccar/protocol/Gl200ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gl200ProtocolDecoder.java
@@ -22,6 +22,7 @@ import java.util.regex.Pattern;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.traccar.GenericProtocolDecoder;
+import org.traccar.helper.Log;
import org.traccar.model.DataManager;
import org.traccar.model.Position;
@@ -81,7 +82,12 @@ public class Gl200ProtocolDecoder extends GenericProtocolDecoder {
// Get device by IMEI
String imei = parser.group(index++);
- position.setDeviceId(getDataManager().getDeviceByImei(imei).getId());
+ try {
+ position.setDeviceId(getDataManager().getDeviceByImei(imei).getId());
+ } catch(Exception error) {
+ Log.warning("Unknown device - " + imei);
+ return null;
+ }
// Validity
position.setValid(Integer.valueOf(parser.group(index++)) == 0 ? false : true);
diff --git a/src/org/traccar/protocol/Gps103ProtocolDecoder.java b/src/org/traccar/protocol/Gps103ProtocolDecoder.java
index 1f19b56e4..9c9f56b2f 100644
--- a/src/org/traccar/protocol/Gps103ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gps103ProtocolDecoder.java
@@ -94,7 +94,12 @@ public class Gps103ProtocolDecoder extends GenericProtocolDecoder {
// Get device by IMEI
String imei = parser.group(index++);
- position.setDeviceId(getDataManager().getDeviceByImei(imei).getId());
+ try {
+ position.setDeviceId(getDataManager().getDeviceByImei(imei).getId());
+ } catch(Exception error) {
+ Log.warning("Unknown device - " + imei);
+ return null;
+ }
// Alarm message
extendedInfo.append("<alarm>");
diff --git a/src/org/traccar/protocol/H02ProtocolDecoder.java b/src/org/traccar/protocol/H02ProtocolDecoder.java
index bfdfc3758..2d4fb9a21 100644
--- a/src/org/traccar/protocol/H02ProtocolDecoder.java
+++ b/src/org/traccar/protocol/H02ProtocolDecoder.java
@@ -22,6 +22,7 @@ import java.util.regex.Pattern;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.traccar.GenericProtocolDecoder;
+import org.traccar.helper.Log;
import org.traccar.model.DataManager;
import org.traccar.model.Position;
@@ -77,7 +78,12 @@ public class H02ProtocolDecoder extends GenericProtocolDecoder {
// Get device by IMEI
String imei = parser.group(index++);
- position.setDeviceId(getDataManager().getDeviceByImei(imei).getId());
+ try {
+ position.setDeviceId(getDataManager().getDeviceByImei(imei).getId());
+ } catch(Exception error) {
+ Log.warning("Unknown device - " + imei);
+ return null;
+ }
// Time
Calendar time = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
diff --git a/src/org/traccar/protocol/Jt600ProtocolDecoder.java b/src/org/traccar/protocol/Jt600ProtocolDecoder.java
index 907eabb4b..d765c1b42 100644
--- a/src/org/traccar/protocol/Jt600ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Jt600ProtocolDecoder.java
@@ -25,6 +25,7 @@ import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.traccar.GenericProtocolDecoder;
import org.traccar.helper.ChannelBufferTools;
+import org.traccar.helper.Log;
import org.traccar.model.DataManager;
import org.traccar.model.Position;
@@ -51,7 +52,12 @@ public class Jt600ProtocolDecoder extends GenericProtocolDecoder {
// Get device by identifier
String id = Long.valueOf(ChannelBufferTools.readHexString(buf, 10)).toString();
- position.setDeviceId(getDataManager().getDeviceByImei(id).getId());
+ try {
+ position.setDeviceId(getDataManager().getDeviceByImei(id).getId());
+ } catch(Exception error) {
+ Log.warning("Unknown device - " + id);
+ return null;
+ }
buf.readByte(); // protocol version + data type
@@ -157,7 +163,12 @@ public class Jt600ProtocolDecoder extends GenericProtocolDecoder {
// Get device by identifier
String id = parser.group(index++);
- position.setDeviceId(getDataManager().getDeviceByImei(id).getId());
+ try {
+ position.setDeviceId(getDataManager().getDeviceByImei(id).getId());
+ } catch(Exception error) {
+ Log.warning("Unknown device - " + id);
+ return null;
+ }
// Longitude
Double lonlitude = Double.valueOf(parser.group(index++));
diff --git a/src/org/traccar/protocol/MaxonProtocolDecoder.java b/src/org/traccar/protocol/MaxonProtocolDecoder.java
index e05ef0e30..9bad2c965 100644
--- a/src/org/traccar/protocol/MaxonProtocolDecoder.java
+++ b/src/org/traccar/protocol/MaxonProtocolDecoder.java
@@ -22,6 +22,7 @@ import java.util.regex.Pattern;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.traccar.GenericProtocolDecoder;
+import org.traccar.helper.Log;
import org.traccar.model.DataManager;
import org.traccar.model.Position;
@@ -142,7 +143,12 @@ public class MaxonProtocolDecoder extends GenericProtocolDecoder {
if (parser.matches()) {
String imei = parser.group(1);
- position.setDeviceId(getDataManager().getDeviceByImei(imei).getId());
+ try {
+ position.setDeviceId(getDataManager().getDeviceByImei(imei).getId());
+ } catch(Exception error) {
+ Log.warning("Unknown device - " + imei);
+ return null;
+ }
return position;
}
}
diff --git a/src/org/traccar/protocol/MeiligaoProtocolDecoder.java b/src/org/traccar/protocol/MeiligaoProtocolDecoder.java
index b658c74e8..d5658b9a2 100644
--- a/src/org/traccar/protocol/MeiligaoProtocolDecoder.java
+++ b/src/org/traccar/protocol/MeiligaoProtocolDecoder.java
@@ -27,6 +27,7 @@ import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.traccar.GenericProtocolDecoder;
import org.traccar.helper.Crc;
+import org.traccar.helper.Log;
import org.traccar.model.DataManager;
import org.traccar.model.Position;
@@ -133,7 +134,13 @@ public class MeiligaoProtocolDecoder extends GenericProtocolDecoder {
// Get device by id
// TODO: change imei to unique id
- position.setDeviceId(getDataManager().getDeviceByImei(getId(buf)).getId());
+ String id = getId(buf);
+ try {
+ position.setDeviceId(getDataManager().getDeviceByImei(id).getId());
+ } catch(Exception error) {
+ Log.warning("Unknown device - " + id);
+ return null;
+ }
// Parse message
String sentence = buf.toString(offset, buf.readableBytes() - offset - 4, Charset.defaultCharset());
diff --git a/src/org/traccar/protocol/NavisProtocolDecoder.java b/src/org/traccar/protocol/NavisProtocolDecoder.java
index 1b3cd80f7..291d2b87c 100644
--- a/src/org/traccar/protocol/NavisProtocolDecoder.java
+++ b/src/org/traccar/protocol/NavisProtocolDecoder.java
@@ -277,12 +277,11 @@ public class NavisProtocolDecoder extends GenericProtocolDecoder {
private Object processHandshake(Channel channel, ChannelBuffer buf) {
buf.readByte(); // semicolon symbol
imei = buf.toString(Charset.defaultCharset());
-
try {
databaseDeviceId = getDataManager().getDeviceByImei(imei).getId();
sendReply(channel, ChannelBuffers.copiedBuffer(ByteOrder.LITTLE_ENDIAN, "*<S", charset));
} catch(Exception error) {
- Log.warning(error.toString());
+ Log.warning("Unknown device - " + imei);
}
return null;
}
diff --git a/src/org/traccar/protocol/ProgressProtocolDecoder.java b/src/org/traccar/protocol/ProgressProtocolDecoder.java
index 865e190e2..0494b339f 100644
--- a/src/org/traccar/protocol/ProgressProtocolDecoder.java
+++ b/src/org/traccar/protocol/ProgressProtocolDecoder.java
@@ -23,6 +23,7 @@ import org.jboss.netty.buffer.ChannelBuffers;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.traccar.GenericProtocolDecoder;
+import org.traccar.helper.Log;
import org.traccar.model.DataManager;
import org.traccar.model.Position;
@@ -74,7 +75,11 @@ public class ProgressProtocolDecoder extends GenericProtocolDecoder {
buf.skipBytes(length);
length = buf.readUnsignedShort();
String imei = buf.readBytes(length).toString(Charset.defaultCharset());
- deviceId = getDataManager().getDeviceByImei(imei).getId();
+ try {
+ deviceId = getDataManager().getDeviceByImei(imei).getId();
+ } catch(Exception error) {
+ Log.warning("Unknown device - " + imei);
+ }
}
// Position
diff --git a/src/org/traccar/protocol/Pt502ProtocolDecoder.java b/src/org/traccar/protocol/Pt502ProtocolDecoder.java
index b08b6c1bd..e5f2e9224 100644
--- a/src/org/traccar/protocol/Pt502ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Pt502ProtocolDecoder.java
@@ -80,7 +80,12 @@ public class Pt502ProtocolDecoder extends GenericProtocolDecoder {
// Get device by IMEI
String id = parser.group(index++);
- position.setDeviceId(getDataManager().getDeviceByImei(id).getId());
+ try {
+ position.setDeviceId(getDataManager().getDeviceByImei(id).getId());
+ } catch(Exception error) {
+ Log.warning("Unknown device - " + id);
+ return null;
+ }
// Time
Calendar time = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
diff --git a/src/org/traccar/protocol/T55ProtocolDecoder.java b/src/org/traccar/protocol/T55ProtocolDecoder.java
index 116343c5a..184f5e40b 100644
--- a/src/org/traccar/protocol/T55ProtocolDecoder.java
+++ b/src/org/traccar/protocol/T55ProtocolDecoder.java
@@ -22,6 +22,7 @@ import java.util.regex.Pattern;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.traccar.GenericProtocolDecoder;
+import org.traccar.helper.Log;
import org.traccar.model.DataManager;
import org.traccar.model.Position;
@@ -70,7 +71,11 @@ public class T55ProtocolDecoder extends GenericProtocolDecoder {
// Detect device ID
if (sentence.contains("$PGID")) {
String imei = sentence.substring(6, 6 + 15);
- deviceId = getDataManager().getDeviceByImei(imei).getId();
+ try {
+ deviceId = getDataManager().getDeviceByImei(imei).getId();
+ } catch(Exception error) {
+ Log.warning("Unknown device - " + imei);
+ }
}
// Parse message
diff --git a/src/org/traccar/protocol/Tk103ProtocolDecoder.java b/src/org/traccar/protocol/Tk103ProtocolDecoder.java
index 4c0fd0c03..7145cf893 100644
--- a/src/org/traccar/protocol/Tk103ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Tk103ProtocolDecoder.java
@@ -22,6 +22,7 @@ import java.util.regex.Pattern;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.traccar.GenericProtocolDecoder;
+import org.traccar.helper.Log;
import org.traccar.model.DataManager;
import org.traccar.model.Position;
@@ -83,7 +84,12 @@ public class Tk103ProtocolDecoder extends GenericProtocolDecoder {
// Get device by IMEI
String imei = parser.group(index++);
- position.setDeviceId(getDataManager().getDeviceByImei(imei).getId());
+ try {
+ position.setDeviceId(getDataManager().getDeviceByImei(imei).getId());
+ } catch(Exception error) {
+ Log.warning("Unknown device - " + imei);
+ return null;
+ }
// Date
Calendar time = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
diff --git a/src/org/traccar/protocol/Tr20ProtocolDecoder.java b/src/org/traccar/protocol/Tr20ProtocolDecoder.java
index 8f2f49218..0424b70b0 100644
--- a/src/org/traccar/protocol/Tr20ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Tr20ProtocolDecoder.java
@@ -22,6 +22,7 @@ import java.util.regex.Pattern;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.traccar.GenericProtocolDecoder;
+import org.traccar.helper.Log;
import org.traccar.model.DataManager;
import org.traccar.model.Position;
@@ -91,7 +92,12 @@ public class Tr20ProtocolDecoder extends GenericProtocolDecoder {
// Get device by id
String id = parser.group(index++);
- position.setDeviceId(getDataManager().getDeviceByImei(id).getId());
+ try {
+ position.setDeviceId(getDataManager().getDeviceByImei(id).getId());
+ } catch(Exception error) {
+ Log.warning("Unknown device - " + id);
+ return null;
+ }
// Validity
position.setValid(parser.group(index++).compareTo("A") == 0 ? true : false);
diff --git a/src/org/traccar/protocol/V680ProtocolDecoder.java b/src/org/traccar/protocol/V680ProtocolDecoder.java
index 10f17b184..57e5982dc 100644
--- a/src/org/traccar/protocol/V680ProtocolDecoder.java
+++ b/src/org/traccar/protocol/V680ProtocolDecoder.java
@@ -22,6 +22,7 @@ import java.util.regex.Pattern;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.traccar.GenericProtocolDecoder;
+import org.traccar.helper.Log;
import org.traccar.model.DataManager;
import org.traccar.model.Position;
@@ -80,7 +81,12 @@ public class V680ProtocolDecoder extends GenericProtocolDecoder {
// Get device by IMEI
String imei = parser.group(index++);
- position.setDeviceId(getDataManager().getDeviceByImei(imei).getId());
+ try {
+ position.setDeviceId(getDataManager().getDeviceByImei(imei).getId());
+ } catch(Exception error) {
+ Log.warning("Unknown device - " + imei);
+ return null;
+ }
// User
extendedInfo.append("<user>");
diff --git a/src/org/traccar/protocol/Xexun2ProtocolDecoder.java b/src/org/traccar/protocol/Xexun2ProtocolDecoder.java
index e7b29b728..6edb3733e 100644
--- a/src/org/traccar/protocol/Xexun2ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Xexun2ProtocolDecoder.java
@@ -22,6 +22,7 @@ import java.util.regex.Pattern;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.traccar.GenericProtocolDecoder;
+import org.traccar.helper.Log;
import org.traccar.model.DataManager;
import org.traccar.model.Position;
@@ -148,7 +149,12 @@ public class Xexun2ProtocolDecoder extends GenericProtocolDecoder {
// Get device by IMEI
String imei = parser.group(index++);
- position.setDeviceId(getDataManager().getDeviceByImei(imei).getId());
+ try {
+ position.setDeviceId(getDataManager().getDeviceByImei(imei).getId());
+ } catch(Exception error) {
+ Log.warning("Unknown device - " + imei);
+ return null;
+ }
// Satellites
extendedInfo.append("<satellites>");
diff --git a/src/org/traccar/protocol/XexunProtocolDecoder.java b/src/org/traccar/protocol/XexunProtocolDecoder.java
index cbff2dee3..2da1c68ac 100644
--- a/src/org/traccar/protocol/XexunProtocolDecoder.java
+++ b/src/org/traccar/protocol/XexunProtocolDecoder.java
@@ -23,6 +23,7 @@ import java.util.regex.Pattern;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.traccar.GenericProtocolDecoder;
+import org.traccar.helper.Log;
import org.traccar.model.DataManager;
import org.traccar.model.Position;
@@ -119,7 +120,12 @@ public class XexunProtocolDecoder extends GenericProtocolDecoder {
// Get device by IMEI
String imei = parser.group(index++);
- position.setDeviceId(getDataManager().getDeviceByImei(imei).getId());
+ try {
+ position.setDeviceId(getDataManager().getDeviceByImei(imei).getId());
+ } catch(Exception error) {
+ Log.warning("Unknown device - " + imei);
+ return null;
+ }
return position;
}