diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2017-04-04 02:27:57 +1200 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2017-04-04 02:27:57 +1200 |
commit | b95d93b27e6b1b22db89aac994131bac26362123 (patch) | |
tree | 988bf03e4ce814f21706da216128148abef1782b | |
parent | f594abe5da4399d3119175695e02e62b719c6ade (diff) | |
download | trackermap-server-b95d93b27e6b1b22db89aac994131bac26362123.tar.gz trackermap-server-b95d93b27e6b1b22db89aac994131bac26362123.tar.bz2 trackermap-server-b95d93b27e6b1b22db89aac994131bac26362123.zip |
Decode H02 additional data
-rw-r--r-- | src/org/traccar/protocol/H02ProtocolDecoder.java | 13 | ||||
-rw-r--r-- | test/org/traccar/protocol/H02ProtocolDecoderTest.java | 3 |
2 files changed, 14 insertions, 2 deletions
diff --git a/src/org/traccar/protocol/H02ProtocolDecoder.java b/src/org/traccar/protocol/H02ProtocolDecoder.java index b11a1e0e6..b78f21d8d 100644 --- a/src/org/traccar/protocol/H02ProtocolDecoder.java +++ b/src/org/traccar/protocol/H02ProtocolDecoder.java @@ -179,9 +179,12 @@ public class H02ProtocolDecoder extends BaseProtocolDecoder { .number("(x+),") // lac .number("(x+)#") // cid .or() - .expression(",.*") + .number(",(d+),") + .number("(d+),") + .number("(d+),") + .number("(d+)#") .or() - .text("#") + .any() .groupEnd() .compile(); @@ -262,6 +265,12 @@ public class H02ProtocolDecoder extends BaseProtocolDecoder { position.setNetwork(new Network(CellTower.fromLacCid(parser.nextInt(16), parser.nextInt(16)))); } + if (parser.hasNext(4)) { + for (int i = 1; i <= 4; i++) { + position.set(Position.PREFIX_IO + i, parser.nextInt()); + } + } + return position; } diff --git a/test/org/traccar/protocol/H02ProtocolDecoderTest.java b/test/org/traccar/protocol/H02ProtocolDecoderTest.java index ad3a2e589..7498bbcd7 100644 --- a/test/org/traccar/protocol/H02ProtocolDecoderTest.java +++ b/test/org/traccar/protocol/H02ProtocolDecoderTest.java @@ -10,6 +10,9 @@ public class H02ProtocolDecoderTest extends ProtocolTest { H02ProtocolDecoder decoder = new H02ProtocolDecoder(new H02Protocol()); + verifyPosition(decoder, buffer( + "*HQ,8161289587,V1,181933,A,5444.3994,N,02516.3844,E,000.05,000,090317,FFFFBBFF,246,03,00002,41565#")); + verifyPosition(decoder, binary( "2421305109380127171003170520046500100286297e003085ffffdfffff03440069129344006400001151415a20")); |