aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol/MegastekProtocolDecoder.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2014-01-25 01:06:16 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2014-01-25 01:06:16 +1300
commitb5ba2f7b0a01176a3ecd6cbc4b46c62f00d353fb (patch)
tree893ddbb9a212ec2005f12305b1e952c05049f29f /src/org/traccar/protocol/MegastekProtocolDecoder.java
parent04bbc2fe82b5e80f52335604f1d97f955fdedb72 (diff)
downloadtrackermap-server-b5ba2f7b0a01176a3ecd6cbc4b46c62f00d353fb.tar.gz
trackermap-server-b5ba2f7b0a01176a3ecd6cbc4b46c62f00d353fb.tar.bz2
trackermap-server-b5ba2f7b0a01176a3ecd6cbc4b46c62f00d353fb.zip
Improve Megastek decoder (fix #525)
Diffstat (limited to 'src/org/traccar/protocol/MegastekProtocolDecoder.java')
-rw-r--r--src/org/traccar/protocol/MegastekProtocolDecoder.java17
1 files changed, 7 insertions, 10 deletions
diff --git a/src/org/traccar/protocol/MegastekProtocolDecoder.java b/src/org/traccar/protocol/MegastekProtocolDecoder.java
index 8032a0b9d..9d77c4b8d 100644
--- a/src/org/traccar/protocol/MegastekProtocolDecoder.java
+++ b/src/org/traccar/protocol/MegastekProtocolDecoder.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.
@@ -33,7 +33,7 @@ public class MegastekProtocolDecoder 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
@@ -46,11 +46,11 @@ public class MegastekProtocolDecoder extends BaseProtocolDecoder {
"(\\d{2})(\\d{2})(\\d{2})" + // Date (DDMMYY)
"[^\\*]+\\*[0-9a-fA-F]{2}"); // Checksum
- static private Pattern patternSimple = Pattern.compile(
+ private static final Pattern patternSimple = Pattern.compile(
"[FL]," + // Flag
"([^,]*)," + // Alarm
"imei:(\\d+)," + // IMEI
- "(\\d+)?," + // Satellites
+ "(\\d+/?\\d*)?," + // Satellites
"(\\d+\\.\\d+)," + // Altitude
"Battery=(\\d+)%,," + // Battery
"(\\d)?," + // Charger
@@ -59,7 +59,7 @@ public class MegastekProtocolDecoder extends BaseProtocolDecoder {
"(\\p{XDigit}{4},\\p{XDigit}{4});" + // Location code
".+"); // Checksum
- static private Pattern patternAlternative = Pattern.compile(
+ private static final Pattern patternAlternative = Pattern.compile(
"(\\d+)," + // MCC
"(\\d+)," + // MNC
"(\\p{XDigit}{4},\\p{XDigit}{4})," + // Location code
@@ -92,7 +92,7 @@ public class MegastekProtocolDecoder 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++));
@@ -209,10 +209,7 @@ public class MegastekProtocolDecoder extends BaseProtocolDecoder {
}
// Satellites
- String satellites = parser.group(index++);
- if (satellites != null) {
- extendedInfo.set("satellites", satellites);
- }
+ extendedInfo.set("satellites", parser.group(index++));
// Altitude
position.setAltitude(Double.valueOf(parser.group(index++)));