Class IpAddonFinder
java.lang.Object
org.openhab.core.config.discovery.addon.BaseAddonFinder
org.openhab.core.config.discovery.addon.ip.IpAddonFinder
- All Implemented Interfaces:
AddonFinder
,NetworkAddressChangeListener
@NonNullByDefault
public class IpAddonFinder
extends BaseAddonFinder
implements NetworkAddressChangeListener
This is a
IpAddonFinder
for finding suggested add-ons by sending IP packets to the
network and collecting responses.
This finder is intended to detect devices on the network which do not announce via UPnP
or mDNS. Some devices respond to queries to defined multicast addresses and ports and thus
can be detected by sending a single frame on the IP network.
Be aware of possible side effects of sending packets to unknown devices in the network! This is why the IP finder is not intended for large scale network scanning, e.g. using large port or IP ranges.
Configuration
The following parameters can be used to configure frames to be sent to the network:
discovery-parameter | values | comment |
type |
ipMulticast | no other options implemented |
destIp |
destination IP address | |
destPort |
destination port | |
listenPort |
port to use for listening to responses (optional) | privileged ports (<1024 ) not allowed |
request |
description of request frame as hex bytes separated by spaces (e.g. 0x01 0x02 ...) | dynamic replacement of variables $srcIp, $srcPort and $uuid, no others implemented yet |
requestPlain |
description of request frame as plaintext string | dynamic replacement of variables $srcIp, $srcPort and $uuid, no others implemented yet;
standard backslash sequences will be translated, and in addition to \ , there are five
XML special characters which need to be escaped:
|
timeoutMs |
timeout to wait for a answers | |
fmtMac |
format specifier string for mac address | e.g. '%02X', '%02X:', '%02x-' |
dynamic replacement (in request* ) |
value |
$srcIp |
source IP address |
$srcPort |
source port |
$srcMac |
source mac address |
$uuid |
String returned by java.util.UUID.randomUUID() |
Packets are sent out on every available network interface.
There is currently only one match-property defined: response
.
It allows a regex match, but currently only ".*" is supported.
Limitations
The IpAddonFinder
is still under active development.
There are limitations:
- Currently every returned frame is considered as success, regex matching is not implemented.
- Frames are sent only on startup (or if an
AddonInfoProvider
callssetAddonCandidates(List)
), no background scanning.
- Author:
- Holger Friedrich - Initial contribution, Jacob Laursen - Added support for broadcast-based scanning
- API note:
- The
IpAddonFinder
is still under active development, it has initially been developed to detect KNX installations and will be extended. Configuration parameters and supported features may still change. - Implementation note:
- On activation, a thread is spawned which handles the detection. Scan runs once, no continuous background scanning.
-
Field Summary
Fields inherited from class org.openhab.core.config.discovery.addon.BaseAddonFinder
addonCandidates
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
addAddonService
(AddonService featureService) void
The framework calls this method to scan through the candidate list ofAddonInfo
and return a subset of those that it suggests to be installed.void
onChanged
(List<CidrAddress> added, List<CidrAddress> removed) When network address is changed, listeners will be notified by this method.void
onPrimaryAddressChanged
(@Nullable String oldPrimaryAddress, @Nullable String newPrimaryAddress) When the primary address is changed, listeners will be notified by this method.protected void
removeAddonService
(AddonService featureService) void
setAddonCandidates
(List<AddonInfo> candidates) The framework calls this method to provide a list ofAddonInfo
elements which contain potential candidates that this finder can iterate over in order to detect which ones to return via thegetSuggestedAddons()
method.Methods inherited from class org.openhab.core.config.discovery.addon.BaseAddonFinder
propertyMatches, unsetAddonCandidates
-
Field Details
-
SERVICE_TYPE
- See Also:
-
SERVICE_NAME
- See Also:
-
-
Constructor Details
-
IpAddonFinder
-
-
Method Details
-
deactivate
public void deactivate() -
setAddonCandidates
Description copied from interface:AddonFinder
The framework calls this method to provide a list ofAddonInfo
elements which contain potential candidates that this finder can iterate over in order to detect which ones to return via thegetSuggestedAddons()
method.- Specified by:
setAddonCandidates
in interfaceAddonFinder
- Overrides:
setAddonCandidates
in classBaseAddonFinder
- Parameters:
candidates
- a list of AddonInfo candidates.
-
addAddonService
-
removeAddonService
-
onChanged
Description copied from interface:NetworkAddressChangeListener
When network address is changed, listeners will be notified by this method. When a network interface changes from "up" to "down", it is considered as "removed". When a "loopback" or "down" interface is added, the listeners are not notified.- Specified by:
onChanged
in interfaceNetworkAddressChangeListener
- Parameters:
added
- Unmodifiable list of recently added network addressesremoved
- Unmodifiable list of recently removed network addresses
-
onPrimaryAddressChanged
public void onPrimaryAddressChanged(@Nullable String oldPrimaryAddress, @Nullable String newPrimaryAddress) Description copied from interface:NetworkAddressChangeListener
When the primary address is changed, listeners will be notified by this method. The primary address will be in the form of a subnet ("xxx.xxx.xxx.xxx/yyy").- Specified by:
onPrimaryAddressChanged
in interfaceNetworkAddressChangeListener
- Parameters:
oldPrimaryAddress
- The old primary address (may be null if none specified)newPrimaryAddress
- The new primary address (may be null if none specified)
-
getSuggestedAddons
Description copied from interface:AddonFinder
The framework calls this method to scan through the candidate list ofAddonInfo
and return a subset of those that it suggests to be installed.- Specified by:
getSuggestedAddons
in interfaceAddonFinder
-
getServiceName
- Specified by:
getServiceName
in classBaseAddonFinder
-