diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/org/traccar/protocol/TopinProtocolDecoder.java | 13 | ||||
-rw-r--r-- | src/test/java/org/traccar/protocol/TopinProtocolDecoderTest.java | 6 |
2 files changed, 10 insertions, 9 deletions
diff --git a/src/main/java/org/traccar/protocol/TopinProtocolDecoder.java b/src/main/java/org/traccar/protocol/TopinProtocolDecoder.java index df325bc69..c817f500a 100644 --- a/src/main/java/org/traccar/protocol/TopinProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/TopinProtocolDecoder.java @@ -134,19 +134,14 @@ public class TopinProtocolDecoder extends BaseProtocolDecoder { getLastLocation(position, null); - int battery = buf.readUnsignedByte(); - int firmware = buf.readUnsignedByte(); - int timezone = buf.readUnsignedByte(); + position.set(Position.KEY_BATTERY_LEVEL, buf.readUnsignedByte()); + position.set(Position.KEY_VERSION_FW, buf.readUnsignedByte()); + buf.readUnsignedByte(); // timezone int interval = buf.readUnsignedByte(); - int signal = 0; if (length >= 7) { - signal = buf.readUnsignedByte(); - position.set(Position.KEY_RSSI, signal); + position.set(Position.KEY_RSSI, buf.readUnsignedByte()); } - position.set(Position.KEY_BATTERY_LEVEL, battery); - position.set(Position.KEY_VERSION_FW, firmware); - ByteBuf content = Unpooled.buffer(); content.writeByte(interval); sendResponse(channel, length, type, content); diff --git a/src/test/java/org/traccar/protocol/TopinProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/TopinProtocolDecoderTest.java index e212a0f15..0e04c0a19 100644 --- a/src/test/java/org/traccar/protocol/TopinProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/TopinProtocolDecoderTest.java @@ -13,6 +13,12 @@ public class TopinProtocolDecoderTest extends ProtocolTest { verifyNull(decoder, binary( "78780d0103593390754169634d0d0a")); + verifyPosition(decoder, binary( + "787812100A03170F32179C026B3F3E0C22AD651F34600D0A")); + + verifyAttributes(decoder, binary( + "78780a132827010063000000000d0a")); + verifyNotNull(decoder, binary( "7878001719111120141807019456465111aa3c465111ab464651c1a550465106b150465342f750465342f65a465111a95a000d0a")); |