diff options
author | Iván Ávalos <avalos@disroot.org> | 2024-08-03 20:52:00 -0600 |
---|---|---|
committer | Iván Ávalos <avalos@disroot.org> | 2024-08-03 20:52:00 -0600 |
commit | 55f6d92c09a5b1d8566b53633d07be3d31010d3b (patch) | |
tree | b86bed801b0bbadb72c7e839296dae1d28b12bbb /src/main/java/org/traccar/protocol/TrvProtocolDecoder.java | |
parent | c04ad7d48331253c095fc123ded1b00f6ff871d3 (diff) | |
parent | 2788174193def918a3a1a5be3bbed24c9613323f (diff) | |
download | trackermap-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/TrvProtocolDecoder.java')
-rw-r--r-- | src/main/java/org/traccar/protocol/TrvProtocolDecoder.java | 31 |
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; |