aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2021-07-19 19:48:21 -0700
committerAnton Tananaev <anton.tananaev@gmail.com>2021-07-19 19:48:21 -0700
commitb6f241706a3b79b0336bbff059e7b61c8cf58772 (patch)
tree595afe0486fd15259af31c7e05f0ca4dfc3853b6 /src
parent1989e592651c892a63106bbf79d97ac8e89f6b88 (diff)
downloadtrackermap-server-b6f241706a3b79b0336bbff059e7b61c8cf58772.tar.gz
trackermap-server-b6f241706a3b79b0336bbff059e7b61c8cf58772.tar.bz2
trackermap-server-b6f241706a3b79b0336bbff059e7b61c8cf58772.zip
Support Watch temperature
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/traccar/protocol/WatchProtocolDecoder.java24
-rw-r--r--src/test/java/org/traccar/protocol/WatchProtocolDecoderTest.java4
2 files changed, 19 insertions, 9 deletions
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;
diff --git a/src/test/java/org/traccar/protocol/WatchProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/WatchProtocolDecoderTest.java
index 73b97d1b4..4544b5827 100644
--- a/src/test/java/org/traccar/protocol/WatchProtocolDecoderTest.java
+++ b/src/test/java/org/traccar/protocol/WatchProtocolDecoderTest.java
@@ -15,6 +15,10 @@ public class WatchProtocolDecoderTest extends ProtocolTest {
var decoder = new WatchProtocolDecoder(null);
+ verifyAttribute(decoder, buffer(
+ "[3G*2104326058*000E*btemp2,1,35.29]"),
+ Position.PREFIX_TEMP + 1, 35.29);
+
verifyPosition(decoder, buffer(
"[3G*2104326058*00E9*UD_LTE,300621,135101,A,32.162652,N,34.888748,E,30.84,265.158,65.621,18,100,83,0,0,00000000,1,1,425,01,10223,8012811,100,3,ES4104,22:74:1d:39:64:ff,-46,metropoline-wifi,a8:3f:a1:e0:66:ba,-89,Egged.co.il,00:0c:42:51:cf:cd,-81,1.7055488]"));