aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2014-08-30 23:31:45 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2014-08-30 23:31:45 +1200
commit5601a825b55eedd78e2a95263db7731ff67ed861 (patch)
tree575b1ec843ec9b2f66a301aa2b9e4cfbea280cba /src
parent419b1f981fe8b108e053258719da2cc33de76dfa (diff)
downloadtrackermap-server-5601a825b55eedd78e2a95263db7731ff67ed861.tar.gz
trackermap-server-5601a825b55eedd78e2a95263db7731ff67ed861.tar.bz2
trackermap-server-5601a825b55eedd78e2a95263db7731ff67ed861.zip
Support Visiontek VT84 (fix #799)
Diffstat (limited to 'src')
-rw-r--r--src/org/traccar/protocol/VisiontekProtocolDecoder.java32
1 files changed, 21 insertions, 11 deletions
diff --git a/src/org/traccar/protocol/VisiontekProtocolDecoder.java b/src/org/traccar/protocol/VisiontekProtocolDecoder.java
index 8242a2a9f..4ca97be67 100644
--- a/src/org/traccar/protocol/VisiontekProtocolDecoder.java
+++ b/src/org/traccar/protocol/VisiontekProtocolDecoder.java
@@ -36,24 +36,24 @@ public class VisiontekProtocolDecoder extends BaseProtocolDecoder {
private static final Pattern pattern = Pattern.compile(
"\\$1," +
"([^,]+)," + // Identifier
- "(\\d+)," + // IMEI
+ "(?:(\\d+),)?" + // IMEI
"(\\d{2}),(\\d{2}),(\\d{2})," + // Date
"(\\d{2}),(\\d{2}),(\\d{2})," + // Time
"(\\d{2})(\\d{6})([NS])," + // Latitude
"(\\d{3})(\\d{6})([EW])," + // Longitude
"(\\d+\\.\\d+)," + // Speed
"(\\d+)," + // Course
- "(\\d+)," + // Altitude
- "(\\d+)," + // Satellites
+ "(?:(\\d+)," + // Altitude
+ "(\\d+),)?" + // Satellites
"(\\d+)," + // Milage
- "(\\d)," + // Ignition
+ "(?:(\\d)," + // Ignition
"(\\d)," + // Input 1
"(\\d)," + // Input 2
"(\\d)," + // Immobilizer
"(\\d)," + // External Battery Status
- "(\\d+)," + // GSM
- "([AV])," + // Validity
- "(\\d+)" + // RFID
+ "(\\d+),)?" + // GSM
+ "([AV]),?" + // Validity
+ "(\\d+)?" + // RFID
".*");
@Override
@@ -81,9 +81,14 @@ public class VisiontekProtocolDecoder extends BaseProtocolDecoder {
try {
position.setDeviceId(getDataManager().getDeviceByImei(id).getId());
} catch(Exception error) {
- try {
- position.setDeviceId(getDataManager().getDeviceByImei(imei).getId());
- } catch(Exception error2) {
+ if (imei != null) {
+ try {
+ position.setDeviceId(getDataManager().getDeviceByImei(imei).getId());
+ } catch(Exception error2) {
+ Log.warning("Unknown device - " + id);
+ return null;
+ }
+ } else {
Log.warning("Unknown device - " + id);
return null;
}
@@ -119,7 +124,12 @@ public class VisiontekProtocolDecoder extends BaseProtocolDecoder {
position.setCourse(Double.valueOf(parser.group(index++)));
// Altitude
- position.setAltitude(Double.valueOf(parser.group(index++)));
+ String altitude = parser.group(index++);
+ if (altitude != null) {
+ position.setAltitude(Double.valueOf(altitude));
+ } else {
+ position.setAltitude(0.0);
+ }
// Additional data
extendedInfo.set("satellites", parser.group(index++));