aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/protocol/TytanProtocolDecoder.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/TytanProtocolDecoder.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/TytanProtocolDecoder.java')
-rw-r--r--src/main/java/org/traccar/protocol/TytanProtocolDecoder.java64
1 files changed, 21 insertions, 43 deletions
diff --git a/src/main/java/org/traccar/protocol/TytanProtocolDecoder.java b/src/main/java/org/traccar/protocol/TytanProtocolDecoder.java
index 6169e0545..04461f9cc 100644
--- a/src/main/java/org/traccar/protocol/TytanProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/TytanProtocolDecoder.java
@@ -51,55 +51,39 @@ public class TytanProtocolDecoder extends BaseProtocolDecoder {
int n;
switch (type) {
- case 2:
- position.set(Position.KEY_ODOMETER_TRIP, buf.readUnsignedMedium());
- break;
- case 5:
- position.set(Position.KEY_INPUT, buf.readUnsignedByte());
- break;
- case 6:
+ case 2 -> position.set(Position.KEY_ODOMETER_TRIP, buf.readUnsignedMedium());
+ case 5 -> position.set(Position.KEY_INPUT, buf.readUnsignedByte());
+ case 6 -> {
n = buf.readUnsignedByte() >> 4;
if (n < 2) {
position.set(Position.PREFIX_ADC + n, buf.readFloat());
} else {
position.set("di" + (n - 2), buf.readFloat());
}
- break;
- case 7:
+ }
+ case 7 -> {
int alarm = buf.readUnsignedByte();
buf.readUnsignedByte();
if (BitUtil.check(alarm, 5)) {
position.set(Position.KEY_ALARM, Position.ALARM_GENERAL);
}
- break;
- case 8:
- position.set("antihijack", buf.readUnsignedByte());
- break;
- case 9:
- position.set("unauthorized", ByteBufUtil.hexDump(buf.readSlice(8)));
- break;
- case 10:
- position.set("authorized", ByteBufUtil.hexDump(buf.readSlice(8)));
- break;
- case 24:
+ }
+ case 8 -> position.set("antihijack", buf.readUnsignedByte());
+ case 9 -> position.set("unauthorized", ByteBufUtil.hexDump(buf.readSlice(8)));
+ case 10 -> position.set("authorized", ByteBufUtil.hexDump(buf.readSlice(8)));
+ case 24 -> {
for (int i = 0; i < length / 2; i++) {
position.set(Position.PREFIX_TEMP + buf.readUnsignedByte(), buf.readByte());
}
- break;
- case 28:
+ }
+ case 28 -> {
position.set(Position.KEY_AXLE_WEIGHT, buf.readUnsignedShort());
buf.readUnsignedByte();
- break;
- case 90:
- position.set(Position.KEY_POWER, buf.readFloat());
- break;
- case 101:
- position.set(Position.KEY_OBD_SPEED, buf.readUnsignedByte());
- break;
- case 102:
- position.set(Position.KEY_RPM, buf.readUnsignedByte() * 50);
- break;
- case 107:
+ }
+ case 90 -> position.set(Position.KEY_POWER, buf.readFloat());
+ case 101 -> position.set(Position.KEY_OBD_SPEED, buf.readUnsignedByte());
+ case 102 -> position.set(Position.KEY_RPM, buf.readUnsignedByte() * 50);
+ case 107 -> {
int fuel = buf.readUnsignedShort();
int fuelFormat = fuel >> 14;
if (fuelFormat == 1) {
@@ -109,16 +93,10 @@ public class TytanProtocolDecoder extends BaseProtocolDecoder {
} else if (fuelFormat == 3) {
position.set("fuelValue", (fuel & 0x3fff) * -0.5 + " l");
}
- break;
- case 108:
- position.set(Position.KEY_OBD_ODOMETER, buf.readUnsignedInt() * 5);
- break;
- case 150:
- position.set(Position.KEY_DOOR, buf.readUnsignedByte());
- break;
- default:
- buf.skipBytes(length);
- break;
+ }
+ case 108 -> position.set(Position.KEY_OBD_ODOMETER, buf.readUnsignedInt() * 5);
+ case 150 -> position.set(Position.KEY_DOOR, buf.readUnsignedByte());
+ default -> buf.skipBytes(length);
}
}
}