Skip to content

Commit

Permalink
v0.2.24: raise NotFitnessMachine from get_client_from_address
Browse files Browse the repository at this point in the history
  • Loading branch information
dudanov committed Aug 11, 2024
1 parent 8e0ac52 commit 643a887
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
12 changes: 9 additions & 3 deletions pyftms/client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# SPDX-License-Identifier: Apache-2.0

import asyncio
import logging

from bleak import BleakScanner
from bleak.backends.device import BLEDevice
Expand Down Expand Up @@ -32,6 +33,8 @@
get_machine_type_from_service_data,
)

_LOGGER = logging.getLogger(__name__)


def get_client(
ble_device: BLEDevice,
Expand Down Expand Up @@ -95,6 +98,8 @@ async def get_client_from_address(
- `FitnessMachine` instance if device found successfully.
"""

_exc = None

async with BleakScanner() as scanner:
try:
async with asyncio.timeout(scan_timeout):
Expand All @@ -111,13 +116,14 @@ async def get_client_from_address(
on_disconnect=on_disconnect,
)

except NotFitnessMachineError:
pass
except NotFitnessMachineError as e:
_exc = e
_LOGGER.debug("Advertisement data has no valid FTMS data.")

except asyncio.TimeoutError:
pass

raise BleakDeviceNotFoundError(address)
raise _exc or BleakDeviceNotFoundError(address)


__all__ = [
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "pyftms"
version = "0.2.23"
version = "0.2.24"
description = "PyFTMS - Python Fitness Machine Service client library."
authors = ["Sergey V. DUDANOV <[email protected]>"]
readme = "README.md"
Expand Down

0 comments on commit 643a887

Please sign in to comment.