aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/protocol/H02ProtocolDecoder.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/traccar/protocol/H02ProtocolDecoder.java')
-rw-r--r--src/main/java/org/traccar/protocol/H02ProtocolDecoder.java35
1 files changed, 16 insertions, 19 deletions
diff --git a/src/main/java/org/traccar/protocol/H02ProtocolDecoder.java b/src/main/java/org/traccar/protocol/H02ProtocolDecoder.java
index 2ad4f644b..38c063b52 100644
--- a/src/main/java/org/traccar/protocol/H02ProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/H02ProtocolDecoder.java
@@ -598,7 +598,7 @@ public class H02ProtocolDecoder extends BaseProtocolDecoder {
String marker = buf.toString(0, 1, StandardCharsets.US_ASCII);
switch (marker) {
- case "*":
+ case "*" -> {
String sentence = buf.toString(StandardCharsets.US_ASCII).trim();
int typeStart = sentence.indexOf(',', sentence.indexOf(',') + 1) + 1;
int typeEnd = sentence.indexOf(',', typeStart);
@@ -607,33 +607,30 @@ public class H02ProtocolDecoder extends BaseProtocolDecoder {
}
if (typeEnd > 0) {
String type = sentence.substring(typeStart, typeEnd);
- switch (type) {
- case "V0":
- case "HTBT":
+ return switch (type) {
+ case "V0", "HTBT" -> {
if (channel != null) {
String response = sentence.substring(0, typeEnd) + "#";
channel.writeAndFlush(new NetworkMessage(response, remoteAddress));
}
- return decodeHeartbeat(sentence, channel, remoteAddress);
- case "NBR":
- return decodeLbs(sentence, channel, remoteAddress);
- case "LINK":
- return decodeLink(sentence, channel, remoteAddress);
- case "V3":
- return decodeV3(sentence, channel, remoteAddress);
- case "VP1":
- return decodeVp1(sentence, channel, remoteAddress);
- default:
- return decodeText(sentence, channel, remoteAddress);
- }
+ yield decodeHeartbeat(sentence, channel, remoteAddress);
+ }
+ case "NBR" -> decodeLbs(sentence, channel, remoteAddress);
+ case "LINK" -> decodeLink(sentence, channel, remoteAddress);
+ case "V3" -> decodeV3(sentence, channel, remoteAddress);
+ case "VP1" -> decodeVp1(sentence, channel, remoteAddress);
+ default -> decodeText(sentence, channel, remoteAddress);
+ };
} else {
return null;
}
- case "$":
+ }
+ case "$" -> {
return decodeBinary(buf, channel, remoteAddress);
- case "X":
- default:
+ }
+ default -> {
return null;
+ }
}
}