aboutsummaryrefslogtreecommitdiff
path: root/src/org
diff options
context:
space:
mode:
Diffstat (limited to 'src/org')
-rw-r--r--src/org/traccar/protocol/PretraceProtocolDecoder.java40
1 files changed, 38 insertions, 2 deletions
diff --git a/src/org/traccar/protocol/PretraceProtocolDecoder.java b/src/org/traccar/protocol/PretraceProtocolDecoder.java
index e4306a429..fc0245c0e 100644
--- a/src/org/traccar/protocol/PretraceProtocolDecoder.java
+++ b/src/org/traccar/protocol/PretraceProtocolDecoder.java
@@ -51,8 +51,8 @@ public class PretraceProtocolDecoder extends BaseProtocolDecoder {
.number("(x)") // satellites
.number("(dd)") // hdop
.number("(dd)") // gsm
- .expression("(.{8})") // state
- .any()
+ .expression("(.{8}),&") // state
+ .expression("(.+)?") // optional data
.text("^")
.number("xx") // checksum
.compile();
@@ -89,6 +89,42 @@ public class PretraceProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_HDOP, parser.nextInt(0));
position.set(Position.KEY_RSSI, parser.nextInt(0));
+ parser.next(); // state
+
+ if (parser.hasNext()) {
+ for (String value : parser.next().split(",")) {
+ switch (value.charAt(0)) {
+ case 'P':
+ if (value.charAt(1) == '1') {
+ if (value.charAt(4) == '%') {
+ position.set(Position.KEY_BATTERY_LEVEL, Integer.parseInt(value.substring(2, 4)));
+ } else {
+ position.set(Position.KEY_BATTERY, Integer.parseInt(value.substring(2), 16) * 0.01);
+ }
+ } else {
+ position.set(Position.KEY_POWER, Integer.parseInt(value.substring(2), 16) * 0.01);
+ }
+ break;
+ case 'T':
+ double temperature = Integer.parseInt(value.substring(2), 16) * 0.25;
+ if (value.charAt(1) == '1') {
+ position.set(Position.KEY_DEVICE_TEMP, temperature);
+ } else {
+ position.set(Position.PREFIX_TEMP + (value.charAt(1) - '0'), temperature);
+ }
+ break;
+ case 'F':
+ position.set("fuel" + (value.charAt(1) - '0'), Integer.parseInt(value.substring(2), 16) * 0.01);
+ break;
+ case 'R':
+ position.set(Position.KEY_DRIVER_UNIQUE_ID, value.substring(3));
+ break;
+ default:
+ break;
+ }
+ }
+ }
+
return position;
}