2 * Copyright (c) 2010-2022 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.velux.internal.bridge.slip;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.openhab.binding.velux.internal.bridge.common.RunReboot;
17 import org.openhab.binding.velux.internal.bridge.slip.utils.KLF200Response;
18 import org.openhab.binding.velux.internal.things.VeluxKLFAPI.Command;
19 import org.openhab.binding.velux.internal.things.VeluxKLFAPI.CommandNumber;
20 import org.slf4j.Logger;
21 import org.slf4j.LoggerFactory;
24 * Protocol specific bridge communication supported by the Velux bridge:
25 * <B>Reboot Bridge</B>
27 * Common Message semantic: Communication with the bridge and (optionally) storing returned information within the class
30 * As 3rd level class it defines informations how to send query and receive answer through the
31 * {@link org.openhab.binding.velux.internal.bridge.VeluxBridgeProvider VeluxBridgeProvider}
32 * as described by the {@link org.openhab.binding.velux.internal.bridge.slip.SlipBridgeCommunicationProtocol
33 * SlipBridgeCommunicationProtocol}.
35 * Methods in addition to the mentioned interface:
37 * <LI>{@link #runReboot} for rebooting the Velux hub.</LI>
41 * @see SlipBridgeCommunicationProtocol
43 * @author Andrew Fiddian-Green - Initial contribution.
46 class SCrunReboot extends RunReboot implements SlipBridgeCommunicationProtocol {
47 private final Logger logger = LoggerFactory.getLogger(SCrunReboot.class);
49 private static final String DESCRIPTION = "Issue the reboot command";
50 private static final Command COMMAND = Command.GW_REBOOT_REQ;
53 * ===========================================================
57 private byte[] requestData = new byte[0];
60 * ===========================================================
64 private boolean success = false;
65 private boolean finished = false;
68 * ===========================================================
69 * Methods required for interface {@link SlipBridgeCommunicationProtocol}.
73 public String name() {
78 public CommandNumber getRequestCommand() {
81 logger.debug("getRequestCommand() returns {} ({}).", COMMAND.name(), COMMAND.getCommand());
82 return COMMAND.getCommand();
86 public byte[] getRequestDataAsArrayOfBytes() {
91 public void setResponse(short responseCommand, byte[] thisResponseData, boolean isSequentialEnforced) {
92 KLF200Response.introLogging(logger, responseCommand, thisResponseData);
95 switch (Command.get(responseCommand)) {
97 if (!KLF200Response.isLengthValid(logger, responseCommand, thisResponseData, 0)) {
106 KLF200Response.errorLogging(logger, responseCommand);
109 KLF200Response.outroLogging(logger, success, finished);
113 public boolean isCommunicationFinished() {
118 public boolean isCommunicationSuccessful() {