Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ def device_discovered(self, device):
print("[%s] Discovered, alias = %s" % (device.mac_address, device.alias()))

manager = AnyDeviceManager(adapter_name='hci0')
manager.start_discovery()
manager.start_discovery(timeout=10000) # 10 seconds
manager.run()
5 changes: 4 additions & 1 deletion gatt/gatt_linux.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,14 @@ def devices(self):
self.update_devices()
return self._devices.values()

def start_discovery(self, service_uuids=[]):
def start_discovery(self, service_uuids=[], timeout=10000):
"""Starts a discovery for BLE devices with given service UUIDs.

:param service_uuids: Filters the search to only return devices with given UUIDs.
:param timeout: Stops discovery after a timeout (in milliseconds). If set to 0, no timeout is used.
"""
if timeout > 0:
GObject.timeout_add(timeout, self.stop)

discovery_filter = {'Transport': 'le'}
if service_uuids: # D-Bus doesn't like empty lists, it needs to guess the type
Expand Down