aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/protocol/FreematicsProtocolDecoder.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/traccar/protocol/FreematicsProtocolDecoder.java')
-rw-r--r--src/main/java/org/traccar/protocol/FreematicsProtocolDecoder.java91
1 files changed, 27 insertions, 64 deletions
diff --git a/src/main/java/org/traccar/protocol/FreematicsProtocolDecoder.java b/src/main/java/org/traccar/protocol/FreematicsProtocolDecoder.java
index d0402cc94..d7d9d62ed 100644
--- a/src/main/java/org/traccar/protocol/FreematicsProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/FreematicsProtocolDecoder.java
@@ -48,20 +48,13 @@ public class FreematicsProtocolDecoder extends BaseProtocolDecoder {
String key = data[0];
String value = data[1];
switch (key) {
- case "ID":
- case "VIN":
+ case "ID", "VIN" -> {
if (deviceSession == null) {
deviceSession = getDeviceSession(channel, remoteAddress, value);
}
- break;
- case "EV":
- event = value;
- break;
- case "TS":
- time = value;
- break;
- default:
- break;
+ }
+ case "EV" -> event = value;
+ case "TS" -> time = value;
}
}
@@ -105,74 +98,44 @@ public class FreematicsProtocolDecoder extends BaseProtocolDecoder {
dateBuilder = new DateBuilder(new Date());
} else if (position != null) {
switch (key) {
- case 0x11:
+ case 0x11 -> {
value = ("000000" + value).substring(value.length());
dateBuilder.setDateReverse(
Integer.parseInt(value.substring(0, 2)),
Integer.parseInt(value.substring(2, 4)),
Integer.parseInt(value.substring(4)));
- break;
- case 0x10:
+ }
+ case 0x10 -> {
value = ("00000000" + value).substring(value.length());
dateBuilder.setTime(
Integer.parseInt(value.substring(0, 2)),
Integer.parseInt(value.substring(2, 4)),
Integer.parseInt(value.substring(4, 6)),
Integer.parseInt(value.substring(6)) * 10);
- break;
- case 0xA:
+ }
+ case 0xA -> {
position.setValid(true);
position.setLatitude(Double.parseDouble(value));
- break;
- case 0xB:
+ }
+ case 0xB -> {
position.setValid(true);
position.setLongitude(Double.parseDouble(value));
- break;
- case 0xC:
- position.setAltitude(Double.parseDouble(value));
- break;
- case 0xD:
- position.setSpeed(UnitsConverter.knotsFromKph(Double.parseDouble(value)));
- break;
- case 0xE:
- position.setCourse(Integer.parseInt(value));
- break;
- case 0xF:
- position.set(Position.KEY_SATELLITES, Integer.parseInt(value));
- break;
- case 0x12:
- position.set(Position.KEY_HDOP, Integer.parseInt(value));
- break;
- case 0x20:
- position.set(Position.KEY_ACCELERATION, value);
- break;
- case 0x24:
- position.set(Position.KEY_BATTERY, Integer.parseInt(value) * 0.01);
- break;
- case 0x81:
- position.set(Position.KEY_RSSI, Integer.parseInt(value));
- break;
- case 0x82:
- position.set(Position.KEY_DEVICE_TEMP, Double.parseDouble(value) * 0.1);
- break;
- case 0x104:
- position.set(Position.KEY_ENGINE_LOAD, Integer.parseInt(value));
- break;
- case 0x105:
- position.set(Position.KEY_COOLANT_TEMP, Integer.parseInt(value));
- break;
- case 0x10c:
- position.set(Position.KEY_RPM, Integer.parseInt(value));
- break;
- case 0x10d:
- position.set(Position.KEY_OBD_SPEED, Integer.parseInt(value));
- break;
- case 0x111:
- position.set(Position.KEY_THROTTLE, Integer.parseInt(value));
- break;
- default:
- position.set(Position.PREFIX_IO + key, value);
- break;
+ }
+ case 0xC -> position.setAltitude(Double.parseDouble(value));
+ case 0xD -> position.setSpeed(UnitsConverter.knotsFromKph(Double.parseDouble(value)));
+ case 0xE -> position.setCourse(Integer.parseInt(value));
+ case 0xF -> position.set(Position.KEY_SATELLITES, Integer.parseInt(value));
+ case 0x12 -> position.set(Position.KEY_HDOP, Integer.parseInt(value));
+ case 0x20 -> position.set(Position.KEY_ACCELERATION, value);
+ case 0x24 -> position.set(Position.KEY_BATTERY, Integer.parseInt(value) * 0.01);
+ case 0x81 -> position.set(Position.KEY_RSSI, Integer.parseInt(value));
+ case 0x82 -> position.set(Position.KEY_DEVICE_TEMP, Double.parseDouble(value) * 0.1);
+ case 0x104 -> position.set(Position.KEY_ENGINE_LOAD, Integer.parseInt(value));
+ case 0x105 -> position.set(Position.KEY_COOLANT_TEMP, Integer.parseInt(value));
+ case 0x10c -> position.set(Position.KEY_RPM, Integer.parseInt(value));
+ case 0x10d -> position.set(Position.KEY_OBD_SPEED, Integer.parseInt(value));
+ case 0x111 -> position.set(Position.KEY_THROTTLE, Integer.parseInt(value));
+ default -> position.set(Position.PREFIX_IO + key, value);
}
}
}