aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2020-05-19 22:14:49 -0700
committerAnton Tananaev <anton.tananaev@gmail.com>2020-05-19 22:14:49 -0700
commit1a4981e5adf0832d8590c964f00578179d85eb98 (patch)
tree4dbb0851426d0fc2205ce6ccbdfbb7437f4d8c1b
parent680caf2dae5d52f99d02958728da3f6cf9961a2d (diff)
downloadtrackermap-server-1a4981e5adf0832d8590c964f00578179d85eb98.tar.gz
trackermap-server-1a4981e5adf0832d8590c964f00578179d85eb98.tar.bz2
trackermap-server-1a4981e5adf0832d8590c964f00578179d85eb98.zip
Update PST decoder
-rw-r--r--src/main/java/org/traccar/protocol/PstProtocolDecoder.java10
-rw-r--r--src/test/java/org/traccar/protocol/PstProtocolDecoderTest.java3
2 files changed, 11 insertions, 2 deletions
diff --git a/src/main/java/org/traccar/protocol/PstProtocolDecoder.java b/src/main/java/org/traccar/protocol/PstProtocolDecoder.java
index 68d32636c..0c7826e42 100644
--- a/src/main/java/org/traccar/protocol/PstProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/PstProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2019 Anton Tananaev (anton@traccar.org)
+ * Copyright 2019 - 2020 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.
@@ -86,10 +86,16 @@ public class PstProtocolDecoder extends BaseProtocolDecoder {
int length = buf.readUnsignedByte();
switch (tag) {
+ case 0x09:
+ buf.readUnsignedByte(); // sensor count
+ buf.readUnsignedByte(); // sensor logic
+ int status = buf.readUnsignedByte();
+ position.set(Position.KEY_IGNITION, BitUtil.check(status, 7));
+ break;
case 0x0D:
int battery = buf.readUnsignedByte();
if (battery <= 20) {
- position.set(Position.KEY_BATTERY_LEVEL, buf.readUnsignedByte() * 5);
+ position.set(Position.KEY_BATTERY_LEVEL, battery * 5);
}
break;
case 0x10:
diff --git a/src/test/java/org/traccar/protocol/PstProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/PstProtocolDecoderTest.java
index a5db8872d..dd2564982 100644
--- a/src/test/java/org/traccar/protocol/PstProtocolDecoderTest.java
+++ b/src/test/java/org/traccar/protocol/PstProtocolDecoderTest.java
@@ -11,6 +11,9 @@ public class PstProtocolDecoderTest extends ProtocolTest {
PstProtocolDecoder decoder = new PstProtocolDecoder(null);
verifyPosition(decoder, binary(
+ "2fafb18306000005ab055166ee8f08080b0400008ec00c09b50022aef924d320f30d01130f045166ee8f10145166ee92805118978b59109900b3000b0000010c110300a7011404b58000001502039ff6e4"));
+
+ verifyPosition(decoder, binary(
"2faf9ab606000004c7055052ec88c0070b04000015050c09b500a25271c733e0720d01fe0f045052ec8410145052ba07858413918af325e7020802fe010001051103ffff0015023bbdc87d"));
verifyPosition(decoder, binary(