]> git.basschouten.com Git - openhab-addons.git/blob
688d8baa0a71b6390b63fe24820b4afe721b6384
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
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
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.souliss.internal.discovery;
14
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jdt.annotation.Nullable;
17 import org.openhab.binding.souliss.internal.handler.SoulissGatewayHandler;
18 import org.openhab.binding.souliss.internal.protocol.CommonCommands;
19 import org.slf4j.Logger;
20 import org.slf4j.LoggerFactory;
21
22 /**
23  * @author Tonino Fazio - Initial contribution
24  * @author Luca Calcaterra - Refactor for OH3
25  */
26 @NonNullByDefault
27 public class SoulissDiscoverJob implements Runnable {
28
29     private final Logger logger = LoggerFactory.getLogger(SoulissDiscoverJob.class);
30
31     private final CommonCommands commonCommands = new CommonCommands();
32
33     private int resendCounter = 0;
34
35     private @Nullable SoulissGatewayHandler gwHandler;
36
37     public SoulissDiscoverJob(@Nullable SoulissGatewayHandler soulissGwHandler) {
38         this.gwHandler = soulissGwHandler;
39     }
40
41     @Override
42     public void run() {
43         var localGwHandler = this.gwHandler;
44         if (localGwHandler != null) {
45             commonCommands.sendDBStructFrame(localGwHandler.getGwConfig());
46             logger.debug("Sending request to gateway for souliss network - Counter={}", resendCounter);
47         } else {
48             logger.debug("Gateway null - Skipped");
49         }
50         resendCounter++;
51     }
52 }