Class Discover

java.lang.Object
tuwien.auto.calimero.tools.Discover
All Implemented Interfaces:
Runnable

public class Discover extends Object implements Runnable
A tool for Calimero showing the KNXnet/IP discovery and self-description feature.

Discover is a Runnable tool implementation allowing a user to do KNXnet/IP discovery and self-description of KNXnet/IP capable devices. As the protocol name already implies, this is done using the IP protocol. This tool shows the necessary interaction with the Calimero 2 API for discovering KNXnet/IP capable devices and query descriptions. The main part of this tool implementation interacts with the type Discoverer in the library, which implements the necessary discovery and self-description features.
When running this tool from the console, the main- method of this class is invoked, otherwise use it in the context appropriate to a Runnable.

To cancel a running discovery/description request on the console, use a user interrupt for termination, for example, ^C.
In console mode, discovery and self-description responses, as well as errors and problems during discovery/description are written to System.out.

  • Constructor Summary

    Constructors
    Constructor
    Description
    Discover(String[] args)
    Creates a new Discover instance using the supplied options; see main(String[]) for a list of options.
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    main(String... args)
    Entry point for running Discover.
    protected void
    onCompletion(Exception thrown, boolean canceled)
    Called by this tool on completion.
    protected void
    onDescriptionReceived(tuwien.auto.calimero.knxnetip.Discoverer.Result<tuwien.auto.calimero.knxnetip.servicetype.DescriptionResponse> result)
    Invoked by this tool immediately after receiving a description response.
    protected void
    onEndpointReceived(tuwien.auto.calimero.knxnetip.Discoverer.Result<tuwien.auto.calimero.knxnetip.servicetype.SearchResponse> result)
    Invoked by this tool immediately after receiving a search response.
    void
    run()
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Discover

      public Discover(String[] args)
      Creates a new Discover instance using the supplied options; see main(String[]) for a list of options.
      Parameters:
      args - list with options
  • Method Details

    • main

      public static void main(String... args)
      Entry point for running Discover.

      To show usage message of the tool on the console, supply the command line option --help (or -h).
      Command line arguments are treated case-sensitive; if no command is given, the tool only shows a short description and version info. Available commands and options for discovery/self-description:

      • search [host] start a discovery search
        • --withDescription query self description for each search result
        • --netif -i interface name | IP address  local multicast network interface
        • --unicast -u request unicast responses
        • --mac address  extended search requesting the specified MAC address
        • --progmode  extended search requesting devices in programming mode
      • describe host  query self description from host
        • --netif -i interface name | IP address  local network interface for sending description request
        • --serverport -p number  server UDP/TCP port (defaults to port 3671)
      • sd  shortcut for search --withDescription
      Other options:
      • --help -h show help message
      • --version show tool/library version and exit
      • --localport number  local UDP/TCP port (default system assigned)
      • --nat -n enable Network Address Translation
      • --timeout -t discovery/self description response timeout in seconds
      • --tcp request TCP communication
      • --udp request UDP communication
      Parameters:
      args - command line options for discovery or self-description
    • run

      public void run()
      Specified by:
      run in interface Runnable
    • onEndpointReceived

      protected void onEndpointReceived(tuwien.auto.calimero.knxnetip.Discoverer.Result<tuwien.auto.calimero.knxnetip.servicetype.SearchResponse> result)
      Invoked by this tool immediately after receiving a search response.

      This default implementation writes the endpoint information to standard output.

      Parameters:
      result - the search result containing the received search response with information about a KNXnet/IP endpoint
    • onDescriptionReceived

      protected void onDescriptionReceived(tuwien.auto.calimero.knxnetip.Discoverer.Result<tuwien.auto.calimero.knxnetip.servicetype.DescriptionResponse> result)
      Invoked by this tool immediately after receiving a description response.

      This default implementation extracts the information and writes it to the standard output.

      Parameters:
      result - the description result containing the received description response
    • onCompletion

      protected void onCompletion(Exception thrown, boolean canceled)
      Called by this tool on completion.
      Parameters:
      thrown - the thrown exception if operation completed due to a raised exception, null otherwise
      canceled - whether the operation got canceled before its planned end