aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2013-11-09 19:01:19 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2013-11-09 19:01:19 +1300
commitcf0565caceee6856328e481dd23600ed2590c88a (patch)
tree9d2cc8cf8d3eb27b36412eb492ad702581891f1c /src/org/traccar
parentf9ecee5b732b0c82c8a95bebdb5e275ea479cccc (diff)
downloadtrackermap-server-cf0565caceee6856328e481dd23600ed2590c88a.tar.gz
trackermap-server-cf0565caceee6856328e481dd23600ed2590c88a.tar.bz2
trackermap-server-cf0565caceee6856328e481dd23600ed2590c88a.zip
Improve unit test verification
Diffstat (limited to 'src/org/traccar')
-rw-r--r--src/org/traccar/protocol/EnforaProtocolDecoder.java22
-rw-r--r--src/org/traccar/protocol/Ev603ProtocolDecoder.java13
-rw-r--r--src/org/traccar/protocol/Gl100ProtocolDecoder.java8
-rw-r--r--src/org/traccar/protocol/Gl200ProtocolDecoder.java3
-rw-r--r--src/org/traccar/protocol/GpsGateProtocolDecoder.java7
-rw-r--r--src/org/traccar/protocol/Jt600ProtocolDecoder.java7
-rw-r--r--src/org/traccar/protocol/MegastekProtocolDecoder.java3
-rw-r--r--src/org/traccar/protocol/MeitrackProtocolDecoder.java6
-rw-r--r--src/org/traccar/protocol/SkypatrolProtocolDecoder.java13
-rw-r--r--src/org/traccar/protocol/T55ProtocolDecoder.java14
-rw-r--r--src/org/traccar/protocol/TotemProtocolDecoder.java5
-rw-r--r--src/org/traccar/protocol/V680ProtocolDecoder.java14
-rw-r--r--src/org/traccar/protocol/XexunProtocolDecoder.java5
-rw-r--r--src/org/traccar/protocol/Xt7ProtocolDecoder.java7
14 files changed, 73 insertions, 54 deletions
diff --git a/src/org/traccar/protocol/EnforaProtocolDecoder.java b/src/org/traccar/protocol/EnforaProtocolDecoder.java
index 3d8d3221a..e5e5680d9 100644
--- a/src/org/traccar/protocol/EnforaProtocolDecoder.java
+++ b/src/org/traccar/protocol/EnforaProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012 Anton Tananaev (anton.tananaev@gmail.com)
+ * Copyright 2012 - 2013 Anton Tananaev (anton.tananaev@gmail.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,24 +27,16 @@ import org.traccar.BaseProtocolDecoder;
import org.traccar.ServerManager;
import org.traccar.helper.ChannelBufferTools;
import org.traccar.helper.Log;
+import org.traccar.model.ExtendedInfoFormatter;
import org.traccar.model.Position;
-/**
- * Enfora protocol decoder
- */
public class EnforaProtocolDecoder extends BaseProtocolDecoder {
- /**
- * Initialize
- */
public EnforaProtocolDecoder(ServerManager serverManager) {
super(serverManager);
}
- /**
- * Regular expressions pattern
- */
- static private Pattern pattern = Pattern.compile(
+ private static final Pattern pattern = Pattern.compile(
"GPRMC," +
"(\\d{2})(\\d{2})(\\d{2}).(\\d{2})," + // Time (HHMMSS.SS)
"([AV])," + // Validity
@@ -59,9 +51,7 @@ public class EnforaProtocolDecoder extends BaseProtocolDecoder {
public static final int IMEI_LENGTH = 15;
- /**
- * Decode message
- */
+ @Override
protected Object decode(
ChannelHandlerContext ctx, Channel channel, Object msg)
throws Exception {
@@ -104,6 +94,7 @@ public class EnforaProtocolDecoder extends BaseProtocolDecoder {
// Create new position
Position position = new Position();
+ ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("enfora");
Integer index = 1;
// Get device by IMEI
@@ -123,7 +114,7 @@ public class EnforaProtocolDecoder extends BaseProtocolDecoder {
time.set(Calendar.MILLISECOND, Integer.valueOf(parser.group(index++)) * 10);
// Validity
- position.setValid(parser.group(index++).compareTo("A") == 0 ? true : false);
+ position.setValid(parser.group(index++).compareTo("A") == 0);
// Latitude
Double latitude = Double.valueOf(parser.group(index++));
@@ -157,6 +148,7 @@ public class EnforaProtocolDecoder extends BaseProtocolDecoder {
time.set(Calendar.YEAR, 2000 + Integer.valueOf(parser.group(index++)));
position.setTime(time.getTime());
+ position.setExtendedInfo(extendedInfo.toString());
return position;
}
diff --git a/src/org/traccar/protocol/Ev603ProtocolDecoder.java b/src/org/traccar/protocol/Ev603ProtocolDecoder.java
index 322d7dd61..5be569d77 100644
--- a/src/org/traccar/protocol/Ev603ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Ev603ProtocolDecoder.java
@@ -1,6 +1,6 @@
/*
- * Copyright 2012 Anton Tananaev (anton.tananaev@gmail.com)
- * Luis Parada (luis.parada@gmail.com)
+ * Copyright 2012 - 2013 Anton Tananaev (anton.tananaev@gmail.com)
+ * Luis Parada (luis.parada@gmail.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -36,7 +36,7 @@ public class Ev603ProtocolDecoder extends BaseProtocolDecoder{
super(serverManager);
}
- static private Pattern pattern = Pattern.compile(
+ private static final Pattern pattern = Pattern.compile(
"!A," + // Type
"(\\d{2})\\/(\\d{2})\\/(\\d{2})," + // Date dd/mm/YY
"(\\d{2}):(\\d{2}):(\\d{2})," + // Time hh:mm:ss
@@ -67,7 +67,7 @@ public class Ev603ProtocolDecoder extends BaseProtocolDecoder{
else if (sentence.startsWith("!A,")) {
// Parse message
Matcher parser = pattern.matcher(sentence);
- if (!parser.matches()) {
+ if (deviceId == null || !parser.matches()) {
return null;
}
@@ -105,10 +105,11 @@ public class Ev603ProtocolDecoder extends BaseProtocolDecoder{
// Course
position.setCourse(Double.valueOf(parser.group(index++)));
+ if (position.getCourse() > 360) {
+ position.setCourse(0.0);
+ }
- // Extended info
position.setExtendedInfo(extendedInfo.toString());
-
return position;
}
diff --git a/src/org/traccar/protocol/Gl100ProtocolDecoder.java b/src/org/traccar/protocol/Gl100ProtocolDecoder.java
index d99953f24..88f9047bb 100644
--- a/src/org/traccar/protocol/Gl100ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gl100ProtocolDecoder.java
@@ -24,6 +24,7 @@ import org.jboss.netty.channel.ChannelHandlerContext;
import org.traccar.BaseProtocolDecoder;
import org.traccar.ServerManager;
import org.traccar.helper.Log;
+import org.traccar.model.ExtendedInfoFormatter;
import org.traccar.model.Position;
/**
@@ -41,7 +42,7 @@ public class Gl100ProtocolDecoder extends BaseProtocolDecoder {
/**
* Regular expressions pattern
*/
- static private Pattern pattern = Pattern.compile(
+ private static final Pattern pattern = Pattern.compile(
"\\+RESP:GT...," +
"(\\d{15})," + // IMEI
"(?:(?:\\d+," + // Number
@@ -62,6 +63,7 @@ public class Gl100ProtocolDecoder extends BaseProtocolDecoder {
/**
* Decode message
*/
+ @Override
protected Object decode(
ChannelHandlerContext ctx, Channel channel, Object msg)
throws Exception {
@@ -84,6 +86,7 @@ public class Gl100ProtocolDecoder extends BaseProtocolDecoder {
// Create new position
Position position = new Position();
+ ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("gl100");
Integer index = 1;
@@ -97,7 +100,7 @@ public class Gl100ProtocolDecoder extends BaseProtocolDecoder {
}
// Validity
- position.setValid(Integer.valueOf(parser.group(index++)) == 0 ? false : true);
+ position.setValid(Integer.valueOf(parser.group(index++)) == 0);
// Position info
position.setSpeed(Double.valueOf(parser.group(index++)));
@@ -119,6 +122,7 @@ public class Gl100ProtocolDecoder extends BaseProtocolDecoder {
time.set(Calendar.SECOND, Integer.valueOf(parser.group(index++)));
position.setTime(time.getTime());
+ position.setExtendedInfo(extendedInfo.toString());
return position;
}
diff --git a/src/org/traccar/protocol/Gl200ProtocolDecoder.java b/src/org/traccar/protocol/Gl200ProtocolDecoder.java
index ce845a6ec..8f3579d38 100644
--- a/src/org/traccar/protocol/Gl200ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gl200ProtocolDecoder.java
@@ -24,6 +24,7 @@ import org.jboss.netty.channel.ChannelHandlerContext;
import org.traccar.BaseProtocolDecoder;
import org.traccar.ServerManager;
import org.traccar.helper.Log;
+import org.traccar.model.ExtendedInfoFormatter;
import org.traccar.model.Position;
public class Gl200ProtocolDecoder extends BaseProtocolDecoder {
@@ -61,6 +62,7 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder {
// Create new position
Position position = new Position();
+ ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("gl200");
Integer index = 1;
@@ -96,6 +98,7 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder {
time.set(Calendar.SECOND, Integer.valueOf(parser.group(index++)));
position.setTime(time.getTime());
+ position.setExtendedInfo(extendedInfo.toString());
return position;
}
diff --git a/src/org/traccar/protocol/GpsGateProtocolDecoder.java b/src/org/traccar/protocol/GpsGateProtocolDecoder.java
index 99954850b..075ae8654 100644
--- a/src/org/traccar/protocol/GpsGateProtocolDecoder.java
+++ b/src/org/traccar/protocol/GpsGateProtocolDecoder.java
@@ -25,6 +25,7 @@ import org.traccar.BaseProtocolDecoder;
import org.traccar.ServerManager;
import org.traccar.helper.Crc;
import org.traccar.helper.Log;
+import org.traccar.model.ExtendedInfoFormatter;
import org.traccar.model.Position;
public class GpsGateProtocolDecoder extends BaseProtocolDecoder {
@@ -38,7 +39,7 @@ public class GpsGateProtocolDecoder extends BaseProtocolDecoder {
/**
* Regular expressions pattern
*/
- static private Pattern pattern = Pattern.compile(
+ private static final Pattern pattern = Pattern.compile(
"\\$GPRMC," +
"(\\d{2})(\\d{2})(\\d{2})\\.(\\d+)," + // Time (HHMMSS.SSS)
"([AV])," + // Validity
@@ -103,6 +104,7 @@ public class GpsGateProtocolDecoder extends BaseProtocolDecoder {
// Create new position
Position position = new Position();
+ ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("gpsgate");
position.setDeviceId(deviceId);
Integer index = 1;
@@ -116,7 +118,7 @@ public class GpsGateProtocolDecoder extends BaseProtocolDecoder {
index += 1; // Skip milliseconds
// Validity
- position.setValid(parser.group(index++).compareTo("A") == 0 ? true : false);
+ position.setValid(parser.group(index++).compareTo("A") == 0);
// Latitude
Double latitude = Double.valueOf(parser.group(index++));
@@ -155,6 +157,7 @@ public class GpsGateProtocolDecoder extends BaseProtocolDecoder {
// Altitude
position.setAltitude(0.0);
+ position.setExtendedInfo(extendedInfo.toString());
return position;
}
diff --git a/src/org/traccar/protocol/Jt600ProtocolDecoder.java b/src/org/traccar/protocol/Jt600ProtocolDecoder.java
index d12b09740..847e3859a 100644
--- a/src/org/traccar/protocol/Jt600ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Jt600ProtocolDecoder.java
@@ -127,7 +127,7 @@ public class Jt600ProtocolDecoder extends BaseProtocolDecoder {
return position;
}
- static private Pattern pattern = Pattern.compile(
+ private static final Pattern pattern = Pattern.compile(
"\\(" +
"([\\d]+)," + // Id
"W01," + // Type
@@ -184,7 +184,7 @@ public class Jt600ProtocolDecoder extends BaseProtocolDecoder {
position.setLatitude(latitude);
// Validity
- position.setValid(parser.group(index++).compareTo("A") == 0 ? true : false);
+ position.setValid(parser.group(index++).compareTo("A") == 0);
// Time
Calendar time = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
@@ -202,6 +202,9 @@ public class Jt600ProtocolDecoder extends BaseProtocolDecoder {
// Course
position.setCourse(Double.valueOf(parser.group(index++)));
+
+ // Altitude
+ position.setAltitude(0.0);
// Power
extendedInfo.set("power", Double.valueOf(parser.group(index++)));
diff --git a/src/org/traccar/protocol/MegastekProtocolDecoder.java b/src/org/traccar/protocol/MegastekProtocolDecoder.java
index dc55dbed1..8032a0b9d 100644
--- a/src/org/traccar/protocol/MegastekProtocolDecoder.java
+++ b/src/org/traccar/protocol/MegastekProtocolDecoder.java
@@ -239,6 +239,9 @@ public class MegastekProtocolDecoder extends BaseProtocolDecoder {
}
int index = 1;
+
+ // Altitude
+ position.setAltitude(0.0);
try {
position.setDeviceId(getDataManager().getDeviceByImei(id).getId());
diff --git a/src/org/traccar/protocol/MeitrackProtocolDecoder.java b/src/org/traccar/protocol/MeitrackProtocolDecoder.java
index af269f58b..3cf822000 100644
--- a/src/org/traccar/protocol/MeitrackProtocolDecoder.java
+++ b/src/org/traccar/protocol/MeitrackProtocolDecoder.java
@@ -33,7 +33,7 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder {
super(serverManager);
}
- static private Pattern pattern = Pattern.compile(
+ private static final Pattern pattern = Pattern.compile(
"\\$\\$." + // Flag
"\\d+," + // Length
"(\\d+)," + // IMEI
@@ -48,7 +48,7 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder {
"(\\d+)," + // GSM Signal
"(\\d+)," + // Speed
"(\\d+)," + // Course
- "(\\d+.?\\d*)," + // HDOP
+ "(\\d+\\.?\\d*)," + // HDOP
"(\\d+)," + // Altitude
"(\\d+)," + // Milage
".*"); // TODO: parse other stuff
@@ -99,7 +99,7 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder {
position.setTime(time.getTime());
// Validity
- position.setValid(parser.group(index++).compareTo("A") == 0 ? true : false);
+ position.setValid(parser.group(index++).compareTo("A") == 0);
// Satellites
extendedInfo.set("satellites", parser.group(index++));
diff --git a/src/org/traccar/protocol/SkypatrolProtocolDecoder.java b/src/org/traccar/protocol/SkypatrolProtocolDecoder.java
index 72fa45ac7..bf1295aea 100644
--- a/src/org/traccar/protocol/SkypatrolProtocolDecoder.java
+++ b/src/org/traccar/protocol/SkypatrolProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012 Anton Tananaev (anton.tananaev@gmail.com)
+ * Copyright 2012 - 2013 Anton Tananaev (anton.tananaev@gmail.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,14 +27,8 @@ import org.traccar.helper.Log;
import org.traccar.model.ExtendedInfoFormatter;
import org.traccar.model.Position;
-/**
- * T55 tracker protocol decoder
- */
public class SkypatrolProtocolDecoder extends BaseProtocolDecoder {
- /**
- * Initialize
- */
public SkypatrolProtocolDecoder(ServerManager serverManager) {
super(serverManager);
}
@@ -57,9 +51,6 @@ public class SkypatrolProtocolDecoder extends BaseProtocolDecoder {
return sign * degrees;
}
- /**
- * Decode message
- */
@Override
protected Object decode(
ChannelHandlerContext ctx, Channel channel, Object msg)
@@ -177,7 +168,7 @@ public class SkypatrolProtocolDecoder extends BaseProtocolDecoder {
// Altitude
if (checkBit(mask, 15)) {
- buf.skipBytes(3);
+ position.setAltitude((double) buf.readMedium());
}
// Satellites
diff --git a/src/org/traccar/protocol/T55ProtocolDecoder.java b/src/org/traccar/protocol/T55ProtocolDecoder.java
index 05a6ad4ae..246036313 100644
--- a/src/org/traccar/protocol/T55ProtocolDecoder.java
+++ b/src/org/traccar/protocol/T55ProtocolDecoder.java
@@ -35,7 +35,7 @@ public class T55ProtocolDecoder extends BaseProtocolDecoder {
super(serverManager);
}
- static private Pattern patternGPRMC = Pattern.compile(
+ private static final Pattern patternGPRMC = Pattern.compile(
"\\$GPRMC," +
"(\\d{2})(\\d{2})(\\d{2})\\.?\\d*," + // Time (HHMMSS.SSS)
"([AV])," + // Validity
@@ -48,7 +48,7 @@ public class T55ProtocolDecoder extends BaseProtocolDecoder {
"(\\d{2})(\\d{2})(\\d{2})" + // Date (DDMMYY)
".+");
- static private Pattern patternGPGGA = Pattern.compile(
+ private static final Pattern patternGPGGA = Pattern.compile(
"\\$GPGGA," +
"(\\d{2})(\\d{2})(\\d{2})\\.?\\d*," + // Time
"(\\d{2})(\\d{2}\\.\\d+)," + // Latitude
@@ -57,7 +57,7 @@ public class T55ProtocolDecoder extends BaseProtocolDecoder {
"([EW])," +
".+");
- static private Pattern patternGPRMA = Pattern.compile(
+ private static final Pattern patternGPRMA = Pattern.compile(
"\\$GPRMA," +
"([AV])," + // Validity
"(\\d{2})(\\d{2}\\.\\d+)," + // Latitude
@@ -124,7 +124,7 @@ public class T55ProtocolDecoder extends BaseProtocolDecoder {
time.set(Calendar.SECOND, Integer.valueOf(parser.group(index++)));
// Validity
- position.setValid(parser.group(index++).compareTo("A") == 0 ? true : false);
+ position.setValid(parser.group(index++).compareTo("A") == 0);
// Latitude
Double latitude = Double.valueOf(parser.group(index++));
@@ -205,6 +205,12 @@ public class T55ProtocolDecoder extends BaseProtocolDecoder {
longitude += Double.valueOf(parser.group(index++)) / 60;
if (parser.group(index++).compareTo("W") == 0) longitude = -longitude;
position.setLongitude(longitude);
+
+ // Speed
+ position.setSpeed(0.0);
+
+ // Course
+ position.setCourse(0.0);
// Altitude
position.setAltitude(0.0);
diff --git a/src/org/traccar/protocol/TotemProtocolDecoder.java b/src/org/traccar/protocol/TotemProtocolDecoder.java
index 1a0f22d80..bf88523f9 100644
--- a/src/org/traccar/protocol/TotemProtocolDecoder.java
+++ b/src/org/traccar/protocol/TotemProtocolDecoder.java
@@ -288,7 +288,7 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder {
extendedInfo.set("lac", parser.group(index++));
// Validity
- position.setValid(parser.group(index++).compareTo("A") == 0 ? true : false);
+ position.setValid(parser.group(index++).compareTo("A") == 0);
// Satellites
extendedInfo.set("satellites", parser.group(index++));
@@ -299,6 +299,9 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder {
// Speed
position.setSpeed(Double.valueOf(parser.group(index++)));
+ // Altitude
+ position.setAltitude(0.0);
+
// PDOP
extendedInfo.set("pdop", parser.group(index++));
diff --git a/src/org/traccar/protocol/V680ProtocolDecoder.java b/src/org/traccar/protocol/V680ProtocolDecoder.java
index 0f5d4b942..7541bb618 100644
--- a/src/org/traccar/protocol/V680ProtocolDecoder.java
+++ b/src/org/traccar/protocol/V680ProtocolDecoder.java
@@ -35,6 +35,7 @@ public class V680ProtocolDecoder extends BaseProtocolDecoder {
super(serverManager);
}
+ //#359094025419110#bigfriend#0#1234#AUTO#1##04632.8846,W,2327.2264,S,0.00,0.00#220913#234808##
private static final Pattern pattern = Pattern.compile(
"(?:#(\\d+)#" + // IMEI
"([^#]*)#)?" + // User
@@ -42,7 +43,7 @@ public class V680ProtocolDecoder extends BaseProtocolDecoder {
"([^#]+)#" + // Password
"[^#]+#" +
"(\\d+)#" + // Packet number
- "([^#]+)#" + // GSM base station
+ "([^#]+)?#?" + // GSM base station
"(?:[^#]+#)?" +
"(\\d+)(\\d{2}\\.\\d+)," + // Longitude (DDDMM.MMMM)
"([EW])," +
@@ -139,8 +140,13 @@ public class V680ProtocolDecoder extends BaseProtocolDecoder {
// Date
Calendar time = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
time.clear();
- time.set(Calendar.DAY_OF_MONTH, Integer.valueOf(parser.group(index++)));
- time.set(Calendar.MONTH, Integer.valueOf(parser.group(index++)) - 1);
+ int day = Integer.valueOf(parser.group(index++));
+ int month = Integer.valueOf(parser.group(index++));
+ if (day == 0 && month == 0) {
+ return null; // invalid date
+ }
+ time.set(Calendar.DAY_OF_MONTH, day);
+ time.set(Calendar.MONTH, month - 1);
time.set(Calendar.YEAR, 2000 + Integer.valueOf(parser.group(index++)));
// Time
@@ -149,9 +155,7 @@ public class V680ProtocolDecoder extends BaseProtocolDecoder {
time.set(Calendar.SECOND, Integer.valueOf(parser.group(index++)));
position.setTime(time.getTime());
- // Extended info
position.setExtendedInfo(extendedInfo.toString());
-
return position;
}
diff --git a/src/org/traccar/protocol/XexunProtocolDecoder.java b/src/org/traccar/protocol/XexunProtocolDecoder.java
index 03d746c34..bc92e4fb6 100644
--- a/src/org/traccar/protocol/XexunProtocolDecoder.java
+++ b/src/org/traccar/protocol/XexunProtocolDecoder.java
@@ -25,6 +25,7 @@ import org.jboss.netty.channel.ChannelHandlerContext;
import org.traccar.BaseProtocolDecoder;
import org.traccar.ServerManager;
import org.traccar.helper.Log;
+import org.traccar.model.ExtendedInfoFormatter;
import org.traccar.model.Position;
public class XexunProtocolDecoder extends BaseProtocolDecoder {
@@ -61,6 +62,7 @@ public class XexunProtocolDecoder extends BaseProtocolDecoder {
// Create new position
Position position = new Position();
+ ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("xexun");
Integer index = 1;
@@ -73,7 +75,7 @@ public class XexunProtocolDecoder extends BaseProtocolDecoder {
time.set(Calendar.MILLISECOND, Integer.valueOf(parser.group(index++)));
// Validity
- position.setValid(parser.group(index++).compareTo("A") == 0 ? true : false);
+ position.setValid(parser.group(index++).compareTo("A") == 0);
// Latitude
Double latitude = Double.valueOf(parser.group(index++));
@@ -116,6 +118,7 @@ public class XexunProtocolDecoder extends BaseProtocolDecoder {
return null;
}
+ position.setExtendedInfo(extendedInfo.toString());
return position;
}
diff --git a/src/org/traccar/protocol/Xt7ProtocolDecoder.java b/src/org/traccar/protocol/Xt7ProtocolDecoder.java
index cee9d18a7..42013cb9a 100644
--- a/src/org/traccar/protocol/Xt7ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Xt7ProtocolDecoder.java
@@ -35,7 +35,7 @@ public class Xt7ProtocolDecoder extends BaseProtocolDecoder {
super(serverManager);
}
- static private Pattern pattern = Pattern.compile(
+ private static final Pattern pattern = Pattern.compile(
"\\$GPRMC," +
"(\\d{2})(\\d{2})(\\d{2})\\.(\\d+)," + // Time (HHMMSS.SSS)
"([AV])," + // Validity
@@ -99,7 +99,7 @@ public class Xt7ProtocolDecoder extends BaseProtocolDecoder {
time.set(Calendar.MILLISECOND, Integer.valueOf(parser.group(index++)));
// Validity
- position.setValid(parser.group(index++).compareTo("A") == 0 ? true : false);
+ position.setValid(parser.group(index++).compareTo("A") == 0);
// Latitude
Double latitude = Double.valueOf(parser.group(index++));
@@ -123,6 +123,9 @@ public class Xt7ProtocolDecoder extends BaseProtocolDecoder {
} else {
position.setCourse(0.0);
}
+
+ // Altitude
+ position.setAltitude(0.0);
// Date
time.set(Calendar.DAY_OF_MONTH, Integer.valueOf(parser.group(index++)));