diff --git a/tuhi/base.py b/tuhi/base.py index 1f32aa0..6f26032 100644 --- a/tuhi/base.py +++ b/tuhi/base.py @@ -246,7 +246,7 @@ class Tuhi(GObject.Object): if bluez_device.vendor_id not in WACOM_COMPANY_IDS: return False - manufacturer_data = bluez_device.get_manufacturer_data(bluez_device.vendor_id) + manufacturer_data = bluez_device.manufacturer_data return manufacturer_data is not None and len(manufacturer_data) == 4 def _on_bluez_discovery_started(self, manager): diff --git a/tuhi/ble.py b/tuhi/ble.py index 55c643c..e81a554 100755 --- a/tuhi/ble.py +++ b/tuhi/ble.py @@ -152,10 +152,18 @@ class BlueZDevice(GObject.Object): return (self.interface.get_cached_property('Connected').unpack() and self.interface.get_cached_property('ServicesResolved').unpack()) - def get_manufacturer_data(self, vendor_id): + @GObject.Property + def manufacturer_data(self): md = self.interface.get_cached_property('ManufacturerData') - if md is not None and vendor_id in md.keys(): - return md[vendor_id] + if md is None: + return None + + try: + return next(iter(dict(md).values())) + except StopIteration: + # dict is empty + pass + return None def resolve(self, om): @@ -257,6 +265,8 @@ class BlueZDevice(GObject.Object): self.emit('connected') if 'RSSI' in properties: self.emit('updated') + if 'ManufacturerData' in properties: + self.notify('manufacturer-data') def connect_gatt_value(self, uuid, callback): '''