Add Bodytone DU30-B1D8 Fitness Bike#67
Open
netsoft-ruidias wants to merge 3 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds a GATT-based fallback to FTMS discovery so devices that advertise the FTMS service but omit machine type service data can still be identified.
Changes:
- Adds
get_machine_type_from_gattto infer machine type from FTMS data characteristics. - Uses the new helper as a fallback during
discover_ftms_devices. - Exports the helper from the properties package and imports it into the client package.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
src/pyftms/client/properties/machine_type.py |
Adds GATT characteristic-based machine type detection. |
src/pyftms/client/properties/__init__.py |
Re-exports the new GATT detection helper. |
src/pyftms/client/__init__.py |
Adds discovery fallback logic that connects to devices lacking machine type service data. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+124
to
+130
| async with BleakClient( | ||
| dev, services=[FTMS_UUID] | ||
| ) as cli: | ||
| machine_type = await get_machine_type_from_gatt( | ||
| cli | ||
| ) | ||
| except (BleakError, NotFitnessMachineError, OSError): |
Comment on lines
+130
to
+136
| except (BleakError, NotFitnessMachineError, OSError): | ||
| _LOGGER.debug( | ||
| "Could not determine machine type for '%s' " | ||
| "via GATT fallback.", | ||
| dev.address, | ||
| ) | ||
| continue |
| if cli.services.get_characteristic(uuid) is not None: | ||
| return machine_type | ||
|
|
||
| raise NotFitnessMachineError() |
Comment on lines
+13
to
+15
| MachineType, | ||
| get_machine_type_from_gatt, | ||
| get_machine_type_from_service_data |
| from bleak.backends.device import BLEDevice | ||
| from bleak.backends.scanner import AdvertisementData | ||
| from bleak.exc import BleakDeviceNotFoundError | ||
| from bleak.exc import BleakError, BleakDeviceNotFoundError |
Comment on lines
+13
to
+15
| MachineType, | ||
| get_machine_type_from_gatt, | ||
| get_machine_type_from_service_data |
| from bleak.backends.device import BLEDevice | ||
| from bleak.backends.scanner import AdvertisementData | ||
| from bleak.exc import BleakDeviceNotFoundError | ||
| from bleak.exc import BleakError, BleakDeviceNotFoundError |
Comment on lines
126
to
+131
| except NotFitnessMachineError: | ||
| continue | ||
| # The device advertises the FTMS service UUID but does | ||
| # not include machine type in its service data (e.g. | ||
| # Bodytone DU30). Fall back to GATT characteristic | ||
| # inspection by briefly connecting to the device. | ||
| try: |
| if cli.services.get_characteristic(uuid) is not None: | ||
| return machine_type | ||
|
|
||
| raise NotFitnessMachineError() |
Comment on lines
+131
to
+134
| try: | ||
| async with BleakClient( | ||
| dev, services=[FTMS_UUID] | ||
| ) as cli: |
| # advertise the FTMS UUID in service_uuids but provide no service data, so | ||
| # they would be silently dropped. We therefore scan for all BLE devices | ||
| # and filter manually. | ||
| async with BleakScanner(**kwargs) as scanner: |
Author
|
Discovery result: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request improves the ability of the FTMS device discovery process to correctly identify machine types, especially for devices that do not advertise their type in service data. The main enhancement is a fallback mechanism that inspects GATT characteristics if the machine type cannot be determined from advertisement data. Additionally, the new utility function for GATT-based type detection has been added and exported for broader use.
Enhancements to FTMS device discovery:
discover_ftms_devicesto determine machine type by connecting to the device and inspecting its GATT characteristics when service data is insufficient. This increases compatibility with devices like the Bodytone DU30 that do not include machine type in their advertisements.New utility for machine type detection:
get_machine_type_from_gatt, an async function that determines the fitness machine type by checking for known FTMS data characteristics on a connected device.get_machine_type_from_gattin bothsrc/pyftms/client/properties/__init__.pyandsrc/pyftms/client/__init__.pyfor use elsewhere in the codebase. [1] [2]Dependency and import updates:
BleakClient,BleakError, and the new utility function, ensuring all necessary components are available for the new fallback logic. [1] [2]