aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-08-17 06:29:07 -0700
committerAnton Tananaev <anton@traccar.org>2022-08-17 06:29:07 -0700
commit6bce58763ef9b8ba3b75139114f727c5685694d0 (patch)
tree418ba85a8c9f6d5ae1b115ca5d1d0e995ff3f186
parentd11002c4820c2f964a9e4c2f1bdc8b758bfa7050 (diff)
downloadtrackermap-server-6bce58763ef9b8ba3b75139114f727c5685694d0.tar.gz
trackermap-server-6bce58763ef9b8ba3b75139114f727c5685694d0.tar.bz2
trackermap-server-6bce58763ef9b8ba3b75139114f727c5685694d0.zip
Correct G109 command format
-rw-r--r--src/main/java/org/traccar/protocol/Gt06ProtocolEncoder.java23
1 files changed, 18 insertions, 5 deletions
diff --git a/src/main/java/org/traccar/protocol/Gt06ProtocolEncoder.java b/src/main/java/org/traccar/protocol/Gt06ProtocolEncoder.java
index 6b2cd6833..dc5dd446f 100644
--- a/src/main/java/org/traccar/protocol/Gt06ProtocolEncoder.java
+++ b/src/main/java/org/traccar/protocol/Gt06ProtocolEncoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 - 2019 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2022 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.
@@ -23,6 +23,7 @@ import org.traccar.config.Keys;
import org.traccar.helper.Checksum;
import org.traccar.helper.model.AttributeUtil;
import org.traccar.model.Command;
+import org.traccar.model.Device;
import java.nio.charset.StandardCharsets;
@@ -73,13 +74,25 @@ public class Gt06ProtocolEncoder extends BaseProtocolEncoder {
String password = AttributeUtil.getDevicePassword(
getCacheManager(), command.getDeviceId(), getProtocolName(), "123456");
+ Device device = getCacheManager().getObject(Device.class, command.getDeviceId());
+
switch (command.getType()) {
case Command.TYPE_ENGINE_STOP:
- return encodeContent(command.getDeviceId(),
- alternative ? "DYD," + password + "#" : "Relay,1#");
+ if ("G109".equals(device.getModel())) {
+ return encodeContent(command.getDeviceId(), "DYD#");
+ } else if (alternative) {
+ return encodeContent(command.getDeviceId(), "DYD," + password + "#");
+ } else {
+ return encodeContent(command.getDeviceId(), "Relay,1#");
+ }
case Command.TYPE_ENGINE_RESUME:
- return encodeContent(command.getDeviceId(),
- alternative ? "HFYD," + password + "#" : "Relay,0#");
+ if ("G109".equals(device.getModel())) {
+ return encodeContent(command.getDeviceId(), "HFYD#");
+ } else if (alternative) {
+ return encodeContent(command.getDeviceId(), "HFYD," + password + "#");
+ } else {
+ return encodeContent(command.getDeviceId(), "Relay,0#");
+ }
case Command.TYPE_CUSTOM:
return encodeContent(command.getDeviceId(), command.getString(Command.KEY_DATA));
default: