aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2014-06-25 20:45:52 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2014-06-25 20:45:52 +1200
commit19aa8eeb318dc9265e0b05d9cb1e4f1726a8e578 (patch)
treee70467349badca187e406f0ff36309eb8d2d8860 /src/org/traccar/protocol
parent2b976dcce16f92b1e429906848f0ae70fcb05b54 (diff)
downloadtrackermap-server-19aa8eeb318dc9265e0b05d9cb1e4f1726a8e578.tar.gz
trackermap-server-19aa8eeb318dc9265e0b05d9cb1e4f1726a8e578.tar.bz2
trackermap-server-19aa8eeb318dc9265e0b05d9cb1e4f1726a8e578.zip
Fix Laipac protocol decoder
Diffstat (limited to 'src/org/traccar/protocol')
-rw-r--r--src/org/traccar/protocol/LaipacProtocolDecoder.java16
1 files changed, 7 insertions, 9 deletions
diff --git a/src/org/traccar/protocol/LaipacProtocolDecoder.java b/src/org/traccar/protocol/LaipacProtocolDecoder.java
index ac0356991..a62a50e51 100644
--- a/src/org/traccar/protocol/LaipacProtocolDecoder.java
+++ b/src/org/traccar/protocol/LaipacProtocolDecoder.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.
@@ -34,11 +34,11 @@ public class LaipacProtocolDecoder extends BaseProtocolDecoder {
super(serverManager);
}
- static private Pattern pattern = Pattern.compile(
+ private static final Pattern pattern = Pattern.compile(
"\\$AVRMC," +
- "(\\d+)," + // Identifier
+ "([^,]+)," + // Identifier
"(\\d{2})(\\d{2})(\\d{2})," + // Time (HHMMSS)
- "([AVavr])," + // Validity
+ "([AVRavr])," + // Validity
"(\\d{2})(\\d{2}\\.\\d+)," + // Latitude (DDMM.MMMM)
"([NS])," +
"(\\d{3})(\\d{2}\\.\\d+)," + // Longitude (DDDMM.MMMM)
@@ -58,10 +58,8 @@ public class LaipacProtocolDecoder extends BaseProtocolDecoder {
String sentence = (String) msg;
// Heartbeat
- if (sentence.startsWith("$ECHK")) {
- if (channel != null) {
- channel.write(sentence + "\r\n");
- }
+ if (sentence.startsWith("$ECHK") && channel != null) {
+ channel.write(sentence + "\r\n");
return null;
}
@@ -93,7 +91,7 @@ public class LaipacProtocolDecoder extends BaseProtocolDecoder {
// Validity
String status = parser.group(index++);
- position.setValid(status.compareToIgnoreCase("A") == 0 ? true : false);
+ position.setValid(status.compareToIgnoreCase("A") == 0);
// Latitude
Double latitude = Double.valueOf(parser.group(index++));