ignore Wacom devices that are in pairing mode
When the device is in pairing mode (blinking blue), the manufacturer data contains less than 7 fields. We should ignore those devices as we are not supposed to pull pen data out of them. Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>pull/8/head
parent
43b1c4057c
commit
c073ff2f06
11
tuhi.py
11
tuhi.py
|
@ -163,10 +163,21 @@ class Tuhi(GObject.Object):
|
||||||
self._pairing_stop_handler = None
|
self._pairing_stop_handler = None
|
||||||
self.bluez.stop_discovery()
|
self.bluez.stop_discovery()
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _is_pairing_device(cls, bluez_device):
|
||||||
|
if bluez_device.vendor_id != WACOM_COMPANY_ID:
|
||||||
|
return False
|
||||||
|
|
||||||
|
manufacturer_data = bluez_device.get_manufacturer_data(WACOM_COMPANY_ID)
|
||||||
|
return manufacturer_data is not None and len(manufacturer_data) == 4
|
||||||
|
|
||||||
def _on_bluez_device_added(self, manager, bluez_device):
|
def _on_bluez_device_added(self, manager, bluez_device):
|
||||||
if bluez_device.vendor_id != WACOM_COMPANY_ID:
|
if bluez_device.vendor_id != WACOM_COMPANY_ID:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if Tuhi._is_pairing_device(bluez_device):
|
||||||
|
return
|
||||||
|
|
||||||
tuhi_dbus_device = self.server.create_device(bluez_device)
|
tuhi_dbus_device = self.server.create_device(bluez_device)
|
||||||
d = TuhiDevice(bluez_device, tuhi_dbus_device)
|
d = TuhiDevice(bluez_device, tuhi_dbus_device)
|
||||||
self.devices[bluez_device.address] = d
|
self.devices[bluez_device.address] = d
|
||||||
|
|
|
@ -140,6 +140,12 @@ class BlueZDevice(GObject.Object):
|
||||||
return (self.interface.get_cached_property('Connected').unpack() and
|
return (self.interface.get_cached_property('Connected').unpack() and
|
||||||
self.interface.get_cached_property('ServicesResolved').unpack())
|
self.interface.get_cached_property('ServicesResolved').unpack())
|
||||||
|
|
||||||
|
def get_manufacturer_data(self, vendor_id):
|
||||||
|
md = self.interface.get_cached_property('ManufacturerData')
|
||||||
|
if md is not None and vendor_id in md.keys():
|
||||||
|
return md[vendor_id]
|
||||||
|
return None
|
||||||
|
|
||||||
def resolve(self, om):
|
def resolve(self, om):
|
||||||
"""
|
"""
|
||||||
Resolve the GattServices and GattCharacteristics. This function does
|
Resolve the GattServices and GattCharacteristics. This function does
|
||||||
|
|
Loading…
Reference in New Issue