4.1.2. DeviceDiscoverer

Todo

Add documentation for the DeviceDiscover class and its methods.

class bluetooth.DeviceDiscoverer(device_id=-1)

Bases: object

Skeleton class for finer control of the device discovery process.

To implement asynchronous device discovery (e.g. if you want to do something as soon as a device is discovered), subclass DeviceDiscoverer and override device_discovered () and inquiry_complete ()

cancel_inquiry()

Call this method to cancel an inquiry in process. inquiry_complete will still be called.

device_discovered(address, device_class, rssi, name)

Called when a bluetooth device is discovered.

address is the bluetooth address of the device

device_class is the Class of Device, as specified in [1]
passed in as a 3-byte string

name is the user-friendly name of the device if lookup_names was set when the inquiry was started. otherwise None

This method exists to be overriden.

[1] https://www.bluetooth.org/foundry/assignnumb/document/baseband

fileno()
find_devices(lookup_names=True, duration=8, flush_cache=True)
find_devices (lookup_names=True, service_name=None,
duration=8, flush_cache=True)

Call this method to initiate the device discovery process

lookup_names - set to True if you want to lookup the user-friendly
names for each device found.
service_name - set to the name of a service you’re looking for.
only devices with a service of this name will be returned in device_discovered () NOT YET IMPLEMENTED
ADVANCED PARAMETERS: (don’t change these unless you know what
you’re doing)
duration - the number of 1.2 second units to spend searching for
bluetooth devices. If lookup_names is True, then the inquiry process can take a lot longer.

flush_cache - return devices discovered in previous inquiries

inquiry_complete()

Called when an inquiry started by find_devices has completed.

pre_inquiry()

Called just after find_devices is invoked, but just before the inquiry is started.

This method exists to be overriden

process_event()

Waits for one event to happen, and proceses it. The event will be either a device discovery, or an inquiry completion.

process_inquiry()

Repeatedly calls process_event () until the device inquiry has completed.