aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/protocol/WliProtocolDecoder.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/WliProtocolDecoder.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/WliProtocolDecoder.java')
-rw-r--r--src/main/java/org/traccar/protocol/WliProtocolDecoder.java54
1 files changed, 14 insertions, 40 deletions
diff --git a/src/main/java/org/traccar/protocol/WliProtocolDecoder.java b/src/main/java/org/traccar/protocol/WliProtocolDecoder.java
index ec1c4d17a..a01cdb0cf 100644
--- a/src/main/java/org/traccar/protocol/WliProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/WliProtocolDecoder.java
@@ -99,54 +99,28 @@ public class WliProtocolDecoder extends BaseProtocolDecoder {
String value = buf.readCharSequence(
endIndex - buf.readerIndex(), StandardCharsets.US_ASCII).toString();
- int networkFieldsOffset;
- switch (type) {
- case 0xE4:
- networkFieldsOffset = 10;
- break;
- case 0xCB:
- networkFieldsOffset = 80;
- break;
- case 0x1E:
- networkFieldsOffset = 182;
- break;
- case 0xC9:
- default:
- networkFieldsOffset = 35;
- break;
- }
+ int networkFieldsOffset = switch (type) {
+ case 0xE4 -> 10;
+ case 0xCB -> 80;
+ case 0x1E -> 182;
+ default -> 35;
+ };
if (fieldNumber - networkFieldsOffset >= 0 && fieldNumber - networkFieldsOffset < 10) {
switch (fieldNumber - networkFieldsOffset) {
- case 0:
- cellTower.setMobileCountryCode(Integer.parseInt(value));
- break;
- case 1:
- cellTower.setMobileNetworkCode(Integer.parseInt(value));
- break;
- case 2:
- cellTower.setLocationAreaCode(Integer.parseInt(value));
- break;
- case 3:
- cellTower.setCellId(Long.parseLong(value));
- break;
- case 4:
- cellTower.setSignalStrength(Integer.parseInt(value));
- break;
- default:
- break;
+ case 0 -> cellTower.setMobileCountryCode(Integer.parseInt(value));
+ case 1 -> cellTower.setMobileNetworkCode(Integer.parseInt(value));
+ case 2 -> cellTower.setLocationAreaCode(Integer.parseInt(value));
+ case 3 -> cellTower.setCellId(Long.parseLong(value));
+ case 4 -> cellTower.setSignalStrength(Integer.parseInt(value));
}
} else {
switch (fieldNumber) {
- case 246:
+ case 246 -> {
String[] values = value.split(",");
position.set(Position.KEY_POWER, Integer.parseInt(values[2]) * 0.01);
position.set(Position.KEY_BATTERY, Integer.parseInt(values[3]) * 0.01);
- break;
- case 255:
- position.setDeviceTime(new Date(Long.parseLong(value) * 1000));
- break;
- default:
- break;
+ }
+ case 255 -> position.setDeviceTime(new Date(Long.parseLong(value) * 1000));
}
}