From b6f241706a3b79b0336bbff059e7b61c8cf58772 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Mon, 19 Jul 2021 19:48:21 -0700 Subject: Support Watch temperature --- .../org/traccar/protocol/WatchProtocolDecoder.java | 24 ++++++++++++++-------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/org/traccar/protocol/WatchProtocolDecoder.java b/src/main/java/org/traccar/protocol/WatchProtocolDecoder.java index db352ac73..7f70e9fff 100644 --- a/src/main/java/org/traccar/protocol/WatchProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/WatchProtocolDecoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2020 Anton Tananaev (anton@traccar.org) + * Copyright 2015 - 2021 Anton Tananaev (anton@traccar.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -268,7 +268,8 @@ public class WatchProtocolDecoder extends BaseProtocolDecoder { } else if (type.equalsIgnoreCase("PULSE") || type.equalsIgnoreCase("HEART") || type.equalsIgnoreCase("BLOOD") - || type.equalsIgnoreCase("BPHRT")) { + || type.equalsIgnoreCase("BPHRT") + || type.equalsIgnoreCase("btemp2")) { if (buf.isReadable()) { @@ -280,13 +281,18 @@ public class WatchProtocolDecoder extends BaseProtocolDecoder { String[] values = buf.toString(StandardCharsets.US_ASCII).split(","); int valueIndex = 0; - if (type.equalsIgnoreCase("BPHRT") || type.equalsIgnoreCase("BLOOD")) { - position.set("pressureHigh", values[valueIndex++]); - position.set("pressureLow", values[valueIndex++]); - } - - if (valueIndex <= values.length - 1) { - position.set(Position.KEY_HEART_RATE, Integer.parseInt(values[valueIndex])); + if (type.equalsIgnoreCase("btemp2")) { + if (Integer.parseInt(values[valueIndex++]) > 0) { + position.set(Position.PREFIX_TEMP + 1, Double.parseDouble(values[valueIndex])); + } + } else { + if (type.equalsIgnoreCase("BPHRT") || type.equalsIgnoreCase("BLOOD")) { + position.set("pressureHigh", values[valueIndex++]); + position.set("pressureLow", values[valueIndex++]); + } + if (valueIndex <= values.length - 1) { + position.set(Position.KEY_HEART_RATE, Integer.parseInt(values[valueIndex])); + } } return position; -- cgit v1.2.3