aboutsummaryrefslogtreecommitdiff
path: root/src/org
diff options
context:
space:
mode:
Diffstat (limited to 'src/org')
-rw-r--r--src/org/traccar/protocol/H02FrameDecoder.java6
-rw-r--r--src/org/traccar/protocol/H02ProtocolDecoder.java10
2 files changed, 11 insertions, 5 deletions
diff --git a/src/org/traccar/protocol/H02FrameDecoder.java b/src/org/traccar/protocol/H02FrameDecoder.java
index ef28e9986..82e3201f7 100644
--- a/src/org/traccar/protocol/H02FrameDecoder.java
+++ b/src/org/traccar/protocol/H02FrameDecoder.java
@@ -33,6 +33,12 @@ public class H02FrameDecoder extends FrameDecoder {
ChannelBuffer buf) throws Exception {
String marker = buf.toString(buf.readerIndex(), 1, Charset.defaultCharset());
+
+ while ((marker.equals(" ") || marker.equals("\r") || marker.equals("\n")) && buf.readableBytes() > 0) {
+ buf.skipBytes(1);
+ marker = buf.toString(buf.readerIndex(), 1, Charset.defaultCharset());
+ }
+
if (marker.equals("*")) {
// Return text message
diff --git a/src/org/traccar/protocol/H02ProtocolDecoder.java b/src/org/traccar/protocol/H02ProtocolDecoder.java
index 463c0af27..cc59eea9d 100644
--- a/src/org/traccar/protocol/H02ProtocolDecoder.java
+++ b/src/org/traccar/protocol/H02ProtocolDecoder.java
@@ -106,19 +106,19 @@ public class H02ProtocolDecoder extends BaseProtocolDecoder {
return position;
}
- static private Pattern pattern = Pattern.compile(
+ private static final Pattern pattern = Pattern.compile(
"\\*..," + // Manufacturer
"(\\d+)," + // IMEI
"V\\d," + // Version?
".*" +
"(\\d{2})(\\d{2})(\\d{2})," + // Time (HHMMSS)
"([AV])," + // Validity
- "(\\d+)(\\d{2}.\\d{4})," + // Latitude (DDMM.MMMM)
+ "(\\d+)(\\d{2}.\\d+)," + // Latitude (DDMM.MMMM)
"([NS])," +
- "(\\d+)(\\d{2}.\\d{4})," + // Longitude (DDMM.MMMM)
+ "(\\d+)(\\d{2}.\\d+)," + // Longitude (DDMM.MMMM)
"([EW])," +
- "(\\d+.\\d+)," + // Speed
- "(\\d+.\\d+)?," + // Course
+ "(\\d+.?\\d*)," + // Speed
+ "(\\d+.?\\d*)?," + // Course
"(\\d{2})(\\d{2})(\\d{2})," + // Date (DDMMYY)
"(\\p{XDigit}{8})" + // Status
".*");