Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make services direct references and match properties for I/O #238

Merged
merged 5 commits into from
Feb 4, 2022

Conversation

twyatt
Copy link
Member

@twyatt twyatt commented Jan 6, 2022

Inspired by #128.

Previously, all I/O operations would lazily search for the first match when looking up characteristics or descriptors. This was problematic if duplicate UUIDs existed. Discovered GATT profile items (services, characteristics and descriptors) as provided via Peripheral.services now hold direct references to underlying platform types. This means they no longer trigger lookups for I/O operations and specific GATT profile items can be manually sought after and used.

When using characteristicOf (which is still a lazy lookup), the properties of the characteristic are now taken into account when searching for the underlying platform object (this will allow support for duplicate UUIDs assuming they differ by the appropriate properties). For example, when performing a read, only a characteristic with a matching UUID and read property will be considered a match.

This PR implements a "more correct" behavior for characteristic lookups (when using characteristicOf) but is a potentially breaking change (at runtime) for some users. If a library consumer has a peripheral with characteristics with incorrect (or missing) properties, then they may have been relying on characteristicOf to match the first one found with the same UUID, but this PR may make it so that when lazily looking up the characteristic, it is no longer found if the peripheral's characteristic is not setup with the appropriate properties. In this case, these users should either update the firmware on the peripheral to have correct properties, or manually traverse the Peripheral.services in order to perform I/O on the characteristic they were using before.

Updated documentation can be read here.

Closes #127
Closes #93

Previously, all I/O operations would lazily search for the first match
when looking up characteristics or descriptors. This was problematic if
duplicate UUIDs existed. Discovered GATT profile items (services,
characteristics and descriptors) as provided via `Peripheral.services`
are now direct references to underlying platform types. This means they
no longer trigger lookups for I/O operations and specific GATT profile
items can be sought after and used.

When using `characteristicOf`, the properties of the characteristic are
now taken into account when searching for the underlying platform
object. For example, when performing a read, only a characteristic with
a matching UUID **and** `read` property will be considered a match.
Copy link
Contributor

@davertay-j davertay-j left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@twyatt twyatt modified the milestones: 0.12.0, 0.13.0 Jan 12, 2022
@twyatt twyatt merged commit 941c8ad into main Feb 4, 2022
@twyatt twyatt deleted the twyatt/profile branch February 4, 2022 06:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Characteristics with duplicating UUIDs are not supported Services with the same UUIDs
3 participants