aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2017-04-09 21:47:16 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2017-04-09 21:47:16 +1200
commit1f4dc7e4413aae6f8e927d7d5a9c40a8bd0ae082 (patch)
treea3f7a1445d30d3e08a61b3b0075d2d98a9dd640d
parente104f5636d53311dfd91cafaa2cdea65260ae7dc (diff)
downloadtraccar-server-1f4dc7e4413aae6f8e927d7d5a9c40a8bd0ae082.tar.gz
traccar-server-1f4dc7e4413aae6f8e927d7d5a9c40a8bd0ae082.tar.bz2
traccar-server-1f4dc7e4413aae6f8e927d7d5a9c40a8bd0ae082.zip
Import cGuard protocol decoder (fix #3080)
-rw-r--r--src/org/traccar/protocol/CguardProtocolDecoder.java14
-rw-r--r--test/org/traccar/protocol/CguardProtocolDecoderTest.java6
2 files changed, 13 insertions, 7 deletions
diff --git a/src/org/traccar/protocol/CguardProtocolDecoder.java b/src/org/traccar/protocol/CguardProtocolDecoder.java
index 19144017a..f1d593944 100644
--- a/src/org/traccar/protocol/CguardProtocolDecoder.java
+++ b/src/org/traccar/protocol/CguardProtocolDecoder.java
@@ -35,13 +35,13 @@ public class CguardProtocolDecoder extends BaseProtocolDecoder {
private static final Pattern PATTERN_NV = new PatternBuilder()
.text("NV:")
.number("(dd)(dd)(dd) ") // date (yymmdd)
- .number("(dd)(dd)(dd):") // time (hhmmss)
- .number("(-?d+.d+):") // longitude
- .number("(-?d+.d+):") // latitude
- .number("(d+.?d*):") // speed
- .number("(?:NAN|(d+.?d*)):") // accuracy
- .number("(?:NAN|(d+.?d*)):") // course
- .number("(?:NAN|(d+.?d*))") // altitude
+ .number("(dd)(dd)(dd)") // time (hhmmss)
+ .number(":(-?d+.d+)") // longitude
+ .number(":(-?d+.d+)") // latitude
+ .number(":(d+.?d*)") // speed
+ .number(":(?:NAN|(d+.?d*))") // accuracy
+ .number(":(?:NAN|(d+.?d*))") // course
+ .number(":(?:NAN|(d+.?d*))").optional() // altitude
.compile();
private static final Pattern PATTERN_BC = new PatternBuilder()
diff --git a/test/org/traccar/protocol/CguardProtocolDecoderTest.java b/test/org/traccar/protocol/CguardProtocolDecoderTest.java
index ff9ecb9be..3a3aa2332 100644
--- a/test/org/traccar/protocol/CguardProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/CguardProtocolDecoderTest.java
@@ -14,6 +14,12 @@ public class CguardProtocolDecoderTest extends ProtocolTest {
"IDRO:354868050655283"));
verifyPosition(decoder, text(
+ "NV:170409 031456:56.808553:60.595476:0:NAN:0"));
+
+ verifyAttributes(decoder, text(
+ "BC:170409 031456:CSQ1:64:NSQ1:17:PWR1:0"));
+
+ verifyPosition(decoder, text(
"NV:161007 122043:55.812730:37.733689:3.62:NAN:244.05:143.4"));
verifyPosition(decoder, text(