aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/protocol/H02ProtocolDecoder.java
diff options
context:
space:
mode:
authorIván Ávalos <avalos@disroot.org>2024-08-03 20:52:00 -0600
committerIván Ávalos <avalos@disroot.org>2024-08-03 20:52:00 -0600
commit55f6d92c09a5b1d8566b53633d07be3d31010d3b (patch)
treeb86bed801b0bbadb72c7e839296dae1d28b12bbb /src/main/java/org/traccar/protocol/H02ProtocolDecoder.java
parentc04ad7d48331253c095fc123ded1b00f6ff871d3 (diff)
parent2788174193def918a3a1a5be3bbed24c9613323f (diff)
downloadtrackermap-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/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;
+ }
}
}