diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/org/traccar/protocol/MeitrackProtocolDecoder.java | 11 | ||||
-rw-r--r-- | src/test/java/org/traccar/protocol/MeitrackProtocolDecoderTest.java | 2 |
2 files changed, 10 insertions, 3 deletions
diff --git a/src/main/java/org/traccar/protocol/MeitrackProtocolDecoder.java b/src/main/java/org/traccar/protocol/MeitrackProtocolDecoder.java index 3acd87b8f..3f1f7f506 100644 --- a/src/main/java/org/traccar/protocol/MeitrackProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/MeitrackProtocolDecoder.java @@ -554,8 +554,15 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder { buf.skipBytes(length - 2); break; case 0xFEA8: - buf.readUnsignedByte(); // battery status - position.set(Position.KEY_BATTERY_LEVEL, buf.readUnsignedByte()); + if (buf.readUnsignedByte() > 0) { + position.set(Position.KEY_BATTERY_LEVEL, buf.readUnsignedByte()); + } else { + buf.readUnsignedByte(); + } + buf.readUnsignedByte(); // battery 2 status + buf.readUnsignedByte(); // battery 2 level + buf.readUnsignedByte(); // battery 3 status + buf.readUnsignedByte(); // battery 3 level buf.readUnsignedByte(); // battery alert break; default: diff --git a/src/test/java/org/traccar/protocol/MeitrackProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/MeitrackProtocolDecoderTest.java index 853345521..ec45933a3 100644 --- a/src/test/java/org/traccar/protocol/MeitrackProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/MeitrackProtocolDecoderTest.java @@ -12,7 +12,7 @@ public class MeitrackProtocolDecoderTest extends ProtocolTest { var decoder = inject(new MeitrackProtocolDecoder(null)); verifyAttribute(decoder, binary( - "2424663137302c3836353431333035303839313733372c4343452c00000000010088001800050501060907101400150008080000091c000a18000b1e001606001a0000402300fe9000000602d5fe5ffe038f2a1f0904102c8d2b0cd23f02000df03203001c01000000050e0cf90101003170017ac80892ff4b16010113464444204c5445284c54452042414e44203329fea50601ffffff7ffffea807024d0000000000feb20501010000002a36430d0a"), + "2424593434312c3836353431333035303839313733372c4343452c00000000030088001800050501061607191400150008080000098e000a05000b0c001608001a0000402300fe9000000602c3fe5ffe03e22a1f0904e6688d2b0cd94002000d5f6f03001c01000000050e0cf901010032700298c80899ff4b16010113464444204c5445284c54452042414e44203329fea50601ffffff7ffffea807024d0000000000feb205010000000083001700050501061607191400150008080000098e000a05000b0c001608001a0000405100fe9000000502c3fe5ffe03e22a1f0904e6688d2b0cd94002000d606f0300050e0cf901010032700298c80899ff4b16010113464444204c5445284c54452042414e44203329fea50601ffffff7ffffea807024d0000000000feb205010000000088001800050501061607151400150008080000098e000a05000b0c001607001a0000402300fe9000000602c3fe5ffe03e22a1f0904f0688d2b0cd94002000d696f03001c01000000050e0cf901010032700298c80897ff4b16010113464444204c5445284c54452042414e44203329fea50601ffffff7ffffea807024d0000000000feb20501000000002a36320d0a"), Position.KEY_BATTERY_LEVEL, 77); verifyAttribute(decoder, binary( |