-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[linkTap] Initial code commit. Signed-off-by: dag81 <[email protected]>
- Loading branch information
Showing
76 changed files
with
8,717 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
This content is produced and maintained by the openHAB project. | ||
|
||
* Project home: https://www.openhab.org | ||
|
||
== Declared Project Licenses | ||
|
||
This program and the accompanying materials are made available under the terms | ||
of the Eclipse Public License 2.0 which is available at | ||
https://www.eclipse.org/legal/epl-2.0/. | ||
|
||
== Source Code | ||
|
||
https://github.com/openhab/openhab-addons |
Large diffs are not rendered by default.
Oops, something went wrong.
559 changes: 559 additions & 0 deletions
559
bundles/org.openhab.binding.linktap/Saved/LinkTapHandler.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>org.openhab.addons.bundles</groupId> | ||
<artifactId>org.openhab.addons.reactor.bundles</artifactId> | ||
<version>4.2.0-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>org.openhab.binding.linktap</artifactId> | ||
|
||
<name>openHAB Add-ons :: Bundles :: LinkTap Binding</name> | ||
|
||
<properties> | ||
<jsoup.version>1.15.3</jsoup.version> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.jsoup</groupId> | ||
<artifactId>jsoup</artifactId> | ||
<version>${jsoup.version}</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>4.13.2</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
10 changes: 10 additions & 0 deletions
10
bundles/org.openhab.binding.linktap/src/main/feature/feature.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<features name="org.openhab.binding.linktap-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.4.0"> | ||
<repository>mvn:org.openhab.core.features.karaf/org.openhab.core.features.karaf.openhab-core/${ohc.version}/xml/features</repository> | ||
|
||
<feature name="openhab-binding-linktap" description="LinkTap Binding" version="${project.version}"> | ||
<feature>openhab-runtime-base</feature> | ||
<bundle dependency="true">mvn:org.jsoup/jsoup/1.15.3</bundle> | ||
<bundle start-level="80">mvn:org.openhab.addons.bundles/org.openhab.binding.linktap/${project.version}</bundle> | ||
</feature> | ||
</features> |
28 changes: 28 additions & 0 deletions
28
...p/src/main/java/org/openhab/binding/linktap/configuration/LinkTapBridgeConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/** | ||
* Copyright (c) 2010-2024 Contributors to the openHAB project | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0 | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
package org.openhab.binding.linktap.configuration; | ||
|
||
import org.eclipse.jdt.annotation.NonNullByDefault; | ||
|
||
/** | ||
* The {@link LinkTapBridgeConfiguration} class contains fields mapping bridge configuration parameters. | ||
* | ||
* @author David Goodyear - Initial contribution | ||
*/ | ||
@NonNullByDefault | ||
public class LinkTapBridgeConfiguration { | ||
|
||
public String host = ""; | ||
public String username = ""; | ||
public String password = ""; | ||
} |
27 changes: 27 additions & 0 deletions
27
...p/src/main/java/org/openhab/binding/linktap/configuration/LinkTapDeviceConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/** | ||
* Copyright (c) 2010-2024 Contributors to the openHAB project | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0 | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
package org.openhab.binding.linktap.configuration; | ||
|
||
import org.eclipse.jdt.annotation.NonNullByDefault; | ||
|
||
/** | ||
* The {@link LinkTapDeviceConfiguration} class contains fields mapping thing configuration parameters. | ||
* | ||
* @author David Goodyear - Initial contribution | ||
*/ | ||
@NonNullByDefault | ||
public class LinkTapDeviceConfiguration { | ||
|
||
public String id = ""; | ||
public String name = ""; | ||
} |
81 changes: 81 additions & 0 deletions
81
...hab.binding.linktap/src/main/java/org/openhab/binding/linktap/internal/BridgeManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/** | ||
* Copyright (c) 2010-2024 Contributors to the openHAB project | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0 | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
package org.openhab.binding.linktap.internal; | ||
|
||
import java.util.Map; | ||
import java.util.concurrent.ConcurrentHashMap; | ||
|
||
import org.eclipse.jdt.annotation.NonNullByDefault; | ||
import org.openhab.binding.linktap.protocol.servers.BindingServlet; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
/** | ||
* The {@link BridgeManager} is a singleton responsible for routing based on the key (IP address) back to | ||
* the relevant LinkTapBridgeHandler instance. | ||
* | ||
* @author David Goodyear - Initial contribution | ||
*/ | ||
@NonNullByDefault | ||
public final class BridgeManager { | ||
|
||
private final Logger logger = LoggerFactory.getLogger(BridgeManager.class); | ||
|
||
private static final BridgeManager INSTANCE = new BridgeManager(); | ||
|
||
final Map<String, LinkTapBridgeHandler> ipAddrLookup = new ConcurrentHashMap<String, LinkTapBridgeHandler>(); | ||
final Map<String, LinkTapBridgeHandler> idLookup = new ConcurrentHashMap<String, LinkTapBridgeHandler>(); | ||
|
||
private BridgeManager() { | ||
} | ||
|
||
public static BridgeManager getInstance() { | ||
return INSTANCE; | ||
} | ||
|
||
public boolean isEmpty() { | ||
return ipAddrLookup.isEmpty(); | ||
} | ||
|
||
public boolean registerBridge(final String ipAddress, final LinkTapBridgeHandler bridge) { | ||
logger.warn("Adding {} -> {}", ipAddress, bridge); | ||
if (ipAddrLookup.containsKey(ipAddress)) { | ||
if (!bridge.equals(ipAddrLookup.get(ipAddress))) { | ||
return false; | ||
} | ||
} | ||
ipAddrLookup.put(ipAddress, bridge); | ||
logger.warn("Total mappings is now : {}", ipAddrLookup.size()); | ||
BindingServlet.getInstance().registerServlet(); | ||
return true; | ||
} | ||
|
||
public void deregisterBridge(final String ipAddress, final LinkTapBridgeHandler bridge, | ||
final LinkTapBridgeHandler handler) { | ||
logger.warn("Removing {} -> {}", ipAddress, bridge); | ||
ipAddrLookup.remove(ipAddress, handler); | ||
logger.warn("Total mappings is now : {}", ipAddrLookup.size()); | ||
if (ipAddrLookup.isEmpty()) { | ||
BindingServlet.getInstance().unregisterServlet(); | ||
} | ||
} | ||
|
||
/* | ||
* public LinkTapBridgeHandler getBridge(final String ipAddress) { | ||
* logger.warn("Locating {}", ipAddress); | ||
* LinkTapBridgeHandler result = ipAddrLookup.get(ipAddress); | ||
* logger.warn("Locating result {} -> {}", ipAddress, result); | ||
* return result; | ||
* } | ||
*/ | ||
} |
25 changes: 25 additions & 0 deletions
25
...ktap/src/main/java/org/openhab/binding/linktap/internal/DeviceMetaDataUpdatedHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/** | ||
* Copyright (c) 2010-2024 Contributors to the openHAB project | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0 | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
package org.openhab.binding.linktap.internal; | ||
|
||
import org.eclipse.jdt.annotation.NonNullByDefault; | ||
|
||
/** | ||
* The {@link DeviceMetaDataUpdatedHandler} enables call-backs for when the device meta-data is updated from a bridge. | ||
* | ||
* @author David Goodyear - Initial contribution | ||
*/ | ||
@NonNullByDefault | ||
public interface DeviceMetaDataUpdatedHandler { | ||
void handleMetadataRetrieved(LinkTapBridgeHandler handler); | ||
} |
23 changes: 23 additions & 0 deletions
23
...enhab.binding.linktap/src/main/java/org/openhab/binding/linktap/internal/IBridgeData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/** | ||
* Copyright (c) 2010-2024 Contributors to the openHAB project | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0 | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
package org.openhab.binding.linktap.internal; | ||
|
||
import org.eclipse.jdt.annotation.NonNullByDefault; | ||
|
||
/** | ||
* @author David Goodyear - Initial contribution | ||
*/ | ||
@NonNullByDefault | ||
public interface IBridgeData { | ||
void handleBridgeDataUpdated(); | ||
} |
Oops, something went wrong.