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

Add Published Audio Capabilities Service #356

Merged
merged 1 commit into from
Dec 2, 2023
Merged

Add Published Audio Capabilities Service #356

merged 1 commit into from
Dec 2, 2023

Conversation

zxzxwu
Copy link
Collaborator

@zxzxwu zxzxwu commented Nov 30, 2023

No description provided.

uuid=gatt.GATT_SUPPORTED_AUDIO_CONTEXTS_CHARACTERISTIC,
properties=gatt.Characteristic.Properties.READ,
permissions=gatt.Characteristic.Permissions.READABLE,
value=struct.pack('<HH', supported_sink_context, supported_source_context),
Copy link
Collaborator

Choose a reason for hiding this comment

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

NOTE (for this and other characteristics in general): if the value could potentially be changed while the characteristic is published by a server, you could use a PackedCharacteristicAdapter with a pack_format (or other type of adapter), to do the ->bytes encoding on the fly as the characteristic is read.

def __init__(self, service_proxy: gatt_client.ServiceProxy):
self.service_proxy = service_proxy

self.available_audio_contexts = service_proxy.get_characteristics_by_uuid(
Copy link
Collaborator

Choose a reason for hiding this comment

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

A future enhancement here would be to provide an adapter to convert the raw bytes into the actual fields (in this case here, I think available_audio_contexts get split into available_sink_context and available_source_context fields. Either a PackedCharacteristicAdapter or MappedCharacteristicAdapter or some other type of adapter would do that automatically (see battery_service.py or header_rate_service.py for examples).

@zxzxwu zxzxwu merged commit 73dbdff into google:main Dec 2, 2023
51 checks passed
@zxzxwu zxzxwu deleted the bap branch December 2, 2023 15:37
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.

2 participants