diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2017-01-15 23:42:34 +1300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2017-01-15 23:42:34 +1300 |
commit | 671010ae5e270c58ffbae611e5580d3971133070 (patch) | |
tree | d6cb687decb07520fb32b128c76118a796f803bc | |
parent | 5d818d732fa4c83de13c9bd31f22f94e729060b2 (diff) | |
download | traccar-server-671010ae5e270c58ffbae611e5580d3971133070.tar.gz traccar-server-671010ae5e270c58ffbae611e5580d3971133070.tar.bz2 traccar-server-671010ae5e270c58ffbae611e5580d3971133070.zip |
Always send Gator echo message
-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(); |