aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2016-07-07 16:43:00 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2016-07-07 16:43:00 +1200
commit11bc6b9a9384c7fe417615af0cd7d42bbf4d78ff (patch)
tree363dcf7851019b17800b86fc2fbd3661832bec65
parent173abe94195da45f2521e75a8ac4a37e074fdc6b (diff)
downloadtraccar-server-11bc6b9a9384c7fe417615af0cd7d42bbf4d78ff.tar.gz
traccar-server-11bc6b9a9384c7fe417615af0cd7d42bbf4d78ff.tar.bz2
traccar-server-11bc6b9a9384c7fe417615af0cd7d42bbf4d78ff.zip
Add Gator heartbeat response
-rw-r--r--src/org/traccar/protocol/GatorProtocolDecoder.java21
-rw-r--r--src/org/traccar/protocol/Gt06ProtocolDecoder.java4
2 files changed, 21 insertions, 4 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();
diff --git a/src/org/traccar/protocol/Gt06ProtocolDecoder.java b/src/org/traccar/protocol/Gt06ProtocolDecoder.java
index 00444b61b..12c9d20b5 100644
--- a/src/org/traccar/protocol/Gt06ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gt06ProtocolDecoder.java
@@ -87,9 +87,9 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
private static void sendResponse(Channel channel, int type, int index) {
if (channel != null) {
- ChannelBuffer response = ChannelBuffers.directBuffer(10);
+ ChannelBuffer response = ChannelBuffers.dynamicBuffer();
response.writeByte(0x78); response.writeByte(0x78); // header
- response.writeByte(0x05); // size
+ response.writeByte(5); // size
response.writeByte(type);
response.writeShort(index);
response.writeShort(Checksum.crc16(Checksum.CRC16_X25, response.toByteBuffer(2, 4)));