]> git.basschouten.com Git - openhab-addons.git/blob
475477ce675c32d9d30acf4d0d310901e94495eb
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
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
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.bluetooth.daikinmadoka.internal.model.commands;
14
15 import java.util.concurrent.Executor;
16
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.openhab.binding.bluetooth.daikinmadoka.internal.model.MadokaMessage;
19 import org.openhab.binding.bluetooth.daikinmadoka.internal.model.MadokaValue;
20 import org.openhab.core.util.HexUtils;
21 import org.slf4j.Logger;
22 import org.slf4j.LoggerFactory;
23
24 /**
25  * This command enable privileged commands on remote device
26  *
27  * @author Benjamin Lafois - Initial contribution
28  *
29  */
30 @NonNullByDefault
31 public class EnterPrivilegedModeCommand extends BRC1HCommand {
32
33     private final Logger logger = LoggerFactory.getLogger(EnterPrivilegedModeCommand.class);
34
35     @Override
36     public byte[][] getRequest() {
37         MadokaValue privilegedMode = new MadokaValue(0xfe, 1, new byte[] { (byte) 0x01 });
38         return MadokaMessage.createRequest(this, privilegedMode);
39     }
40
41     @Override
42     public void handleResponse(Executor executor, ResponseListener listener, MadokaMessage mm) {
43         byte[] msg = mm.getRawMessage();
44         if (logger.isDebugEnabled() && msg != null) {
45             logger.debug("Got response for {} : {}", this.getClass().getSimpleName(), HexUtils.bytesToHex(msg));
46         }
47
48         setState(State.SUCCEEDED);
49     }
50
51     @Override
52     public int getCommandId() {
53         return 16658;
54     }
55 }