aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/protocol/TrvProtocolDecoder.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/traccar/protocol/TrvProtocolDecoder.java')
-rw-r--r--src/main/java/org/traccar/protocol/TrvProtocolDecoder.java31
1 files changed, 10 insertions, 21 deletions
diff --git a/src/main/java/org/traccar/protocol/TrvProtocolDecoder.java b/src/main/java/org/traccar/protocol/TrvProtocolDecoder.java
index 1187250f8..e39b17307 100644
--- a/src/main/java/org/traccar/protocol/TrvProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/TrvProtocolDecoder.java
@@ -180,7 +180,7 @@ public class TrvProtocolDecoder extends BaseProtocolDecoder {
channel.writeAndFlush(new NetworkMessage(responseHeader + "," + time + ",0#", remoteAddress));
} else if (type.equals("AP14")) {
channel.writeAndFlush(new NetworkMessage(responseHeader + ",0.000,0.000#", remoteAddress));
- } else {
+ } else if (!type.equals("AP12") && !sentence.substring(responseHeader.length() + 1).matches("^\\d{6}$")) {
channel.writeAndFlush(new NetworkMessage(responseHeader + "#", remoteAddress));
}
}
@@ -249,15 +249,8 @@ public class TrvProtocolDecoder extends BaseProtocolDecoder {
if (parser.hasNext()) {
switch (parser.nextInt()) {
- case 1:
- position.set(Position.KEY_ALARM, Position.ALARM_SOS);
- break;
- case 5:
- case 6:
- position.set(Position.KEY_ALARM, Position.ALARM_FALL_DOWN);
- break;
- default:
- break;
+ case 1 -> position.set(Position.KEY_ALARM, Position.ALARM_SOS);
+ case 5, 6 -> position.set(Position.KEY_ALARM, Position.ALARM_FALL_DOWN);
}
}
@@ -332,28 +325,24 @@ public class TrvProtocolDecoder extends BaseProtocolDecoder {
String[] values = sentence.split(",");
switch (type) {
- case "AP49":
- position.set(Position.KEY_HEART_RATE, Integer.parseInt(values[1]));
- break;
- case "APHT":
+ case "AP49" -> position.set(Position.KEY_HEART_RATE, Integer.parseInt(values[1]));
+ case "APHT" -> {
position.set(Position.KEY_HEART_RATE, Integer.parseInt(values[1]));
position.set("pressureSystolic", Integer.parseInt(values[2]));
position.set("pressureDiastolic", Integer.parseInt(values[3]));
- break;
- case "APHP":
+ }
+ case "APHP" -> {
position.set(Position.KEY_HEART_RATE, Integer.parseInt(values[1]));
position.set("pressureSystolic", Integer.parseInt(values[2]));
position.set("pressureDiastolic", Integer.parseInt(values[3]));
position.set("spo2", Integer.parseInt(values[4]));
position.set("bloodSugar", Double.parseDouble(values[5]));
position.set("temperature", Double.parseDouble(values[6]));
- break;
- case "AP50":
+ }
+ case "AP50" -> {
position.set("temperature", Double.parseDouble(values[1]));
position.set(Position.KEY_BATTERY_LEVEL, Integer.parseInt(values[2]));
- break;
- default:
- break;
+ }
}
return position;