From 5b7722bd3fd6f7782eadd4b1afc518fdba28e8d3 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sat, 29 Jun 2019 21:19:50 -0700 Subject: Implement protocol responses --- src/main/java/org/traccar/protocol/H02ProtocolDecoder.java | 9 +++++++++ src/test/java/org/traccar/protocol/H02ProtocolDecoderTest.java | 3 +++ 2 files changed, 12 insertions(+) (limited to 'src') diff --git a/src/main/java/org/traccar/protocol/H02ProtocolDecoder.java b/src/main/java/org/traccar/protocol/H02ProtocolDecoder.java index 22bbe4441..137689a67 100644 --- a/src/main/java/org/traccar/protocol/H02ProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/H02ProtocolDecoder.java @@ -554,9 +554,18 @@ public class H02ProtocolDecoder extends BaseProtocolDecoder { String sentence = buf.toString(StandardCharsets.US_ASCII).trim(); int typeStart = sentence.indexOf(',', sentence.indexOf(',') + 1) + 1; int typeEnd = sentence.indexOf(',', typeStart); + if (typeEnd < 0) { + typeEnd = sentence.indexOf('#', typeStart); + } if (typeEnd > 0) { String type = sentence.substring(typeStart, typeEnd); switch (type) { + case "V0": + case "HTBT": + if (channel != null) { + channel.writeAndFlush(new NetworkMessage(sentence, remoteAddress)); + } + return null; case "NBR": return decodeLbs(sentence, channel, remoteAddress); case "LINK": diff --git a/src/test/java/org/traccar/protocol/H02ProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/H02ProtocolDecoderTest.java index c69dffce7..31e4f2dee 100644 --- a/src/test/java/org/traccar/protocol/H02ProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/H02ProtocolDecoderTest.java @@ -11,6 +11,9 @@ public class H02ProtocolDecoderTest extends ProtocolTest { H02ProtocolDecoder decoder = new H02ProtocolDecoder(null); + verifyNull(decoder, buffer( + "*HQ,135790246811220,HTBT#")); + verifyPosition(decoder, binary( "24702802061601234020031910125482600612695044000000ffffbbff000000000000000001760d04e2c9934d")); -- cgit v1.2.3