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/HuaShengProtocolDecoder.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/HuaShengProtocolDecoder.java')
-rw-r--r-- | src/main/java/org/traccar/protocol/HuaShengProtocolDecoder.java | 49 |
1 files changed, 16 insertions, 33 deletions
diff --git a/src/main/java/org/traccar/protocol/HuaShengProtocolDecoder.java b/src/main/java/org/traccar/protocol/HuaShengProtocolDecoder.java index 7d634b0f2..d020b5e44 100644 --- a/src/main/java/org/traccar/protocol/HuaShengProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/HuaShengProtocolDecoder.java @@ -72,24 +72,16 @@ public class HuaShengProtocolDecoder extends BaseProtocolDecoder { } private String decodeAlarm(int event) { - switch (event) { - case 4: - return Position.ALARM_FATIGUE_DRIVING; - case 6: - return Position.ALARM_SOS; - case 7: - return Position.ALARM_BRAKING; - case 8: - return Position.ALARM_ACCELERATION; - case 9: - return Position.ALARM_CORNERING; - case 10: - return Position.ALARM_ACCIDENT; - case 16: - return Position.ALARM_REMOVING; - default: - return null; - } + return switch (event) { + case 4 -> Position.ALARM_FATIGUE_DRIVING; + case 6 -> Position.ALARM_SOS; + case 7 -> Position.ALARM_BRAKING; + case 8 -> Position.ALARM_ACCELERATION; + case 9 -> Position.ALARM_CORNERING; + case 10 -> Position.ALARM_ACCIDENT; + case 16 -> Position.ALARM_REMOVING; + default -> null; + }; } @Override @@ -163,21 +155,12 @@ public class HuaShengProtocolDecoder extends BaseProtocolDecoder { while (buf.readableBytes() > 2) { String value = ByteBufUtil.hexDump(buf.readSlice(2)); int digit = Integer.parseInt(value.substring(0, 1), 16); - char prefix; - switch (digit >> 2) { - default: - prefix = 'P'; - break; - case 1: - prefix = 'C'; - break; - case 2: - prefix = 'B'; - break; - case 3: - prefix = 'U'; - break; - } + char prefix = switch (digit >> 2) { + default -> 'P'; + case 1 -> 'C'; + case 2 -> 'B'; + case 3 -> 'U'; + }; codes.append(prefix).append(digit % 4).append(value.substring(1)); if (buf.readableBytes() > 2) { codes.append(' '); |