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.souliss.internal.handler;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jdt.annotation.Nullable;
17 import org.openhab.binding.souliss.internal.protocol.CommonCommands;
18 import org.openhab.core.thing.Bridge;
21 * @author Tonino Fazio - Initial contribution
22 * @author Luca Calcaterra - Refactor for OH3
26 public class SoulissGatewayJobPing implements Runnable {
28 private @Nullable SoulissGatewayHandler gwHandler;
30 private final CommonCommands commonCommands = new CommonCommands();
32 public SoulissGatewayJobPing(Bridge bridge) {
33 var bridgeHandler = bridge.getHandler();
34 if (bridgeHandler != null) {
35 gwHandler = (SoulissGatewayHandler) bridgeHandler;
41 SoulissGatewayHandler localGwHandler = this.gwHandler;
42 if (localGwHandler != null) {
43 sendPing(localGwHandler);
45 localGwHandler.pingSent();
49 private void sendPing(SoulissGatewayHandler soulissGwHandler) {
50 // sending ping packet
52 if (soulissGwHandler.getGwConfig().gatewayLanAddress.length() > 0) {
53 commonCommands.sendPing(soulissGwHandler.getGwConfig());