aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2014-01-26 11:21:43 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2014-01-26 11:21:43 +1300
commit4889e57de4b9bf88b56e1b75b7940bfd25ccae07 (patch)
tree5c5b217bd4552707168a16d25756414977ad4025
parentab2ea4acda1547c813ce6a2bfe6e5c63181e22c6 (diff)
downloadtrackermap-server-4889e57de4b9bf88b56e1b75b7940bfd25ccae07.tar.gz
trackermap-server-4889e57de4b9bf88b56e1b75b7940bfd25ccae07.tar.bz2
trackermap-server-4889e57de4b9bf88b56e1b75b7940bfd25ccae07.zip
Fix bug in GlobalSat decoder
-rw-r--r--src/org/traccar/protocol/GlobalSatProtocolDecoder.java10
-rw-r--r--test/org/traccar/protocol/GlobalSatProtocolDecoderTest.java4
2 files changed, 9 insertions, 5 deletions
diff --git a/src/org/traccar/protocol/GlobalSatProtocolDecoder.java b/src/org/traccar/protocol/GlobalSatProtocolDecoder.java
index 2e0cb4ca6..2c808813a 100644
--- a/src/org/traccar/protocol/GlobalSatProtocolDecoder.java
+++ b/src/org/traccar/protocol/GlobalSatProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2013 Anton Tananaev (anton.tananaev@gmail.com)
+ * Copyright 2013 - 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.
@@ -41,10 +41,10 @@ public class GlobalSatProtocolDecoder extends BaseProtocolDecoder {
format1 = "SARY*U!";
if (getServerManager() != null) {
Properties p = getServerManager().getProperties();
- if (p.contains("globalsat.format0")) {
+ if (p.containsKey("globalsat.format0")) {
format0 = p.getProperty("globalsat.format0");
}
- if (p.contains("globalsat.format1")) {
+ if (p.containsKey("globalsat.format1")) {
format1 = p.getProperty("globalsat.format1");
}
}
@@ -174,7 +174,7 @@ public class GlobalSatProtocolDecoder extends BaseProtocolDecoder {
return position;
}
- static private Pattern pattern = Pattern.compile(
+ private static final Pattern pattern = Pattern.compile(
"\\$" +
"(\\d+)," + // IMEI
"\\d+," + // mode
@@ -214,7 +214,7 @@ public class GlobalSatProtocolDecoder extends BaseProtocolDecoder {
}
// Validity
- position.setValid(parser.group(index++).compareTo("1") != 0 ? true : false);
+ position.setValid(parser.group(index++).compareTo("1") != 0);
// Time
Calendar time = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
diff --git a/test/org/traccar/protocol/GlobalSatProtocolDecoderTest.java b/test/org/traccar/protocol/GlobalSatProtocolDecoderTest.java
index f0020f8e2..2f986155a 100644
--- a/test/org/traccar/protocol/GlobalSatProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/GlobalSatProtocolDecoderTest.java
@@ -15,6 +15,10 @@ public class GlobalSatProtocolDecoderTest {
assertNull(decoder.decode(null, null, "GSh,131826789036289,3,M,ea04*3d"));
+ //SORPZAB27GHKLMN*U!
+ /*verify(decoder.decode(null, null,
+ "GSr,011412001878820,4,5,00,,1,250114,105316,E00610.2925,N4612.1824,0,0.02,0,1,0.0,64*51!"));*/
+
//TSPRXAB27GHKLMnaicz
verify(decoder.decode(null, null,
"GSr,1,135785412249986,01,I,EA02,3,230410,153318,E12129.2839,N2459.8570,0,1.17,212,8,1.0,12.3V*55"));