From 19e00af6d0c7b666841b181438e401bb8e7415ff Mon Sep 17 00:00:00 2001 From: edvalley <52469633+edvalley@users.noreply.github.com> Date: Fri, 7 Jul 2023 23:24:23 -0400 Subject: Use BitUtil instead of logical bitwise AND operator --- src/main/java/org/traccar/protocol/LaipacProtocolDecoder.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/main/java/org/traccar/protocol/LaipacProtocolDecoder.java b/src/main/java/org/traccar/protocol/LaipacProtocolDecoder.java index 60a9365c5..c2146c22d 100644 --- a/src/main/java/org/traccar/protocol/LaipacProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/LaipacProtocolDecoder.java @@ -28,6 +28,7 @@ import org.traccar.helper.PatternBuilder; import org.traccar.model.CellTower; import org.traccar.model.Network; import org.traccar.model.Position; +import org.traccar.helper.BitUtil; import java.net.SocketAddress; import java.util.regex.Pattern; @@ -114,14 +115,14 @@ public class LaipacProtocolDecoder extends BaseProtocolDecoder { char inputStatus = event.charAt(0); if (inputStatus >= 'A' && inputStatus <= 'D') { int inputStatusInt = inputStatus - 'A'; - position.set(Position.PREFIX_IN + 1, inputStatusInt & 1); - position.set(Position.PREFIX_IN + 2, inputStatusInt & 2); + position.set(Position.PREFIX_IN + 1, BitUtil.check(inputStatusInt, 0)); + position.set(Position.PREFIX_IN + 2, BitUtil.check(inputStatusInt, 1)); position.set(Position.PREFIX_IN + 3, 0); return null; } else if (inputStatus >= 'O' && inputStatus <= 'R') { int inputStatusInt = inputStatus - 'O'; - position.set(Position.PREFIX_IN + 1, inputStatusInt & 1); - position.set(Position.PREFIX_IN + 2, inputStatusInt & 2); + position.set(Position.PREFIX_IN + 1, BitUtil.check(inputStatusInt, 0)); + position.set(Position.PREFIX_IN + 2, BitUtil.check(inputStatusInt, 1)); position.set(Position.PREFIX_IN + 3, 1); return null; } -- cgit v1.2.3