Discovering Devices

To find flux devices in the network, fluxclient.upnp.Discover class provide interface to discover and collect informations continuously.

Basic usage example:

from fluxclient.upnp import UpnpDiscover

def my_callback(discover, device, **kw):
    print("Device '%s' found at %s" % (device.name, device.ipaddr))

    # We find only one printer in this example
    discover.stop()

d = UpnpDiscover()
d.discover(my_callback)

In the example, my_callback will be called one a device is found or recive a device status update. A callback contains two positional arguments, first is UpnpDiscover instance and second is fluxclient.upnp.device.Device instance which it found or been updated.

class fluxclient.upnp.discover.UpnpDiscover(uuid=None, device_ipaddr=None, mcst_ipaddr='239.255.255.250', mcst_port=1901)

The uuid and device_ipaddr param can limit UpnpDiscover to find device with specified uuid or IP address. These params usually be used when you want recive specified status continuously.

Parameters:
  • uuid (uuid.UUID) – Discover specified uuid of device only
  • device_ipaddr (string) – Discover device from specified IP address only.

There is a fast way to get a specific device object directlly

fluxclient.upnp.discover_device(uuid, lookup_callback=None, timeout=inf)

Discover and return device

Parameters:
  • uuid (uuid) – Device UUID
  • lookup_callback (callable) – A callable object will be invoke during discover.
Return type:

fluxclient.upnp.device.Device