2 * Copyright (c) 2010-2020 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.bridge.common.GetWLANConfig;
18 import org.openhab.binding.velux.internal.bridge.slip.utils.Packet;
19 import org.openhab.binding.velux.internal.things.VeluxGwWLAN;
20 import org.openhab.binding.velux.internal.things.VeluxKLFAPI.Command;
21 import org.openhab.binding.velux.internal.things.VeluxKLFAPI.CommandNumber;
22 import org.slf4j.Logger;
23 import org.slf4j.LoggerFactory;
26 * Protocol specific bridge communication supported by the Velux bridge:
27 * <B>Retrieve WLAN configuration</B>
29 * Common Message semantic: Communication with the bridge and (optionally) storing returned information within the class
32 * As 3rd level class it defines informations how to send query and receive answer through the
33 * {@link org.openhab.binding.velux.internal.bridge.VeluxBridgeProvider VeluxBridgeProvider}
34 * as described by the interface {@link SlipBridgeCommunicationProtocol}.
36 * Methods in addition to the mentioned interface:
38 * <LI>{@link #getWLANConfig} to retrieve the current WLAN configuration.</LI>
42 * @see SlipBridgeCommunicationProtocol
45 * @author Guenther Schreiner - Initial contribution.
48 class SCgetWLANConfig extends GetWLANConfig implements SlipBridgeCommunicationProtocol {
49 private final Logger logger = LoggerFactory.getLogger(SCgetWLANConfig.class);
51 private static final String DESCRIPTION = "Retrieve WLAN configuration";
52 private static final Command COMMAND = Command.GW_GET_NETWORK_SETUP_REQ;
54 private static final String UNSUPPORTED = "*** unsupported-by-current-gateway-firmware ***";
60 private byte[] requestData = new byte[0];
61 private short responseCommand;
62 @SuppressWarnings("unused")
63 private byte @Nullable [] responseData;
66 * ===========================================================
70 public SCgetWLANConfig() {
71 logger.trace("SCgetWLANConfig(constructor) called.");
72 requestData = new byte[1];
76 * ===========================================================
77 * Methods required for interface {@link SlipBridgeCommunicationProtocol}.
81 public String name() {
86 public CommandNumber getRequestCommand() {
87 return COMMAND.getCommand();
91 public byte[] getRequestDataAsArrayOfBytes() {
96 public void setResponse(short thisResponseCommand, byte[] thisResponseData, boolean isSequentialEnforced) {
97 logger.trace("setResponseCommand({}, {}) called.", thisResponseCommand, new Packet(thisResponseData));
98 responseCommand = thisResponseCommand;
99 responseData = thisResponseData;
103 public boolean isCommunicationFinished() {
108 public boolean isCommunicationSuccessful() {
109 return (responseCommand == Command.GW_GET_NETWORK_SETUP_CFM.getShort());
113 * ===========================================================
114 * Methods in addition to interface {@link BridgeCommunicationProtocol}.
118 public VeluxGwWLAN getWLANConfig() {
119 logger.trace("getWLANConfig() called.");
120 // Enhancement idea: Velux should provide an enhanced API.
121 return new VeluxGwWLAN(UNSUPPORTED, UNSUPPORTED);