Skip to content

Commit

Permalink
fix: do not try to stop notify if read char is missing (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco authored Sep 25, 2023
1 parent abc0ccb commit 03c84f9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ repos:
- id: pyupgrade
args: [--py37-plus]
- repo: https://github.com/PyCQA/isort
rev: 5.10.1
rev: 5.12.0
hooks:
- id: isort
- repo: https://github.com/psf/black
Expand Down
8 changes: 7 additions & 1 deletion src/led_ble/led_ble.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,13 @@ async def _execute_disconnect(self) -> None:
self._read_char = None
self._write_char = None
if client and client.is_connected:
await client.stop_notify(read_char)
if read_char:
try:
await client.stop_notify(read_char)
except BleakError:
_LOGGER.debug(
"%s: Failed to stop notifications", self.name, exc_info=True
)
await client.disconnect()

@retry_bluetooth_connection_error(DEFAULT_ATTEMPTS)
Expand Down

0 comments on commit 03c84f9

Please sign in to comment.