aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/protocol/SnapperProtocolDecoder.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/SnapperProtocolDecoder.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/SnapperProtocolDecoder.java')
-rw-r--r--src/main/java/org/traccar/protocol/SnapperProtocolDecoder.java39
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;
+ };
}
}