From 29afec15e109176c47e89454a3d9bcff788fc4c3 Mon Sep 17 00:00:00 2001 From: Julian Winter Date: Mon, 3 Dec 2018 19:17:11 +0100 Subject: [PATCH] Added set_timeout(..) function to be able to actually timeout a discovery. --- examples/discovery.py | 1 + gatt/gatt_linux.py | 3 +++ 2 files changed, 4 insertions(+) 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