diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2019-08-06 08:52:39 -0700 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2019-08-06 08:52:39 -0700 |
commit | 0a2f7b1f70329362d76c5c9d446bfdcd314cf7ec (patch) | |
tree | 7321258ad62deec456ddff1831504929bef812b6 | |
parent | 12341a04c3c3bd0fe9b0d5d832ee6702bdbd7e18 (diff) | |
download | trackermap-server-0a2f7b1f70329362d76c5c9d446bfdcd314cf7ec.tar.gz trackermap-server-0a2f7b1f70329362d76c5c9d446bfdcd314cf7ec.tar.bz2 trackermap-server-0a2f7b1f70329362d76c5c9d446bfdcd314cf7ec.zip |
Support VT33S protocol
-rw-r--r-- | src/main/java/org/traccar/protocol/TrvProtocolDecoder.java | 12 | ||||
-rw-r--r-- | src/test/java/org/traccar/protocol/TrvProtocolDecoderTest.java | 3 |
2 files changed, 11 insertions, 4 deletions
diff --git a/src/main/java/org/traccar/protocol/TrvProtocolDecoder.java b/src/main/java/org/traccar/protocol/TrvProtocolDecoder.java index b63385187..eca9aca66 100644 --- a/src/main/java/org/traccar/protocol/TrvProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/TrvProtocolDecoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2015 - 2019 Anton Tananaev (anton@traccar.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,7 +42,8 @@ public class TrvProtocolDecoder extends BaseProtocolDecoder { private static final Pattern PATTERN = new PatternBuilder() .expression("[A-Z]{2,3}") - .number("APdd") + .expression("[A-Z]P") + .number("dd") .number("(dd)(dd)(dd)") // date (yymmdd) .expression("([AV])") // validity .number("(dd)(dd.d+)") // latitude @@ -57,7 +58,8 @@ public class TrvProtocolDecoder extends BaseProtocolDecoder { .number("(ddd)") // battery .number("(d)") // acc .number("(dd)") // arm status - .number("(dd),") // working mode + .number("(dd)") // working mode + .number("(?:[0-2]{3})?,") .number("(d+),") // mcc .number("(d+),") // mnc .number("(d+),") // lac @@ -181,7 +183,9 @@ public class TrvProtocolDecoder extends BaseProtocolDecoder { return position; - } else if (type.equals("AP01") || type.equals("AP10")) { + } else if (type.equals("AP01") || type.equals("AP10") || type.equals("YP03")) { + org.traccar.helper.PatternUtil.MatchResult matchResult = + org.traccar.helper.PatternUtil.checkPattern(PATTERN.pattern(), (String) msg); Parser parser = new Parser(PATTERN, sentence); if (!parser.matches()) { diff --git a/src/test/java/org/traccar/protocol/TrvProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/TrvProtocolDecoderTest.java index 2fdb86218..aceb9e122 100644 --- a/src/test/java/org/traccar/protocol/TrvProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/TrvProtocolDecoderTest.java @@ -13,6 +13,9 @@ public class TrvProtocolDecoderTest extends ProtocolTest { verifyNull(decoder, text( "TRVAP00352121088015548")); + verifyPosition(decoder, text( + "TRVYP03190805A1828.9242N07353.9423E000.0150716029.0010000810020201112,404,27,184,10229")); + verifyNotNull(decoder, text( "IWAP02,zh_cn,0,6,260,1,11002|39252|9,11002|35112|23,11002|11043|24,11002|39253|24,11002|13751|24,11018|8102|26,3,a|c0-4a-00-b6-9c-f5|64&a|c0-4a-00-b6-9c-f5|64&a|18-a6-f7-92-35-da|84")); |