diff options
Diffstat (limited to 'src/org/traccar/protocol/GatorProtocolDecoder.java')
-rw-r--r-- | src/org/traccar/protocol/GatorProtocolDecoder.java | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/org/traccar/protocol/GatorProtocolDecoder.java b/src/org/traccar/protocol/GatorProtocolDecoder.java index 873fef3c9..94ca1fc3c 100644 --- a/src/org/traccar/protocol/GatorProtocolDecoder.java +++ b/src/org/traccar/protocol/GatorProtocolDecoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2013 - 2014 Anton Tananaev (anton.tananaev@gmail.com) + * Copyright 2013 - 2016 Anton Tananaev (anton.tananaev@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,9 +16,11 @@ package org.traccar.protocol; import org.jboss.netty.buffer.ChannelBuffer; +import org.jboss.netty.buffer.ChannelBuffers; import org.jboss.netty.channel.Channel; import org.traccar.BaseProtocolDecoder; import org.traccar.helper.BcdUtil; +import org.traccar.helper.Checksum; import org.traccar.helper.DateBuilder; import org.traccar.helper.UnitsConverter; import org.traccar.model.Position; @@ -68,7 +70,22 @@ public class GatorProtocolDecoder extends BaseProtocolDecoder { buf.readUnsignedByte(), buf.readUnsignedByte(), buf.readUnsignedByte(), buf.readUnsignedByte()); - if (type == MSG_POSITION_DATA || type == MSG_ROLLCALL_RESPONSE + 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); + } + + } else if (type == MSG_POSITION_DATA || type == MSG_ROLLCALL_RESPONSE || type == MSG_ALARM_DATA || type == MSG_BLIND_AREA) { Position position = new Position(); |