aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2018-03-14 07:58:15 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2018-03-14 07:58:15 +1300
commit7c7002e3b001b9e4f8f9a00f9a14dff87b5c9862 (patch)
treefa9d6309ac580377d6ecd015d5e458bae3ff969b
parentb04758893af970e7954571771c1e6c136d472f20 (diff)
downloadtrackermap-server-7c7002e3b001b9e4f8f9a00f9a14dff87b5c9862.tar.gz
trackermap-server-7c7002e3b001b9e4f8f9a00f9a14dff87b5c9862.tar.bz2
trackermap-server-7c7002e3b001b9e4f8f9a00f9a14dff87b5c9862.zip
Support Watch blood pressure
-rw-r--r--src/org/traccar/protocol/WatchProtocolDecoder.java14
-rw-r--r--test/org/traccar/protocol/WatchProtocolDecoderTest.java3
2 files changed, 12 insertions, 5 deletions
diff --git a/src/org/traccar/protocol/WatchProtocolDecoder.java b/src/org/traccar/protocol/WatchProtocolDecoder.java
index 12ec3bd3f..325f2efd9 100644
--- a/src/org/traccar/protocol/WatchProtocolDecoder.java
+++ b/src/org/traccar/protocol/WatchProtocolDecoder.java
@@ -238,7 +238,7 @@ public class WatchProtocolDecoder extends BaseProtocolDecoder {
sendResponse(channel, manufacturer, id, index, "TKQ");
- } else if (type.equals("PULSE") || type.equals("heart")) {
+ } else if (type.equals("PULSE") || type.equals("heart") || type.equals("bphrt")) {
if (buf.readable()) {
@@ -247,10 +247,14 @@ public class WatchProtocolDecoder extends BaseProtocolDecoder {
getLastLocation(position, new Date());
- position.setValid(false);
- String pulse = buf.toString(StandardCharsets.US_ASCII);
- position.set("pulse", pulse);
- position.set(Position.KEY_RESULT, pulse);
+ String[] values = buf.toString(StandardCharsets.US_ASCII).split(",");
+ int valueIndex = 0;
+
+ if (type.equals("bphrt")) {
+ position.set("pressureLow", values[valueIndex++]);
+ position.set("pressureHigh", values[valueIndex++]);
+ }
+ position.set("pulse", values[valueIndex]);
return position;
diff --git a/test/org/traccar/protocol/WatchProtocolDecoderTest.java b/test/org/traccar/protocol/WatchProtocolDecoderTest.java
index 657cb0640..6ba04bf8e 100644
--- a/test/org/traccar/protocol/WatchProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/WatchProtocolDecoderTest.java
@@ -10,6 +10,9 @@ public class WatchProtocolDecoderTest extends ProtocolTest {
WatchProtocolDecoder decoder = new WatchProtocolDecoder(new WatchProtocol());
+ verifyAttributes(decoder, buffer(
+ "[3G*4700609403*0013*bphrt,120,79,73,,,,]"));
+
verifyPosition(decoder, buffer(
"[3G*8308373902*0080*AL,230817,095346,A,47.083950,N,15.4821850,E,7.60,273.8,0.0,4,15,44,0,0,00200010,2,255,232,1,7605,42530,118,7605,58036,119,0,65.8]"));