aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2016-09-18 19:09:28 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2016-09-18 19:09:28 +1200
commit989956915085944d6d5ac550020a7a854c68b541 (patch)
treec0b1ac22560cf6b1db721121674d6a5b6751c971 /src/org/traccar/protocol
parentc60bdb519aa24c24dc5df9fab98103d072f8a4db (diff)
downloadtrackermap-server-989956915085944d6d5ac550020a7a854c68b541.tar.gz
trackermap-server-989956915085944d6d5ac550020a7a854c68b541.tar.bz2
trackermap-server-989956915085944d6d5ac550020a7a854c68b541.zip
Allow to switch GT06 command format
Diffstat (limited to 'src/org/traccar/protocol')
-rw-r--r--src/org/traccar/protocol/Gt06ProtocolEncoder.java16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/org/traccar/protocol/Gt06ProtocolEncoder.java b/src/org/traccar/protocol/Gt06ProtocolEncoder.java
index 3ef9b1313..e478424f9 100644
--- a/src/org/traccar/protocol/Gt06ProtocolEncoder.java
+++ b/src/org/traccar/protocol/Gt06ProtocolEncoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton.tananaev@gmail.com)
+ * Copyright 2015 - 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.
@@ -18,9 +18,11 @@ package org.traccar.protocol;
import org.jboss.netty.buffer.ChannelBuffer;
import org.jboss.netty.buffer.ChannelBuffers;
import org.traccar.BaseProtocolEncoder;
+import org.traccar.Context;
import org.traccar.helper.Checksum;
import org.traccar.helper.Log;
import org.traccar.model.Command;
+import org.traccar.model.Device;
import java.nio.charset.StandardCharsets;
@@ -54,11 +56,19 @@ public class Gt06ProtocolEncoder extends BaseProtocolEncoder {
@Override
protected Object encodeCommand(Command command) {
+ boolean alternative;
+ Device device = Context.getIdentityManager().getDeviceById(command.getDeviceId());
+ if (device.getAttributes().containsKey("gt06.alternative")) {
+ alternative = Boolean.parseBoolean((String) device.getAttributes().get("gt06.alternative"));
+ } else {
+ alternative = Context.getConfig().getBoolean("gt06.alternative");
+ }
+
switch (command.getType()) {
case Command.TYPE_ENGINE_STOP:
- return encodeContent("Relay,1#");
+ return encodeContent(alternative ? "DYD,123456#\r\n" : "Relay,1#");
case Command.TYPE_ENGINE_RESUME:
- return encodeContent("Relay,0#");
+ return encodeContent(alternative ? "HFYD,123456#\r\n" : "Relay,0#");
default:
Log.warning(new UnsupportedOperationException(command.getType()));
break;