diff options
Diffstat (limited to 'src/org/traccar/protocol/Gt06ProtocolEncoder.java')
-rw-r--r-- | src/org/traccar/protocol/Gt06ProtocolEncoder.java | 16 |
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..e78a1b388 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#" : "Relay,1#"); case Command.TYPE_ENGINE_RESUME: - return encodeContent("Relay,0#"); + return encodeContent(alternative ? "HFYD,123456#" : "Relay,0#"); default: Log.warning(new UnsupportedOperationException(command.getType())); break; |