aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErez Ninio <ninioe@gmail.com>2019-09-11 16:43:10 +0300
committerErez Ninio <ninioe@gmail.com>2019-09-19 08:51:41 +0300
commit8a5e7d351ad1e0708655cc11dc07ac29a8e89e35 (patch)
treec25df53fd254d6c67d7ee08a7b1cd7d6e0d89f11
parentd33a48db3bdefd6bf3772432aaa26b0eb2f70d44 (diff)
downloadtraccar-server-8a5e7d351ad1e0708655cc11dc07ac29a8e89e35.tar.gz
traccar-server-8a5e7d351ad1e0708655cc11dc07ac29a8e89e35.tar.bz2
traccar-server-8a5e7d351ad1e0708655cc11dc07ac29a8e89e35.zip
watch protocol case fix
-rw-r--r--src/main/java/org/traccar/protocol/WatchProtocolDecoder.java12
-rw-r--r--src/test/java/org/traccar/protocol/WatchProtocolDecoderTest.java3
2 files changed, 12 insertions, 3 deletions
diff --git a/src/main/java/org/traccar/protocol/WatchProtocolDecoder.java b/src/main/java/org/traccar/protocol/WatchProtocolDecoder.java
index 70b207e9b..3f2156dc2 100644
--- a/src/main/java/org/traccar/protocol/WatchProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/WatchProtocolDecoder.java
@@ -267,7 +267,10 @@ public class WatchProtocolDecoder extends BaseProtocolDecoder {
sendResponse(channel, id, index, "TKQ");
- } else if (type.equals("PULSE") || type.equals("heart") || type.equals("bphrt")) {
+ } else if (type.equalsIgnoreCase("PULSE")
+ || type.equalsIgnoreCase("HEART")
+ || type.equalsIgnoreCase("BLOOD")
+ || type.equalsIgnoreCase("BPHRT")) {
if (buf.isReadable()) {
@@ -279,11 +282,14 @@ public class WatchProtocolDecoder extends BaseProtocolDecoder {
String[] values = buf.toString(StandardCharsets.US_ASCII).split(",");
int valueIndex = 0;
- if (type.equals("bphrt")) {
+ if (type.equalsIgnoreCase("BPHRT") || type.equalsIgnoreCase("BLOOD")) {
position.set("pressureHigh", values[valueIndex++]);
position.set("pressureLow", values[valueIndex++]);
}
- position.set(Position.KEY_HEART_RATE, Integer.parseInt(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 539e63253..c3f27f0a7 100644
--- a/src/test/java/org/traccar/protocol/WatchProtocolDecoderTest.java
+++ b/src/test/java/org/traccar/protocol/WatchProtocolDecoderTest.java
@@ -24,6 +24,9 @@ public class WatchProtocolDecoderTest extends ProtocolTest {
verifyAttributes(decoder, buffer(
"[3G*4700609403*0013*bphrt,120,79,73,,,,]"));
+ verifyAttributes(decoder, buffer(
+ "[ZJ*357653059860416*0007*000c*BLOOD,109,68]"));
+
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]"));