Skip to content

Commit

Permalink
[linkTap] Initial Code Commit
Browse files Browse the repository at this point in the history
[linkTap] Initial code commit.

Signed-off-by: dag81 <david.goodyear@gmail.com>
  • Loading branch information
dag81 committed Aug 11, 2024
1 parent c9864d6 commit e8799ee
Show file tree
Hide file tree
Showing 76 changed files with 8,717 additions and 0 deletions.
13 changes: 13 additions & 0 deletions bundles/org.openhab.binding.linktap/NOTICE
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
201 changes: 201 additions & 0 deletions bundles/org.openhab.binding.linktap/README.md

Large diffs are not rendered by default.

559 changes: 559 additions & 0 deletions bundles/org.openhab.binding.linktap/Saved/LinkTapHandler.java

Large diffs are not rendered by default.

36 changes: 36 additions & 0 deletions bundles/org.openhab.binding.linktap/pom.xml
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 bundles/org.openhab.binding.linktap/src/main/feature/feature.xml
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>
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 = "";
}
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 = "";
}
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;
* }
*/
}
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);
}
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();
}
Loading

0 comments on commit e8799ee

Please sign in to comment.