diff options
-rw-r--r-- | src/main/java/org/traccar/protocol/TopinProtocolDecoder.java | 11 | ||||
-rw-r--r-- | src/test/java/org/traccar/protocol/TopinProtocolDecoderTest.java | 3 |
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")); |