From 5c26f25b3b0afc509c76bfc4a111dbc383efee26 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Fri, 31 Mar 2023 17:26:13 -0700 Subject: Multiple battery levels --- .../org/traccar/protocol/MeitrackProtocolDecoder.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'src/main/java/org/traccar') diff --git a/src/main/java/org/traccar/protocol/MeitrackProtocolDecoder.java b/src/main/java/org/traccar/protocol/MeitrackProtocolDecoder.java index 3f1f7f506..0f0d22021 100644 --- a/src/main/java/org/traccar/protocol/MeitrackProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/MeitrackProtocolDecoder.java @@ -554,15 +554,14 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder { buf.skipBytes(length - 2); break; case 0xFEA8: - if (buf.readUnsignedByte() > 0) { - position.set(Position.KEY_BATTERY_LEVEL, buf.readUnsignedByte()); - } else { - buf.readUnsignedByte(); + for (int k = 1; k <= 3; k++) { + if (buf.readUnsignedByte() > 0) { + String key = k == 1 ? Position.KEY_BATTERY_LEVEL : "battery" + k + "Level"; + position.set(key, 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: -- cgit v1.2.3