aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/protocol/WatchProtocolDecoder.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/traccar/protocol/WatchProtocolDecoder.java')
-rw-r--r--src/main/java/org/traccar/protocol/WatchProtocolDecoder.java37
1 files changed, 19 insertions, 18 deletions
diff --git a/src/main/java/org/traccar/protocol/WatchProtocolDecoder.java b/src/main/java/org/traccar/protocol/WatchProtocolDecoder.java
index 5ff0bbb6c..4990cfd65 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.
@@ -89,8 +89,6 @@ public class WatchProtocolDecoder extends BaseProtocolDecoder {
return Position.ALARM_GEOFENCE_EXIT;
} else if (BitUtil.check(status, 2)) {
return Position.ALARM_GEOFENCE_ENTER;
- } else if (BitUtil.check(status, 3)) {
- return Position.ALARM_OVERSPEED;
} else if (BitUtil.check(status, 16)) {
return Position.ALARM_SOS;
} else if (BitUtil.check(status, 17)) {
@@ -101,7 +99,7 @@ public class WatchProtocolDecoder extends BaseProtocolDecoder {
return Position.ALARM_GEOFENCE_ENTER;
} else if (BitUtil.check(status, 20)) {
return Position.ALARM_REMOVING;
- } else if (BitUtil.check(status, 21)) {
+ } else if (BitUtil.check(status, 21) || BitUtil.check(status, 22)) {
return Position.ALARM_FALL_DOWN;
}
return null;
@@ -145,8 +143,8 @@ public class WatchProtocolDecoder extends BaseProtocolDecoder {
int cellCount = Integer.parseInt(values[index++]);
index += 1; // timing advance
- int mcc = Integer.parseInt(values[index++]);
- int mnc = Integer.parseInt(values[index++]);
+ int mcc = !values[index].isEmpty() ? Integer.parseInt(values[index++]) : 0;
+ int mnc = !values[index].isEmpty() ? Integer.parseInt(values[index++]) : 0;
for (int i = 0; i < cellCount; i++) {
network.addCellTower(CellTower.from(mcc, mnc,
@@ -254,10 +252,7 @@ public class WatchProtocolDecoder extends BaseProtocolDecoder {
Position position = decodePosition(deviceSession, buf.toString(StandardCharsets.US_ASCII));
- if (type.equals("AL")) {
- if (position != null) {
- position.set(Position.KEY_ALARM, Position.ALARM_SOS);
- }
+ if (type.startsWith("AL")) {
sendResponse(channel, id, index, "AL");
}
@@ -270,7 +265,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()) {
@@ -282,13 +278,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;