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

Implement Hap support #532

Merged
merged 34 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
1f3bc2c
Implement Hap support
wescande Aug 8, 2024
a315772
Address zxzxwu comments
wescande Aug 13, 2024
6d0b345
rewrite after meeting with barbibulle
wescande Aug 13, 2024
37a4167
remove staticmethod
wescande Aug 14, 2024
35bac95
read_preset_response : forgot to remove preset after sending it
wescande Aug 14, 2024
1e1fc68
Initialize value & cleanup unused
wescande Aug 14, 2024
21c2b1c
Make it compile in Android
wescande Aug 19, 2024
ea83f2f
Apply suggestion to manage async handler and event
wescande Aug 19, 2024
5d6e8cd
Add run_hap_server example
wescande Aug 21, 2024
e656e2a
Properly write preset changed operation to bytes
wescande Aug 22, 2024
6dacb4b
HAP: assert preset name at service creation
wescande Aug 22, 2024
4b92cac
Enforce default mtu is at lest 49 when doing HAS
wescande Aug 22, 2024
d3d7b8d
minor renaming of has internal variable
wescande Aug 22, 2024
5e9ed8e
Always return a type
wescande Aug 27, 2024
ea27442
raise InvalidArgumentError instead of generic assert
wescande Aug 27, 2024
8c2e72c
Raise bubmle error and apply formatter
wescande Aug 27, 2024
2871d1c
Read_preset, add documentation and use for loop
wescande Aug 27, 2024
a9ac5ff
run formatter
wescande Aug 27, 2024
9bcbc53
preset_op_changed: correctly handle device disconnection
wescande Aug 27, 2024
fe0ffe4
Remove some TODO and apply formatter
wescande Aug 27, 2024
3cdea13
User peer_address of the local address
wescande Aug 28, 2024
f3483ec
Stop asserting device MTU
wescande Aug 28, 2024
d88d73d
Add MTU log warning in read_preset
wescande Aug 28, 2024
c0ad2d6
Add unit tests
wescande Aug 29, 2024
c7a4c71
remove some logging and apply format
wescande Aug 29, 2024
c2d1f59
silence some type misalignement
wescande Sep 6, 2024
034ed03
Fix read_active_preset_index and set_next_preset test
wescande Sep 6, 2024
112eb97
fix setactivepreset and implement more tests
wescande Sep 6, 2024
df3e231
Merge branch 'google:main' into main
wescande Sep 9, 2024
a7d2f85
test trying to set unavailable preset
wescande Sep 9, 2024
8d3967f
format file
wescande Sep 9, 2024
e99378e
Fix 3.8 compatibility
wescande Sep 9, 2024
0c7b6b9
apply format -_-
wescande Sep 9, 2024
e2c4716
remove log_cli in test
wescande Sep 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions bumble/att.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
# Imports
# -----------------------------------------------------------------------------
from __future__ import annotations
from bumble.utils import OpenIntEnum

import enum
import functools
import inspect
Expand Down Expand Up @@ -211,6 +213,15 @@ class ErrorCode(utils.OpenIntEnum):
# pylint: disable=invalid-name


class CommonErrorCode(OpenIntEnum):
'''See Supplement to the Bluetooth Code Specification 1.2 List of Error Codes.'''

WRITE_REQUEST_REJECTED = 0xFC
CLIENT_CHARACTERISTIC_CONFIGURATION_DESCRIPTOR_IMPROPERLY_CONFIGURED = 0xFD
PROCEDURE_ALREADY_IN_PROGRESS = 0xFE
OUT_OF_RANGE = 0xFF


# -----------------------------------------------------------------------------
# Exceptions
# -----------------------------------------------------------------------------
Expand Down
5 changes: 5 additions & 0 deletions bumble/gatt.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,11 @@
GATT_AVAILABLE_AUDIO_CONTEXTS_CHARACTERISTIC = UUID.from_16_bits(0x2BCD, 'Available Audio Contexts')
GATT_SUPPORTED_AUDIO_CONTEXTS_CHARACTERISTIC = UUID.from_16_bits(0x2BCE, 'Supported Audio Contexts')

# Hearing Access Service
GATT_HEARING_AID_FEATURES_CHARACTERISTIC = UUID.from_16_bits(0x2BDA, 'Hearing Aid Features')
GATT_HEARING_AID_PRESET_CONTROL_POINT_CHARACTERISTIC = UUID.from_16_bits(0x2BDB, 'Hearing Aid Preset Control Point')
GATT_ACTIVE_PRESET_INDEX_CHARACTERISTIC = UUID.from_16_bits(0x2BDC, 'Active Preset Index')

# ASHA Service
GATT_ASHA_SERVICE = UUID.from_16_bits(0xFDF0, 'Audio Streaming for Hearing Aid')
GATT_ASHA_READ_ONLY_PROPERTIES_CHARACTERISTIC = UUID('6333651e-c481-4a3e-9169-7c902aad37bb', 'ReadOnlyProperties')
Expand Down
2 changes: 1 addition & 1 deletion bumble/gatt_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -915,7 +915,7 @@ async def on_att_write_request(self, connection, request):
See Bluetooth spec Vol 3, Part F - 3.4.5.1 Write Request
'''

# Check that the attribute exists
# Check that the attribute exists
attribute = self.get_attribute(request.attribute_handle)
if attribute is None:
self.send_response(
Expand Down
Loading
Loading