aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol/GranitProtocolEncoder.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2018-09-14 14:33:49 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2018-09-14 14:33:49 +1200
commitb10824bb5769c4abb93e3451673b88efdfb9d467 (patch)
treec4d04ed2f19d5758a75b702467dbc051c5d0511c /src/org/traccar/protocol/GranitProtocolEncoder.java
parente331573c0df7467fd36ae3eba3c259ed9b1d9253 (diff)
downloadtrackermap-server-b10824bb5769c4abb93e3451673b88efdfb9d467.tar.gz
trackermap-server-b10824bb5769c4abb93e3451673b88efdfb9d467.tar.bz2
trackermap-server-b10824bb5769c4abb93e3451673b88efdfb9d467.zip
Log using slf4j and java logging
Diffstat (limited to 'src/org/traccar/protocol/GranitProtocolEncoder.java')
-rw-r--r--src/org/traccar/protocol/GranitProtocolEncoder.java29
1 files changed, 11 insertions, 18 deletions
diff --git a/src/org/traccar/protocol/GranitProtocolEncoder.java b/src/org/traccar/protocol/GranitProtocolEncoder.java
index bde267ee6..6345ff971 100644
--- a/src/org/traccar/protocol/GranitProtocolEncoder.java
+++ b/src/org/traccar/protocol/GranitProtocolEncoder.java
@@ -20,36 +20,29 @@ import java.nio.charset.StandardCharsets;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import org.traccar.BaseProtocolEncoder;
-import org.traccar.helper.Log;
import org.traccar.model.Command;
public class GranitProtocolEncoder extends BaseProtocolEncoder {
- @Override
- protected Object encodeCommand(Command command) {
- String commandString = "";
+ private ByteBuf encodeCommand(String commandString) {
+ ByteBuf buffer = Unpooled.buffer();
+ buffer.writeBytes(commandString.getBytes(StandardCharsets.US_ASCII));
+ GranitProtocolDecoder.appendChecksum(buffer, commandString.length());
+ return buffer;
+ }
+ @Override
+ protected Object encodeCommand(Command command) {
switch (command.getType()) {
case Command.TYPE_IDENTIFICATION:
- commandString = "BB+IDNT";
- break;
+ return encodeCommand("BB+IDNT");
case Command.TYPE_REBOOT_DEVICE:
- commandString = "BB+RESET";
- break;
+ return encodeCommand("BB+RESET");
case Command.TYPE_POSITION_SINGLE:
- commandString = "BB+RRCD";
- break;
+ return encodeCommand("BB+RRCD");
default:
- Log.warning(new UnsupportedOperationException(command.getType()));
return null;
}
- if (!commandString.isEmpty()) {
- ByteBuf commandBuf = Unpooled.buffer();
- commandBuf.writeBytes(commandString.getBytes(StandardCharsets.US_ASCII));
- GranitProtocolDecoder.appendChecksum(commandBuf, commandString.length());
- return commandBuf;
- }
- return null;
}
}