aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2014-03-23 20:34:43 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2014-03-23 20:34:43 +1300
commit35701e0a14782d67320a7c667d7afd980bbc5dd0 (patch)
tree94827428211420c812c0e956396d92e3c3af9d4a
parent43943e450f58501f61faecd466f88aa5d3eb4482 (diff)
downloadtrackermap-server-35701e0a14782d67320a7c667d7afd980bbc5dd0.tar.gz
trackermap-server-35701e0a14782d67320a7c667d7afd980bbc5dd0.tar.bz2
trackermap-server-35701e0a14782d67320a7c667d7afd980bbc5dd0.zip
Save GPS103 extra data
-rw-r--r--src/org/traccar/protocol/Gps103ProtocolDecoder.java20
-rw-r--r--test/org/traccar/protocol/Gps103ProtocolDecoderTest.java6
2 files changed, 21 insertions, 5 deletions
diff --git a/src/org/traccar/protocol/Gps103ProtocolDecoder.java b/src/org/traccar/protocol/Gps103ProtocolDecoder.java
index 24a1c525d..815ee3192 100644
--- a/src/org/traccar/protocol/Gps103ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gps103ProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012 - 2013 Anton Tananaev (anton.tananaev@gmail.com)
+ * Copyright 2012 - 2014 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.
@@ -33,7 +33,7 @@ public class Gps103ProtocolDecoder extends BaseProtocolDecoder {
super(serverManager);
}
- static private Pattern pattern = Pattern.compile(
+ private static final Pattern pattern = Pattern.compile(
"imei:" +
"(\\d+)," + // IMEI
"([^,]+)," + // Alarm
@@ -48,8 +48,12 @@ public class Gps103ProtocolDecoder extends BaseProtocolDecoder {
"(\\d+)(\\d{2}\\.\\d+)," + // Longitude (DDDMM.MMMM)
"([EW])?," +
"(\\d+\\.?\\d*)," + // Speed
- "(\\d+\\.?\\d*)?(?:," + // Course
- "(\\d+\\.?\\d*)?)?" + // Altitude
+ "(\\d+\\.?\\d*)?,?" + // Course
+ "(\\d+\\.?\\d*)?,?" + // Altitude
+ "([^,]+)?,?" +
+ "([^,]+)?,?" +
+ "([^,]+)?,?" +
+ "([^,]+)?,?" +
".*");
@Override
@@ -129,7 +133,7 @@ public class Gps103ProtocolDecoder 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);
// Latitude
Double latitude = Double.valueOf(parser.group(index++));
@@ -165,6 +169,12 @@ public class Gps103ProtocolDecoder extends BaseProtocolDecoder {
position.setAltitude(0.0);
}
+ // Additional data
+ extendedInfo.set("io1", parser.group(index++));
+ extendedInfo.set("io2", parser.group(index++));
+ extendedInfo.set("io3", parser.group(index++));
+ extendedInfo.set("io4", parser.group(index++));
+
// Extended info
position.setExtendedInfo(extendedInfo.toString());
diff --git a/test/org/traccar/protocol/Gps103ProtocolDecoderTest.java b/test/org/traccar/protocol/Gps103ProtocolDecoderTest.java
index 5bcfa65e8..b5365f8d7 100644
--- a/test/org/traccar/protocol/Gps103ProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/Gps103ProtocolDecoderTest.java
@@ -98,6 +98,12 @@ public class Gps103ProtocolDecoderTest {
verify(decoder.decode(null, null,
"imei:359710041641581,acc alarm,1402231159,,F,065907.000,A,2456.2591,N,06708.8335,E,7.53,76.10,,1,0,0.03%,,"));
+
+ verify(decoder.decode(null, null,
+ "imei:359710041641581,acc alarm,1402231159,,F,065907.000,A,2456.2591,N,06708.8335,E,7.53,76.10,,1,0,0.03%,,"));
+
+ verify(decoder.decode(null, null,
+ "imei:313009071131684,tracker,1403211928,,F,112817.000,A,0610.1133,N,00116.5840,E,0.00,,,0,0,0.0,0.0,"));
}