diff options
author | Iván Ávalos <avalos@disroot.org> | 2024-08-03 20:52:00 -0600 |
---|---|---|
committer | Iván Ávalos <avalos@disroot.org> | 2024-08-03 20:52:00 -0600 |
commit | 55f6d92c09a5b1d8566b53633d07be3d31010d3b (patch) | |
tree | b86bed801b0bbadb72c7e839296dae1d28b12bbb /src/main/java/org/traccar/protocol/TotemProtocolEncoder.java | |
parent | c04ad7d48331253c095fc123ded1b00f6ff871d3 (diff) | |
parent | 2788174193def918a3a1a5be3bbed24c9613323f (diff) | |
download | trackermap-server-55f6d92c09a5b1d8566b53633d07be3d31010d3b.tar.gz trackermap-server-55f6d92c09a5b1d8566b53633d07be3d31010d3b.tar.bz2 trackermap-server-55f6d92c09a5b1d8566b53633d07be3d31010d3b.zip |
Merge tag 'tags/v6.3'
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 |