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/KhdProtocolDecoder.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/KhdProtocolDecoder.java')
-rw-r--r-- | src/main/java/org/traccar/protocol/KhdProtocolDecoder.java | 30 |
1 files changed, 11 insertions, 19 deletions
diff --git a/src/main/java/org/traccar/protocol/KhdProtocolDecoder.java b/src/main/java/org/traccar/protocol/KhdProtocolDecoder.java index 2b234ab21..6ef280166 100644 --- a/src/main/java/org/traccar/protocol/KhdProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/KhdProtocolDecoder.java @@ -191,15 +191,11 @@ public class KhdProtocolDecoder extends BaseProtocolDecoder { int dataLength = buf.readUnsignedByte(); switch (dataType) { - case 0x01: - position.set(Position.KEY_FUEL_LEVEL, - buf.readUnsignedByte() * 100 + buf.readUnsignedByte()); - break; - case 0x02: - position.set(Position.PREFIX_TEMP + 1, - buf.readUnsignedByte() * 100 + buf.readUnsignedByte()); - break; - case 0x05: + case 0x01 -> position.set(Position.KEY_FUEL_LEVEL, + buf.readUnsignedByte() * 100 + buf.readUnsignedByte()); + case 0x02 -> position.set(Position.PREFIX_TEMP + 1, + buf.readUnsignedByte() * 100 + buf.readUnsignedByte()); + case 0x05 -> { int sign = buf.readUnsignedByte(); switch (sign) { case 1: @@ -212,19 +208,17 @@ public class KhdProtocolDecoder extends BaseProtocolDecoder { break; } position.set(Position.KEY_DRIVER_UNIQUE_ID, BufferUtil.readString(buf, dataLength - 1)); - break; - case 0x18: + } + case 0x18 -> { for (int i = 1; i <= 4; i++) { double value = buf.readUnsignedShort(); if (value > 0x0000 && value < 0xFFFF) { position.set("fuel" + i, value / 0xFFFE); } } - break; - case 0x20: - position.set(Position.KEY_BATTERY_LEVEL, buf.readUnsignedByte()); - break; - case 0x23: + } + case 0x20 -> position.set(Position.KEY_BATTERY_LEVEL, buf.readUnsignedByte()); + case 0x23 -> { Network network = new Network(); int count = buf.readUnsignedByte(); for (int i = 0; i < count; i++) { @@ -235,9 +229,7 @@ public class KhdProtocolDecoder extends BaseProtocolDecoder { if (count > 0) { position.setNetwork(network); } - break; - default: - break; + } } } |