aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol/H02ProtocolDecoder.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-06-29 10:48:34 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2015-06-29 10:48:34 +1200
commitd1c4cd526845aad56c5b0a3e20454638bbc7fecc (patch)
tree565ee245ea0e98b88674b775147fbc6d3e1933cb /src/org/traccar/protocol/H02ProtocolDecoder.java
parent88b3f00f3855aa408c7859051efdcb5b37fe559f (diff)
downloadtrackermap-server-d1c4cd526845aad56c5b0a3e20454638bbc7fecc.tar.gz
trackermap-server-d1c4cd526845aad56c5b0a3e20454638bbc7fecc.tar.bz2
trackermap-server-d1c4cd526845aad56c5b0a3e20454638bbc7fecc.zip
Merge commands implmentation (fix #1271)
Diffstat (limited to 'src/org/traccar/protocol/H02ProtocolDecoder.java')
-rw-r--r--src/org/traccar/protocol/H02ProtocolDecoder.java18
1 files changed, 9 insertions, 9 deletions
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;