aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-07-17 10:48:08 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2015-07-17 10:48:08 +1200
commit9b4b52b42d9b6537e2e526ebdb93fe036475c9cb (patch)
tree171fbc0d54ef9c963c13fc0a7a53865000d1ff5e
parent051ef2354038f1bf15d254c5d7630131a4ff37c2 (diff)
downloadtraccar-server-9b4b52b42d9b6537e2e526ebdb93fe036475c9cb.tar.gz
traccar-server-9b4b52b42d9b6537e2e526ebdb93fe036475c9cb.tar.bz2
traccar-server-9b4b52b42d9b6537e2e526ebdb93fe036475c9cb.zip
Correct GPS Marker decoder
-rw-r--r--src/org/traccar/protocol/GpsMarkerProtocolDecoder.java6
-rw-r--r--test/org/traccar/protocol/GpsMarkerProtocolDecoderTest.java7
2 files changed, 9 insertions, 4 deletions
diff --git a/src/org/traccar/protocol/GpsMarkerProtocolDecoder.java b/src/org/traccar/protocol/GpsMarkerProtocolDecoder.java
index 0c1bba84c..3c095853f 100644
--- a/src/org/traccar/protocol/GpsMarkerProtocolDecoder.java
+++ b/src/org/traccar/protocol/GpsMarkerProtocolDecoder.java
@@ -32,12 +32,10 @@ public class GpsMarkerProtocolDecoder extends BaseProtocolDecoder {
super(protocol);
}
- //  DDMMYYHHMM GGMMmmmm GGGMMmmmm
- //$GM 1 350123456789012 T1005111233 N55516789 E037561234 000 000 3 52 00298
- //$GM 203 863071014445404 T150715202258 N55481576 E037292753 000 000 4 05 30301
private static final Pattern pattern = Pattern.compile(
"\\$GM" +
- "\\d+" + // Type
+ "\\d" + // Type
+ "(?:\\p{XDigit}{2})?" + // Index
"(\\d{15})" + // IMEI
"T(\\d{2})(\\d{2})(\\d{2})" + // Date
"(\\d{2})(\\d{2})(\\d{2})?" + // Time
diff --git a/test/org/traccar/protocol/GpsMarkerProtocolDecoderTest.java b/test/org/traccar/protocol/GpsMarkerProtocolDecoderTest.java
index eb3ccfdb7..6e3ef6c8a 100644
--- a/test/org/traccar/protocol/GpsMarkerProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/GpsMarkerProtocolDecoderTest.java
@@ -12,6 +12,13 @@ public class GpsMarkerProtocolDecoderTest extends ProtocolDecoderTest {
GpsMarkerProtocolDecoder decoder = new GpsMarkerProtocolDecoder(new GpsMarkerProtocol());
+
+ assertNull(decoder.decode(null, null,
+ "$GM300350123456789012T100511123300G25000001772F185200000000000000005230298#"));
+
+ verify(decoder.decode(null, null,
+ "$GM200350123456789012T100511123300N55516789E03756123400000035230298#"));
+
verify(decoder.decode(null, null,
"$GM1350123456789012T1005111233N55516789E03756123400000035200298#"));