From c676d09ba29281c287f381ed5ff53cec758a6a2f Mon Sep 17 00:00:00 2001 From: Andrey Pohilko Date: Mon, 30 Jul 2018 12:31:22 +0300 Subject: [PATCH] Fixups after testing --- pylgbst/comms_gatt.py | 5 ++++- pylgbst/comms_pygatt.py | 2 +- tests/test_gatt.py | 6 +++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/pylgbst/comms_gatt.py b/pylgbst/comms_gatt.py index a808ffe..7e676c0 100644 --- a/pylgbst/comms_gatt.py +++ b/pylgbst/comms_gatt.py @@ -81,7 +81,10 @@ class GattConnection(Connection): self._iface = bt_iface_name def connect(self, hub_mac=None): - dev_manager = gatt.DeviceManager(adapter_name=self._iface) + try: + dev_manager = gatt.DeviceManager(adapter_name=self._iface) + except TypeError: + raise NotImplementedError("Gatt is not implemented for this platform") dman_thread = threading.Thread(target=dev_manager.run) dman_thread.setDaemon(True) log.debug('Starting DeviceManager...') diff --git a/pylgbst/comms_pygatt.py b/pylgbst/comms_pygatt.py index ca11f0b..bb91088 100644 --- a/pylgbst/comms_pygatt.py +++ b/pylgbst/comms_pygatt.py @@ -58,4 +58,4 @@ class GattoolConnection(Connection): class BlueGigaConnection(GattoolConnection): def __init__(self): super(BlueGigaConnection, self).__init__() - self.backend = lambda: pygatt.GATTToolBackend() + self.backend = lambda: pygatt.BGAPIBackend() diff --git a/tests/test_gatt.py b/tests/test_gatt.py index 91a5b01..045ace4 100644 --- a/tests/test_gatt.py +++ b/tests/test_gatt.py @@ -4,7 +4,7 @@ import unittest import dbus from gatt import DeviceManager -from pylgbst.comms_gatt import CustomDevice +from pylgbst.comms_gatt import CustomDevice, GattConnection from tests import log, str2hex @@ -41,3 +41,7 @@ class TestGatt(unittest.TestCase): "dbus.Byte(0), dbus.Byte(0), dbus.Byte(0), dbus.Byte(0), dbus.Byte(16), dbus.Byte(0), dbus.Byte(0), " \ "dbus.Byte(0), dbus.Byte(16)], signature=dbus.Signature('y'), variant_level=1)" obj.characteristic_value_updated(None, arr if sys.version_info[0] == 2 else bytes(arr, 'ascii')) + + def test_conn(self): + obj = GattConnection() + obj.connect()