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
Benjamin Tissoires 2018-01-17 15:44:16 +01:00 committed by Peter Hutterer
parent 43b1c4057c
commit c073ff2f06
2 changed files with 17 additions and 0 deletions

11
tuhi.py
View File

@ -163,10 +163,21 @@ class Tuhi(GObject.Object):
self._pairing_stop_handler = None
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):
if bluez_device.vendor_id != WACOM_COMPANY_ID:
return
if Tuhi._is_pairing_device(bluez_device):
return
tuhi_dbus_device = self.server.create_device(bluez_device)
d = TuhiDevice(bluez_device, tuhi_dbus_device)
self.devices[bluez_device.address] = d

View File

@ -140,6 +140,12 @@ 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):
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):
"""
Resolve the GattServices and GattCharacteristics. This function does