aboutsummaryrefslogtreecommitdiff
path: root/src/org
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2018-12-05 16:09:49 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2018-12-05 16:09:49 +1300
commitf61f79c2068c7ed384247107543f27dd19ee2a5a (patch)
treea5422423ff850c273ddea07671eb0994bfa4a7e0 /src/org
parent8c0d4b84f9664aa1d2e578a8a68395dc7e32c88e (diff)
downloadtrackermap-server-f61f79c2068c7ed384247107543f27dd19ee2a5a.tar.gz
trackermap-server-f61f79c2068c7ed384247107543f27dd19ee2a5a.tar.bz2
trackermap-server-f61f79c2068c7ed384247107543f27dd19ee2a5a.zip
Support additional XRB messages
Diffstat (limited to 'src/org')
-rw-r--r--src/org/traccar/protocol/Xrb28ProtocolDecoder.java61
1 files changed, 58 insertions, 3 deletions
diff --git a/src/org/traccar/protocol/Xrb28ProtocolDecoder.java b/src/org/traccar/protocol/Xrb28ProtocolDecoder.java
index 527fa4254..938394d6b 100644
--- a/src/org/traccar/protocol/Xrb28ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Xrb28ProtocolDecoder.java
@@ -88,16 +88,71 @@ public class Xrb28ProtocolDecoder extends BaseProtocolDecoder {
}
}
- if (type.matches("R0|L0|L1|S4|S5|S6|S7|V0|G0|K0|I0|M0")) {
+ if (!type.startsWith("D")) {
Position position = new Position(getProtocolName());
position.setDeviceId(deviceSession.getDeviceId());
getLastLocation(position, null);
- position.set(Position.KEY_RESULT, sentence.substring(25, sentence.length() - 1));
+ String payload = sentence.substring(25, sentence.length() - 1);
+
+ int index = 0;
+ String[] values = payload.substring(3).split(",");
+
+ switch (type) {
+ case "Q0":
+ position.set(Position.KEY_BATTERY, Integer.parseInt(values[index++]) * 0.01);
+ position.set(Position.KEY_BATTERY_LEVEL, Integer.parseInt(values[index++]));
+ position.set(Position.KEY_RSSI, Integer.parseInt(values[index++]));
+ break;
+ case "H0":
+ position.set(Position.KEY_BLOCKED, Integer.parseInt(values[index++]) > 0);
+ position.set(Position.KEY_BATTERY, Integer.parseInt(values[index++]) * 0.01);
+ position.set(Position.KEY_RSSI, Integer.parseInt(values[index++]));
+ position.set(Position.KEY_BATTERY_LEVEL, Integer.parseInt(values[index++]));
+ break;
+ case "W0":
+ switch (Integer.parseInt(values[index++])) {
+ case 1:
+ position.set(Position.KEY_ALARM, Position.ALARM_MOVEMENT);
+ break;
+ case 2:
+ position.set(Position.KEY_ALARM, Position.ALARM_FALL_DOWN);
+ break;
+ case 3:
+ position.set(Position.KEY_ALARM, Position.ALARM_LOW_BATTERY);
+ break;
+ default:
+ break;
+ }
+ break;
+ case "E0":
+ position.set(Position.KEY_ALARM, Position.ALARM_FAULT);
+ position.set("error", Integer.parseInt(values[index++]));
+ break;
+ case "S1":
+ position.set(Position.KEY_EVENT, Integer.parseInt(values[index++]));
+ break;
+ case "R0":
+ case "L0":
+ case "L1":
+ case "S4":
+ case "S5":
+ case "S6":
+ case "S7":
+ case "V0":
+ case "G0":
+ case "K0":
+ case "I0":
+ case "M0":
+ position.set(Position.KEY_RESULT, payload);
+ break;
+ default:
+ break;
+ }
- return position;
+ return !position.getAttributes().isEmpty() ? position : null;
} else {