diff --git a/pygatt/backends/gatttool/gatttool.py b/pygatt/backends/gatttool/gatttool.py index 81d65719..e01a7ef9 100644 --- a/pygatt/backends/gatttool/gatttool.py +++ b/pygatt/backends/gatttool/gatttool.py @@ -78,6 +78,7 @@ def __init__(self, connection, parent_aliveness): 'char_written': { 'patterns': [ r'Characteristic value (was )?written successfully', + r'Characteristic Write Request failed: A timeout occured', ] }, 'value': { @@ -425,7 +426,7 @@ def connect(self, address, timeout=DEFAULT_CONNECT_TIMEOUT_S, def clear_bond(self, address=None): """Use the 'bluetoothctl' program to erase a stored BLE bond. """ - con = pexpect.spawn('sudo bluetoothctl') + con = pexpect.spawn('bluetoothctl') try: con.expect("bluetooth", timeout=1) diff --git a/pygatt/device.py b/pygatt/device.py index ee3991eb..79bdb0fb 100644 --- a/pygatt/device.py +++ b/pygatt/device.py @@ -215,7 +215,7 @@ def subscribe(self, uuid, callback=None, indication=False): self.char_write_handle( characteristic_config_handle, properties, - wait_for_response=False + wait_for_response=True ) log.info("Subscribed to uuid=%s", uuid) self._subscribed_handlers[value_handle] = properties @@ -243,7 +243,7 @@ def unsubscribe(self, uuid): self.char_write_handle( characteristic_config_handle, properties, - wait_for_response=False + wait_for_response=True ) log.info("Unsubscribed from uuid=%s", uuid) else: @@ -315,6 +315,6 @@ def resubscribe_all(self): self.char_write_handle( characteristic_config_handle, properties, - wait_for_response=False + wait_for_response=True ) log.info("Resubscribed to uuid=%s", uuid) diff --git a/tests/gatttool/test_backend.py b/tests/gatttool/test_backend.py index 6275566f..d216f158 100644 --- a/tests/gatttool/test_backend.py +++ b/tests/gatttool/test_backend.py @@ -26,7 +26,7 @@ def rate_limited_expect(*args, **kwargs): time.sleep(0.001) # This is hacky, but we sort the event list in the GATTTool receiver # and hard code where we expect the "Connected" event to be. - return 3 + return 4 self.spawn.return_value.expect.side_effect = rate_limited_expect @@ -132,7 +132,7 @@ def rate_limited_expect_d(*args, **kwargs): def rate_limited_expect_c(*args, **kwargs): time.sleep(0.001) # hard code the "Connected" event - return 3 + return 4 address = "11:22:33:44:55:66" device = self.backend.connect(address, auto_reconnect=True)