aboutsummaryrefslogtreecommitdiff
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
parent419b1f981fe8b108e053258719da2cc33de76dfa (diff)
downloadtrackermap-server-5601a825b55eedd78e2a95263db7731ff67ed861.tar.gz
trackermap-server-5601a825b55eedd78e2a95263db7731ff67ed861.tar.bz2
trackermap-server-5601a825b55eedd78e2a95263db7731ff67ed861.zip
Support Visiontek VT84 (fix #799)
-rw-r--r--src/org/traccar/protocol/VisiontekProtocolDecoder.java32
-rw-r--r--test/org/traccar/protocol/VisiontekProtocolDecoderTest.java6
2 files changed, 27 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++));
diff --git a/test/org/traccar/protocol/VisiontekProtocolDecoderTest.java b/test/org/traccar/protocol/VisiontekProtocolDecoderTest.java
index 40d32b3f9..eba888810 100644
--- a/test/org/traccar/protocol/VisiontekProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/VisiontekProtocolDecoderTest.java
@@ -18,6 +18,12 @@ public class VisiontekProtocolDecoderTest {
assertNull(decoder.decode(null, null,
"$1,AP09BU9397,861785006462448,20,06,14,15,03,28,000000000,0000000000,000.0,000,0000,00,0,1,0,0,1,1,24,V,0000000000"));
+
+ assertNull(decoder.decode(null, null,
+ "$1,1234567890,02,06,11,17,07,45,00000000,000000000,00.0,0,0,V"));
+
+ verify(decoder.decode(null, null,
+ "$1,1234567890,02,06,11,17,07,45,17267690N,078279340E,060.0,113,0,A"));
}