diff options
author | Abyss777 <abyss@fox5.ru> | 2017-01-16 13:51:40 +0500 |
---|---|---|
committer | Abyss777 <abyss@fox5.ru> | 2017-01-16 13:51:40 +0500 |
commit | b5eb48cbba215ca55c1a5e5ae5fae5b375243247 (patch) | |
tree | 64a25006deb6635853c0cc727db201f088566347 /src/org/traccar/protocol/GatorProtocolDecoder.java | |
parent | cffbce4b3bc5ef817c4063a74f148a2a5986d58a (diff) | |
parent | 00caa503748a1dad3349bfb8444ef766efd60633 (diff) | |
download | traccar-server-b5eb48cbba215ca55c1a5e5ae5fae5b375243247.tar.gz traccar-server-b5eb48cbba215ca55c1a5e5ae5fae5b375243247.tar.bz2 traccar-server-b5eb48cbba215ca55c1a5e5ae5fae5b375243247.zip |
Merge remote-tracking branch 'upstream/master' into manager
# Conflicts:
# setup/default.xml
Diffstat (limited to 'src/org/traccar/protocol/GatorProtocolDecoder.java')
-rw-r--r-- | src/org/traccar/protocol/GatorProtocolDecoder.java | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/src/org/traccar/protocol/GatorProtocolDecoder.java b/src/org/traccar/protocol/GatorProtocolDecoder.java index d9c8a086c..f01efb9d8 100644 --- a/src/org/traccar/protocol/GatorProtocolDecoder.java +++ b/src/org/traccar/protocol/GatorProtocolDecoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2013 - 2016 Anton Tananaev (anton@traccar.org) + * Copyright 2013 - 2017 Anton Tananaev (anton@traccar.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -56,6 +56,21 @@ public class GatorProtocolDecoder extends BaseProtocolDecoder { return String.format("%02d%02d%02d%02d%02d", d1, d2, d3, d4, d5); } + private void sendResponse(Channel channel, byte calibration) { + if (channel != null) { + ChannelBuffer response = ChannelBuffers.dynamicBuffer(); + response.writeByte(0x24); response.writeByte(0x24); // header + response.writeByte(MSG_HEARTBEAT); // size + response.writeShort(5); + response.writeByte(calibration); + response.writeByte(0); // main order + response.writeByte(0); // slave order + response.writeByte(1); // calibration + response.writeByte(0x0D); + channel.write(response); + } + } + @Override protected Object decode( Channel channel, SocketAddress remoteAddress, Object msg) throws Exception { @@ -70,22 +85,9 @@ public class GatorProtocolDecoder extends BaseProtocolDecoder { buf.readUnsignedByte(), buf.readUnsignedByte(), buf.readUnsignedByte(), buf.readUnsignedByte()); - if (type == MSG_HEARTBEAT) { - - if (channel != null) { - ChannelBuffer response = ChannelBuffers.dynamicBuffer(); - response.writeByte(0x24); response.writeByte(0x24); // header - response.writeByte(MSG_HEARTBEAT); // size - response.writeShort(5); - response.writeByte(buf.readUnsignedByte()); - response.writeByte(0); // main order - response.writeByte(0); // slave order - response.writeByte(1); // calibration - response.writeByte(0x0D); - channel.write(response); - } + sendResponse(channel, buf.getByte(buf.writerIndex() - 2)); - } else if (type == MSG_POSITION_DATA || type == MSG_ROLLCALL_RESPONSE + if (type == MSG_POSITION_DATA || type == MSG_ROLLCALL_RESPONSE || type == MSG_ALARM_DATA || type == MSG_BLIND_AREA) { Position position = new Position(); |