aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2013-07-24 19:00:01 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2013-07-24 19:00:01 +1200
commita9fbc36ba173573aabd581e7a14f32ce0af69cb6 (patch)
tree7e8ed79632571b99861f46b41a0311b5cf8f2e91 /src/org/traccar
parentbf7be45a144d26ecc213b398b0625e06b5c00bc6 (diff)
downloadtraccar-server-a9fbc36ba173573aabd581e7a14f32ce0af69cb6.tar.gz
traccar-server-a9fbc36ba173573aabd581e7a14f32ce0af69cb6.tar.bz2
traccar-server-a9fbc36ba173573aabd581e7a14f32ce0af69cb6.zip
Improve Xexun2 decoder
Diffstat (limited to 'src/org/traccar')
-rw-r--r--src/org/traccar/protocol/Xexun2ProtocolDecoder.java19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/org/traccar/protocol/Xexun2ProtocolDecoder.java b/src/org/traccar/protocol/Xexun2ProtocolDecoder.java
index 900315d20..098647499 100644
--- a/src/org/traccar/protocol/Xexun2ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Xexun2ProtocolDecoder.java
@@ -38,22 +38,22 @@ public class Xexun2ProtocolDecoder extends BaseProtocolDecoder {
"(\\d+)," + // Serial
"(\\+?\\d+)," + // Number
"GPRMC," +
- "(\\d{2})(\\d{2})(\\d{2})\\.(\\d{3})," + // Time (HHMMSS.SSS)
+ "(\\d{2})(\\d{2})(\\d{2})\\.(\\d+)," + // Time (HHMMSS.SSS)
"([AV])," + // Validity
- "(\\d{2})(\\d{2}\\.\\d{4})," + // Latitude (DDMM.MMMM)
+ "(\\d{2})(\\d{2}\\.\\d+)," + // Latitude (DDMM.MMMM)
"([NS])," +
- "(\\d{3})(\\d{2}\\.\\d{4})," + // Longitude (DDDMM.MMMM)
+ "(\\d{3})(\\d{2}\\.\\d+)," + // Longitude (DDDMM.MMMM)
"([EW])," +
"(\\d+\\.\\d+)," + // Speed
"(\\d+\\.\\d+)?," + // Course
"(\\d{2})(\\d{2})(\\d{2})," + // Date (DDMMYY)
- ",,.\\*..," + // Checksum
+ "[^,]*,[^,]*,.\\*..," + // Checksum
"([FL])," + // Signal
- "(.*)," + // Alarm
+ "(?:([^,]*),)?" + // Alarm
".*imei:" +
"(\\d+)," + // IMEI
"(\\d+)," + // Satellites
- "(-?\\d+\\.\\d+)," + // Altitude
+ "(-?\\d+\\.\\d+)?," + // Altitude
"[FL]:(\\d+\\.\\d+)V," + // Power
".*" +
"[\r\n]*");
@@ -141,7 +141,12 @@ public class Xexun2ProtocolDecoder extends BaseProtocolDecoder {
extendedInfo.set("satellites", parser.group(index++).replaceFirst ("^0*(?![\\.$])", ""));
// 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);
+ }
// Power
position.setPower(Double.valueOf(parser.group(index++)));