diff --git a/examples/discovery.py b/examples/discovery.py index 2b2731e..9c48770 100644 --- a/examples/discovery.py +++ b/examples/discovery.py @@ -6,4 +6,5 @@ def device_discovered(self, device): manager = AnyDeviceManager(adapter_name='hci0') manager.start_discovery() +manager.set_timeout(3 * 1000); # Timeout after 3 seconds manager.run() diff --git a/gatt/gatt_linux.py b/gatt/gatt_linux.py index dcf0b00..ed15e7d 100644 --- a/gatt/gatt_linux.py +++ b/gatt/gatt_linux.py @@ -48,6 +48,9 @@ def __init__(self, adapter_name): self.update_devices() + def set_timeout(self, timeout): + GObject.timeout_add(timeout, self.stop) + @property def is_adapter_powered(self): return self._adapter_properties.Get('org.bluez.Adapter1', 'Powered') == 1