From d1c4cd526845aad56c5b0a3e20454638bbc7fecc Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Mon, 29 Jun 2015 10:48:34 +1200 Subject: Merge commands implmentation (fix #1271) --- src/org/traccar/protocol/H02ProtocolDecoder.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/org/traccar/protocol/H02ProtocolDecoder.java') diff --git a/src/org/traccar/protocol/H02ProtocolDecoder.java b/src/org/traccar/protocol/H02ProtocolDecoder.java index 30c0aaa60..95d80edb5 100644 --- a/src/org/traccar/protocol/H02ProtocolDecoder.java +++ b/src/org/traccar/protocol/H02ProtocolDecoder.java @@ -32,7 +32,7 @@ import org.traccar.model.Position; public class H02ProtocolDecoder extends BaseProtocolDecoder { - public H02ProtocolDecoder(String protocol) { + public H02ProtocolDecoder(H02Protocol protocol) { super(protocol); } @@ -55,16 +55,16 @@ public class H02ProtocolDecoder extends BaseProtocolDecoder { return result; } - private Position decodeBinary(ChannelBuffer buf) { + private Position decodeBinary(ChannelBuffer buf, Channel channel) { // Create new position Position position = new Position(); - position.setProtocol(getProtocol()); + position.setProtocol(getProtocolName()); buf.readByte(); // marker // Identification - if (!identify(ChannelBufferTools.readHexString(buf, 10))) { + if (!identify(ChannelBufferTools.readHexString(buf, 10), channel)) { return null; } position.setDeviceId(getDeviceId()); @@ -117,7 +117,7 @@ public class H02ProtocolDecoder extends BaseProtocolDecoder { "(\\p{XDigit}{8})" + // Status ".*"); - private Position decodeText(String sentence) { + private Position decodeText(String sentence, Channel channel) { // Parse message Matcher parser = pattern.matcher(sentence); @@ -127,12 +127,12 @@ public class H02ProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - position.setProtocol(getProtocol()); + position.setProtocol(getProtocolName()); Integer index = 1; // Get device by IMEI - if (!identify(parser.group(index++))) { + if (!identify(parser.group(index++), channel)) { return null; } position.setDeviceId(getDeviceId()); @@ -190,9 +190,9 @@ public class H02ProtocolDecoder extends BaseProtocolDecoder { // TODO X mode? if (marker.equals("*")) { - return decodeText(buf.toString(Charset.defaultCharset())); + return decodeText(buf.toString(Charset.defaultCharset()), channel); } else if (marker.equals("$")) { - return decodeBinary(buf); + return decodeBinary(buf, channel); } return null; -- cgit v1.2.3