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.lcn.internal.connection;
15 import java.util.concurrent.TimeUnit;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.openhab.binding.lcn.internal.common.LcnException;
21 * Base class for sending username or password.
23 * @author Fabian Wolter - Initial Contribution
26 public abstract class AbstractConnectionStateSendCredentials extends AbstractConnectionState {
27 private static final int AUTH_TIMEOUT_SEC = 10;
29 public AbstractConnectionStateSendCredentials(ConnectionStateMachine context) {
34 public void startWorking() {
35 addTimer(getScheduler().schedule(() -> nextState(ConnectionStateConnecting::new), AUTH_TIMEOUT_SEC,
40 * Starts a timeout when the PCK gateway does not answer to the credentials.
42 protected void startTimeoutTimer() {
43 addTimer(getScheduler().schedule(
44 () -> handleConnectionFailed(
45 new LcnException("Network timeout in state " + getClass().getSimpleName())),
46 connection.getSettings().getTimeout(), TimeUnit.MILLISECONDS));