Skip to content

Commit

Permalink
Merge pull request #236 from peplin/pr/234
Browse files Browse the repository at this point in the history
Merged version of #234
  • Loading branch information
peplin authored Apr 5, 2019
2 parents 4e0aa6b + b8c70ef commit 8caaa96
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
3 changes: 2 additions & 1 deletion pygatt/backends/gatttool/gatttool.py
Original file line number Diff line number Diff line change
Expand Up @@ -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': {
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions pygatt/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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)
4 changes: 2 additions & 2 deletions tests/gatttool/test_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 8caaa96

Please sign in to comment.