From e99ce88d9ea0ab3d2ae0a039e27ebe0029508092 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sat, 1 Aug 2015 00:57:43 +1200 Subject: Fix some commands issues --- src/org/traccar/BaseProtocol.java | 2 +- src/org/traccar/protocol/Gt06ProtocolEncoder.java | 2 +- src/org/traccar/web/CommandServlet.java | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/org') diff --git a/src/org/traccar/BaseProtocol.java b/src/org/traccar/BaseProtocol.java index aa98d776c..3af39a07c 100644 --- a/src/org/traccar/BaseProtocol.java +++ b/src/org/traccar/BaseProtocol.java @@ -42,7 +42,7 @@ public abstract class BaseProtocol implements Protocol { @Override public void sendCommand(ActiveDevice activeDevice, Command command) { if (!supportedCommands.contains(command.getType())) { - throw new RuntimeException("Command " + command + " is not supported in protocol " + getName()); + throw new RuntimeException("Command " + command.getType() + " is not supported in protocol " + getName()); } activeDevice.write(command); } diff --git a/src/org/traccar/protocol/Gt06ProtocolEncoder.java b/src/org/traccar/protocol/Gt06ProtocolEncoder.java index b8177d60b..13836945f 100644 --- a/src/org/traccar/protocol/Gt06ProtocolEncoder.java +++ b/src/org/traccar/protocol/Gt06ProtocolEncoder.java @@ -40,7 +40,7 @@ public class Gt06ProtocolEncoder extends BaseProtocolEncoder { int commandLength = serverFlagBit + content.length(); int packetLength = 0x80 + content.length() + 2 + 2; - ChannelBuffer response = ChannelBuffers.directBuffer(10); + ChannelBuffer response = ChannelBuffers.dynamicBuffer(); response.writeBytes(new byte[]{0x78, 0x78}); // Start Bit response.writeByte(packetLength); // Packet Length response.writeByte(0x80); // Protocol Number diff --git a/src/org/traccar/web/CommandServlet.java b/src/org/traccar/web/CommandServlet.java index 049a0534d..f638520ec 100644 --- a/src/org/traccar/web/CommandServlet.java +++ b/src/org/traccar/web/CommandServlet.java @@ -5,8 +5,8 @@ import javax.json.JsonObject; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.traccar.Context; -import org.traccar.model.Command; import org.traccar.database.ActiveDevice; +import org.traccar.model.Command; public class CommandServlet extends BaseServlet { @@ -36,7 +36,7 @@ public class CommandServlet extends BaseServlet { private void send(HttpServletRequest req, HttpServletResponse resp) throws Exception { Command command = JsonConverter.objectFromJson(req.getReader(), new Command()); - getActiveDevice(command.getDeviceId()).write(command); + getActiveDevice(command.getDeviceId()).sendCommand(command); sendResponse(resp.getWriter(), true); } -- cgit v1.2.3