View Source ExOnvif.Discovery (ExOnvif v0.7.1)

Module for discovering devices on a local network via WS Discovery protocol

Summary

Functions

Returns a list of Probe.t() that have responded via a UDP multicast call on the local network. Devices on subnets / attached routers won't respond.

Returns a single Probe.t() or an error based on filter criteria provided.

Functions

probe(opts \\ [probe_timeout: 2000, multicast_loop: false])

@spec probe(Keyword.t()) :: [ExOnvif.Discovery.Probe.t()]

Returns a list of Probe.t() that have responded via a UDP multicast call on the local network. Devices on subnets / attached routers won't respond.

Duplicate probes may be returned and it is up to the calling application to choose how to filter out a duplicate.

opts are a keyword list of options,

  • :probe_timeout denotes how long the probe will wait between new probe responses before closing out the listener. There currently is no forced duration so if the network continuously generates probe messages this has the possibility to hang.
  • :multicast_loop defaults to false. Enabling it will allow host to echoing the multicast packets back to itself. This is useful when this library runs in same device where you simulate a ONVIF device (https://www.happytimesoft.com/products/onvif-server/index.html)
  • :ip_address If the local host has many IP addresses, this option specifies which one to use.

probe_by(scopes)

@spec probe_by(Keyword.t() | String.t() | [String.t()]) ::
  {:error, :invalid_filter | :invalid_mac | :not_found}
  | {:ok, ExOnvif.Discovery.Probe.t()}

Returns a single Probe.t() or an error based on filter criteria provided.

Duplicate matches to the criteria will only return the first probe that responded to the UDP multicast message. As this uses probe/0 under the hood it is subject to the same limitations and the default probe timeout.

filter can be a keyword list containing one of:

serial - device serial number, not guaranteed to be present

ip_address - device ip that responded to the onvif multicast

mac_address - device mac address, not guaranteed to be present. Accepts colon separated, dash separated, and only digits

name - device name, usually the model number or something manufacturer determined

filter can also be:

an onvif scope - "onvif://www.onvif.org/scope_name/scope_value", not guaranteed to be present

a list of onvif scopes - matches the first one to succeed linking to a probe