aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/traccar')
-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 {