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.eclipse.jdt.annotation.Nullable;
17 import org.openhab.binding.velux.internal.VeluxBindingConstants;
18 import org.openhab.binding.velux.internal.bridge.common.GetWLANConfig;
19 import org.openhab.binding.velux.internal.bridge.slip.utils.Packet;
20 import org.openhab.binding.velux.internal.things.VeluxGwWLAN;
21 import org.openhab.binding.velux.internal.things.VeluxKLFAPI.Command;
22 import org.openhab.binding.velux.internal.things.VeluxKLFAPI.CommandNumber;
23 import org.slf4j.Logger;
24 import org.slf4j.LoggerFactory;
27 * Protocol specific bridge communication supported by the Velux bridge:
28 * <B>Retrieve WLAN configuration</B>
30 * Common Message semantic: Communication with the bridge and (optionally) storing returned information within the class
33 * As 3rd level class it defines informations how to send query and receive answer through the
34 * {@link org.openhab.binding.velux.internal.bridge.VeluxBridgeProvider VeluxBridgeProvider}
35 * as described by the interface {@link SlipBridgeCommunicationProtocol}.
37 * Methods in addition to the mentioned interface:
39 * <LI>{@link #getWLANConfig} to retrieve the current WLAN configuration.</LI>
43 * @see SlipBridgeCommunicationProtocol
46 * @author Guenther Schreiner - Initial contribution.
49 class SCgetWLANConfig extends GetWLANConfig implements SlipBridgeCommunicationProtocol {
50 private final Logger logger = LoggerFactory.getLogger(SCgetWLANConfig.class);
52 private static final String DESCRIPTION = "Retrieve WLAN configuration";
53 private static final Command COMMAND = Command.GW_GET_NETWORK_SETUP_REQ;
59 private byte[] requestData = new byte[0];
60 private short responseCommand;
61 @SuppressWarnings("unused")
62 private byte @Nullable [] responseData;
65 * ===========================================================
69 public SCgetWLANConfig() {
70 logger.trace("SCgetWLANConfig(constructor) called.");
71 requestData = new byte[1];
75 * ===========================================================
76 * Methods required for interface {@link SlipBridgeCommunicationProtocol}.
80 public String name() {
85 public CommandNumber getRequestCommand() {
86 return COMMAND.getCommand();
90 public byte[] getRequestDataAsArrayOfBytes() {
95 public void setResponse(short thisResponseCommand, byte[] thisResponseData, boolean isSequentialEnforced) {
96 logger.trace("setResponseCommand({}, {}) called.", thisResponseCommand, new Packet(thisResponseData));
97 responseCommand = thisResponseCommand;
98 responseData = thisResponseData;
102 public boolean isCommunicationFinished() {
107 public boolean isCommunicationSuccessful() {
108 return (responseCommand == Command.GW_GET_NETWORK_SETUP_CFM.getShort());
112 * ===========================================================
113 * Methods in addition to interface {@link BridgeCommunicationProtocol}.
117 public VeluxGwWLAN getWLANConfig() {
118 logger.trace("getWLANConfig() called.");
119 // Enhancement idea: Velux should provide an enhanced API.
120 return new VeluxGwWLAN(VeluxBindingConstants.UNKNOWN, VeluxBindingConstants.UNKNOWN);