aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/traccar')
-rw-r--r--src/org/traccar/helper/Parser.java2
-rw-r--r--src/org/traccar/protocol/UproProtocolDecoder.java8
2 files changed, 7 insertions, 3 deletions
diff --git a/src/org/traccar/helper/Parser.java b/src/org/traccar/helper/Parser.java
index dcea1c8f7..2f99d6e49 100644
--- a/src/org/traccar/helper/Parser.java
+++ b/src/org/traccar/helper/Parser.java
@@ -155,7 +155,7 @@ public class Parser {
}
if (hemisphere != null && (hemisphere.equals("S") || hemisphere.equals("W") || hemisphere.equals("-"))) {
- coordinate = -coordinate;
+ coordinate = -Math.abs(coordinate);
}
return coordinate;
diff --git a/src/org/traccar/protocol/UproProtocolDecoder.java b/src/org/traccar/protocol/UproProtocolDecoder.java
index b4000c37a..e6cb4e132 100644
--- a/src/org/traccar/protocol/UproProtocolDecoder.java
+++ b/src/org/traccar/protocol/UproProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012 - 2015 Anton Tananaev (anton.tananaev@gmail.com)
+ * Copyright 2012 - 2016 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.
@@ -21,6 +21,7 @@ import org.traccar.DeviceSession;
import org.traccar.helper.DateBuilder;
import org.traccar.helper.Parser;
import org.traccar.helper.PatternBuilder;
+import org.traccar.helper.PatternUtil;
import org.traccar.model.Position;
import java.net.SocketAddress;
@@ -34,8 +35,9 @@ public class UproProtocolDecoder extends BaseProtocolDecoder {
private static final Pattern PATTERN = new PatternBuilder()
.text("*AI20")
+ .expression("[01]") // ack
.number("(d+),") // device id
- .expression("A.+&A")
+ .expression(".+&A")
.number("(dd)(dd)(dd)") // time
.number("(dd)(dd)(dddd)") // latitude
.number("(ddd)(dd)(dddd)") // longitude
@@ -49,6 +51,8 @@ public class UproProtocolDecoder extends BaseProtocolDecoder {
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
+ PatternUtil.MatchResult r = PatternUtil.checkPattern(PATTERN.pattern(), (String) msg);
+
Parser parser = new Parser(PATTERN, (String) msg);
if (!parser.matches()) {
return null;