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/Jt600ProtocolDecoder.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/org/traccar/protocol/Jt600ProtocolDecoder.java') diff --git a/src/org/traccar/protocol/Jt600ProtocolDecoder.java b/src/org/traccar/protocol/Jt600ProtocolDecoder.java index 5c3dcef46..eaf9ff9c6 100644 --- a/src/org/traccar/protocol/Jt600ProtocolDecoder.java +++ b/src/org/traccar/protocol/Jt600ProtocolDecoder.java @@ -32,20 +32,20 @@ import org.traccar.model.Position; public class Jt600ProtocolDecoder extends BaseProtocolDecoder { - public Jt600ProtocolDecoder(String protocol) { + public Jt600ProtocolDecoder(Jt600Protocol protocol) { super(protocol); } - private Position decodeNormalMessage(ChannelBuffer buf) throws Exception { + private Position decodeNormalMessage(ChannelBuffer buf, Channel channel) throws Exception { Position position = new Position(); - position.setProtocol(getProtocol()); + position.setProtocol(getProtocolName()); buf.readByte(); // header // Get device by identifier String id = Long.valueOf(ChannelBufferTools.readHexString(buf, 10)).toString(); - if (!identify(id)) { + if (!identify(id, channel)) { return null; } position.setDeviceId(getDeviceId()); @@ -140,7 +140,7 @@ public class Jt600ProtocolDecoder extends BaseProtocolDecoder { "(\\d+)," + // Alert Type ".*\\)"); - private Position decodeAlertMessage(ChannelBuffer buf) throws Exception { + private Position decodeAlertMessage(ChannelBuffer buf, Channel channel) throws Exception { String message = buf.toString(Charset.defaultCharset()); @@ -152,12 +152,12 @@ public class Jt600ProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - position.setProtocol(getProtocol()); + position.setProtocol(getProtocolName()); position.set(Event.KEY_ALARM, true); Integer index = 1; // Get device by identifier - if (!identify(parser.group(index++))) { + if (!identify(parser.group(index++), channel)) { return null; } position.setDeviceId(getDeviceId()); @@ -209,9 +209,9 @@ public class Jt600ProtocolDecoder extends BaseProtocolDecoder { // Check message type if (first == '$') { - return decodeNormalMessage(buf); + return decodeNormalMessage(buf, channel); } else if (first == '(') { - return decodeAlertMessage(buf); + return decodeAlertMessage(buf, channel); } return null; -- cgit v1.2.3