aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2021-04-27 21:53:19 -0700
committerAnton Tananaev <anton.tananaev@gmail.com>2021-04-27 21:53:19 -0700
commit610a526a33fa1e6d8277f7fd71626ed5858d251e (patch)
tree9ac1119348ebf3a06e06b0ddb5d26e01a2a26c53
parent309e6a6d4e153b67aa598d67b45f3128716576b8 (diff)
downloadtrackermap-server-610a526a33fa1e6d8277f7fd71626ed5858d251e.tar.gz
trackermap-server-610a526a33fa1e6d8277f7fd71626ed5858d251e.tar.bz2
trackermap-server-610a526a33fa1e6d8277f7fd71626ed5858d251e.zip
Additional status attributes
-rw-r--r--src/main/java/org/traccar/protocol/TopinProtocolDecoder.java11
-rw-r--r--src/test/java/org/traccar/protocol/TopinProtocolDecoderTest.java3
2 files changed, 13 insertions, 1 deletions
diff --git a/src/main/java/org/traccar/protocol/TopinProtocolDecoder.java b/src/main/java/org/traccar/protocol/TopinProtocolDecoder.java
index fe8de3710..87db95946 100644
--- a/src/main/java/org/traccar/protocol/TopinProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/TopinProtocolDecoder.java
@@ -190,9 +190,18 @@ public class TopinProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_VERSION_FW, buf.readUnsignedByte());
buf.readUnsignedByte(); // timezone
int interval = buf.readUnsignedByte();
- if (length >= 7) {
+ if (buf.readableBytes() >= 1 + 2) {
position.set(Position.KEY_RSSI, buf.readUnsignedByte());
}
+ if (buf.readableBytes() >= 3 + 2) {
+ buf.skipBytes(3); // temperature
+ }
+ if (buf.readableBytes() >= 1 + 2) {
+ position.set(Position.KEY_CHARGE, buf.readUnsignedByte() > 0);
+ }
+ if (buf.readableBytes() >= 1 + 2) {
+ position.set(Position.KEY_HEART_RATE, buf.readUnsignedByte());
+ }
ByteBuf content = Unpooled.buffer();
content.writeByte(interval);
diff --git a/src/test/java/org/traccar/protocol/TopinProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/TopinProtocolDecoderTest.java
index 5ddee09a2..8f5b5ebbb 100644
--- a/src/test/java/org/traccar/protocol/TopinProtocolDecoderTest.java
+++ b/src/test/java/org/traccar/protocol/TopinProtocolDecoderTest.java
@@ -16,6 +16,9 @@ public class TopinProtocolDecoderTest extends ProtocolTest {
verifyNull(decoder, binary(
"78780d0103593390754169634d0d0a"));
+ verifyAttributes(decoder, binary(
+ "78780A13424008196400041F000D0A"));
+
verifyPosition(decoder, binary(
"78781510120B05030D2498038077200BE2078F0034000102030D0A"));