diff options
Diffstat (limited to 'src/main/java/org/traccar/protocol/TotemProtocolEncoder.java')
-rw-r--r-- | src/main/java/org/traccar/protocol/TotemProtocolEncoder.java | 43 |
1 files changed, 21 insertions, 22 deletions
diff --git a/src/main/java/org/traccar/protocol/TotemProtocolEncoder.java b/src/main/java/org/traccar/protocol/TotemProtocolEncoder.java index 4b22ade03..fea9e2d2c 100644 --- a/src/main/java/org/traccar/protocol/TotemProtocolEncoder.java +++ b/src/main/java/org/traccar/protocol/TotemProtocolEncoder.java @@ -28,28 +28,27 @@ public class TotemProtocolEncoder extends StringProtocolEncoder { } public static String formatContent(Command command) { - switch (command.getType()) { - case Command.TYPE_CUSTOM: - return String.format("%s,%s", - command.getAttributes().get(Command.KEY_DEVICE_PASSWORD), - command.getAttributes().get(Command.KEY_DATA) - ); - case Command.TYPE_REBOOT_DEVICE: - return String.format("%s,006", command.getAttributes().get(Command.KEY_DEVICE_PASSWORD)); - case Command.TYPE_FACTORY_RESET: - return String.format("%s,007", command.getAttributes().get(Command.KEY_DEVICE_PASSWORD)); - case Command.TYPE_GET_VERSION: - return String.format("%s,056", command.getAttributes().get(Command.KEY_DEVICE_PASSWORD)); - case Command.TYPE_POSITION_SINGLE: - return String.format("%s,012", command.getAttributes().get(Command.KEY_DEVICE_PASSWORD)); - // Assuming PIN 8 (Output C) is the power wire, like manual says but it can be PIN 5,7,8 - case Command.TYPE_ENGINE_STOP: - return String.format("%s,025,C,1", command.getAttributes().get(Command.KEY_DEVICE_PASSWORD)); - case Command.TYPE_ENGINE_RESUME: - return String.format("%s,025,C,0", command.getAttributes().get(Command.KEY_DEVICE_PASSWORD)); - default: - return null; - } + return switch (command.getType()) { + case Command.TYPE_CUSTOM -> + String.format( + "%s,%s", + command.getAttributes().get(Command.KEY_DEVICE_PASSWORD), + command.getAttributes().get(Command.KEY_DATA)); + case Command.TYPE_REBOOT_DEVICE -> + String.format("%s,006", command.getAttributes().get(Command.KEY_DEVICE_PASSWORD)); + case Command.TYPE_FACTORY_RESET -> + String.format("%s,007", command.getAttributes().get(Command.KEY_DEVICE_PASSWORD)); + case Command.TYPE_GET_VERSION -> + String.format("%s,056", command.getAttributes().get(Command.KEY_DEVICE_PASSWORD)); + case Command.TYPE_POSITION_SINGLE -> + String.format("%s,012", command.getAttributes().get(Command.KEY_DEVICE_PASSWORD)); + // Assuming PIN 8 (Output C) is the power wire, like manual says, but it can be PIN 5,7,8 + case Command.TYPE_ENGINE_STOP -> + String.format("%s,025,C,1", command.getAttributes().get(Command.KEY_DEVICE_PASSWORD)); + case Command.TYPE_ENGINE_RESUME -> + String.format("%s,025,C,0", command.getAttributes().get(Command.KEY_DEVICE_PASSWORD)); + default -> null; + }; } @Override |