2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.bluetooth.am43.internal.command;
15 import java.util.concurrent.Executor;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.eclipse.jdt.annotation.Nullable;
19 import org.openhab.binding.bluetooth.am43.internal.data.Direction;
20 import org.openhab.binding.bluetooth.am43.internal.data.OperationMode;
23 * The {@link GetAllCommand} gets the bulk of the settings on AM43.
24 * A GetAllCommand request actually returns several responses. But we are
25 * only interested in the device settings response (which luckily has the same command header as the request).
27 * @author Connor Petty - Initial contribution
30 public class GetAllCommand extends AM43Command {
32 private static final byte COMMAND = (byte) 0xa7;
34 public GetAllCommand() {
35 super(COMMAND, (byte) 1);
39 public boolean handleResponse(Executor executor, ResponseListener listener, byte @Nullable [] response) {
40 if (super.handleResponse(executor, listener, response)) {
41 executor.execute(() -> listener.receivedResponse(this));
47 public Direction getDirection() {
48 return Direction.valueOf((getResponse()[3] & 1) > 0);
51 public OperationMode getOperationMode() {
52 return OperationMode.valueOf((getResponse()[3] & 2) > 0);
55 public boolean getTopLimitSet() {
56 return (getResponse()[3] & 4) > 0;
59 public boolean getBottomLimitSet() {
60 return (getResponse()[3] & 8) > 0;
63 public boolean getHasLightSensor() {
64 return (getResponse()[3] & 16) > 0;
67 public int getSpeed() {
68 return getResponse()[4];
71 public int getPosition() {
72 return getResponse()[5];
75 public int getLength() {
76 return getResponse()[6] << 8 | getResponse()[7];
79 public int getDiameter() {
80 return getResponse()[8];
83 public int getType() {
84 return Math.abs(getResponse()[9] >> 4);
88 public int minResponseSize() {