diff options
author | Anton Tananaev <anton@traccar.org> | 2024-07-07 07:33:16 -0700 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2024-07-07 07:33:16 -0700 |
commit | d0536ccbc1b7234784c5e48288bbac00a60ef821 (patch) | |
tree | 29ba8e1349eb9a5990f564edad7ddc7b5e24d7f7 /src/main/java/org/traccar/protocol/SnapperProtocolDecoder.java | |
parent | 864872b2df3e26c94d3a5826f4df504de3cf6c62 (diff) | |
download | trackermap-server-d0536ccbc1b7234784c5e48288bbac00a60ef821.tar.gz trackermap-server-d0536ccbc1b7234784c5e48288bbac00a60ef821.tar.bz2 trackermap-server-d0536ccbc1b7234784c5e48288bbac00a60ef821.zip |
Update switch statements
Diffstat (limited to 'src/main/java/org/traccar/protocol/SnapperProtocolDecoder.java')
-rw-r--r-- | src/main/java/org/traccar/protocol/SnapperProtocolDecoder.java | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/src/main/java/org/traccar/protocol/SnapperProtocolDecoder.java b/src/main/java/org/traccar/protocol/SnapperProtocolDecoder.java index ef1a4426a..1af4ec9eb 100644 --- a/src/main/java/org/traccar/protocol/SnapperProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/SnapperProtocolDecoder.java @@ -93,19 +93,17 @@ public class SnapperProtocolDecoder extends BaseProtocolDecoder { buf.readUnsignedByte(); // index int type = buf.readUnsignedByte(); switch (type) { - case 0x00: + case 0x00 -> { position.set(Position.KEY_POWER, buf.readUnsignedByte() * 0.1); position.set(Position.KEY_DEVICE_TEMP, buf.readByte()); position.set(Position.KEY_RSSI, buf.readUnsignedByte()); - break; - case 0x01: + } + case 0x01 -> { position.set("interiorTemp", buf.readByte()); position.set("engineTemp", buf.readByte()); buf.readUnsignedByte(); // reserved - break; - default: - buf.skipBytes(3); - break; + } + default -> buf.skipBytes(3); } } } @@ -185,19 +183,22 @@ public class SnapperProtocolDecoder extends BaseProtocolDecoder { Position position = new Position(getProtocolName()); position.setDeviceId(deviceSession.getDeviceId()); - switch (type) { - case MSG_SEND_EVENTS: + return switch (type) { + case MSG_SEND_EVENTS -> { decodeEvents(position, buf); getLastLocation(position, null); // TODO read timestamp - return position; - case MSG_SEND_TECH_INFO: + yield position; + } + case MSG_SEND_TECH_INFO -> { decodeTechInfo(position, buf); getLastLocation(position, null); - return position; - case MSG_SEND_GPS_DATA: + yield position; + } + case MSG_SEND_GPS_DATA -> { decodeGpsData(position, buf.readSlice(length)); - return position; - case MSG_SEND_CONCATENATED_PACKET: + yield position; + } + case MSG_SEND_CONCATENATED_PACKET -> { int count = buf.readUnsignedShortLE(); for (int i = 0; i < count; i++) { int partType = buf.readUnsignedShortLE(); @@ -220,10 +221,10 @@ public class SnapperProtocolDecoder extends BaseProtocolDecoder { if (position.getFixTime() == null) { getLastLocation(position, null); } - return position; - default: - return null; - } + yield position; + } + default -> null; + }; } } |