From 5601a825b55eedd78e2a95263db7731ff67ed861 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sat, 30 Aug 2014 23:31:45 +1200 Subject: Support Visiontek VT84 (fix #799) --- .../traccar/protocol/VisiontekProtocolDecoder.java | 32 ++++++++++++++-------- 1 file changed, 21 insertions(+), 11 deletions(-) (limited to 'src/org/traccar') 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++)); -- cgit v1.2.3