aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/traccar')
-rw-r--r--src/main/java/org/traccar/model/Command.java7
-rw-r--r--src/main/java/org/traccar/protocol/GatorProtocol.java1
-rw-r--r--src/main/java/org/traccar/protocol/GatorProtocolDecoder.java1
-rw-r--r--src/main/java/org/traccar/protocol/GatorProtocolEncoder.java23
4 files changed, 25 insertions, 7 deletions
diff --git a/src/main/java/org/traccar/model/Command.java b/src/main/java/org/traccar/model/Command.java
index 99988dd82..5b81fcfef 100644
--- a/src/main/java/org/traccar/model/Command.java
+++ b/src/main/java/org/traccar/model/Command.java
@@ -15,9 +15,8 @@
*/
package org.traccar.model;
-import org.traccar.storage.QueryIgnore;
-
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import org.traccar.storage.QueryIgnore;
import org.traccar.storage.StorageName;
@StorageName("tc_commands")
@@ -72,6 +71,10 @@ public class Command extends BaseCommand {
public static final String KEY_UNIQUE_ID = "uniqueId";
public static final String KEY_FREQUENCY = "frequency";
+
+ public static final String KEY_ENGINE_OFF_INTERVAL = "engine_off_interval";
+ public static final String KEY_ENGINE_ON_INTERVAL = "engine_on_interval";
+ public static final String KEY_HEARTBEAT_INTERVAL = "heartbeat_interval";
public static final String KEY_LANGUAGE = "language";
public static final String KEY_TIMEZONE = "timezone";
public static final String KEY_DEVICE_PASSWORD = "devicePassword";
diff --git a/src/main/java/org/traccar/protocol/GatorProtocol.java b/src/main/java/org/traccar/protocol/GatorProtocol.java
index 096095463..bdea0fb00 100644
--- a/src/main/java/org/traccar/protocol/GatorProtocol.java
+++ b/src/main/java/org/traccar/protocol/GatorProtocol.java
@@ -31,6 +31,7 @@ public class GatorProtocol extends BaseProtocol {
setSupportedDataCommands(Command.TYPE_POSITION_SINGLE);
setSupportedDataCommands(Command.TYPE_ENGINE_RESUME);
setSupportedDataCommands(Command.TYPE_ENGINE_STOP);
+ setSupportedDataCommands(Command.TYPE_POSITION_PERIODIC);
addServer(new TrackerServer(config, getName(), false) {
@Override
protected void addProtocolHandlers(PipelineBuilder pipeline, Config config) {
diff --git a/src/main/java/org/traccar/protocol/GatorProtocolDecoder.java b/src/main/java/org/traccar/protocol/GatorProtocolDecoder.java
index a5ecb2169..bcd1a64b7 100644
--- a/src/main/java/org/traccar/protocol/GatorProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/GatorProtocolDecoder.java
@@ -38,6 +38,7 @@ public class GatorProtocolDecoder extends BaseProtocolDecoder {
public static final int MSG_HEARTBEAT = 0x21;
public static final int MSG_POSITION_REQUEST = 0x30;
+ public static final int MSG_POSITION_PERIODIC = 0x30;
public static final int MSG_RESTORES_THE_OIL_DUCT = 0x38;
public static final int MSG_CLOSE_THE_OIL_DUCT = 0x39;
public static final int MSG_POSITION_DATA = 0x80;
diff --git a/src/main/java/org/traccar/protocol/GatorProtocolEncoder.java b/src/main/java/org/traccar/protocol/GatorProtocolEncoder.java
index 6d96c6e9a..5452d83c7 100644
--- a/src/main/java/org/traccar/protocol/GatorProtocolEncoder.java
+++ b/src/main/java/org/traccar/protocol/GatorProtocolEncoder.java
@@ -43,18 +43,24 @@ public class GatorProtocolEncoder extends BaseProtocolEncoder {
return buf;
}
- private ByteBuf encodeContent(long deviceId, int type) {
+ private ByteBuf encodeContent(long deviceId, int type, ByteBuf content) {
ByteBuf buf = Unpooled.buffer();
buf.writeByte(0x24);
buf.writeByte(0x24);
buf.writeByte(type);
buf.writeByte(0x00);
- buf.writeByte(4 + 1 + 1); // ip 4 bytes, checksum and end byte
+
+ // ip 4 bytes, content length, checksum and end byte
+ buf.writeByte(4 + 1 + (content != null ? content.readableBytes() : 0) + 1);
ByteBuf pseudoIPAddress = encodeId(deviceId);
buf.writeBytes(pseudoIPAddress);
+ if (content != null) {
+ buf.writeBytes(content);
+ }
+
int checksum = Checksum.xor(buf.nioBuffer());
buf.writeByte(checksum);
@@ -66,13 +72,20 @@ public class GatorProtocolEncoder extends BaseProtocolEncoder {
@Override
protected Object encodeCommand(Command command) {
+ ByteBuf content = Unpooled.buffer();
+
switch (command.getType()) {
case Command.TYPE_POSITION_SINGLE:
- return encodeContent(command.getDeviceId(), GatorProtocolDecoder.MSG_POSITION_REQUEST);
+ return encodeContent(command.getDeviceId(), GatorProtocolDecoder.MSG_POSITION_REQUEST, content);
case Command.TYPE_ENGINE_STOP:
- return encodeContent(command.getDeviceId(), GatorProtocolDecoder.MSG_CLOSE_THE_OIL_DUCT);
+ return encodeContent(command.getDeviceId(), GatorProtocolDecoder.MSG_CLOSE_THE_OIL_DUCT, content);
case Command.TYPE_ENGINE_RESUME:
- return encodeContent(command.getDeviceId(), GatorProtocolDecoder.MSG_RESTORES_THE_OIL_DUCT);
+ return encodeContent(command.getDeviceId(), GatorProtocolDecoder.MSG_RESTORES_THE_OIL_DUCT, content);
+ case Command.TYPE_POSITION_PERIODIC:
+ content.writeShort(command.getInteger(Command.KEY_ENGINE_ON_INTERVAL));
+ content.writeShort(command.getInteger(Command.KEY_ENGINE_OFF_INTERVAL));
+ content.writeByte(command.getInteger(Command.KEY_HEARTBEAT_INTERVAL));
+ return encodeContent(command.getDeviceId(), GatorProtocolDecoder.MSG_POSITION_PERIODIC, content);
default:
return null;
}