Merge pull request #553 from zxzxwu/profiles

Remove att.CommonErrorCode
This commit is contained in:
zxzxwu
2024-09-14 18:12:27 +08:00
committed by GitHub
2 changed files with 5 additions and 16 deletions

View File

@@ -23,7 +23,6 @@
# Imports
# -----------------------------------------------------------------------------
from __future__ import annotations
from bumble.utils import OpenIntEnum
import enum
import functools
@@ -213,15 +212,6 @@ UUID_2_FIELD_SPEC = lambda x, y: UUID.parse_uuid_2(x, y) # noqa: E731
# 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
# -----------------------------------------------------------------------------

View File

@@ -19,7 +19,6 @@ from __future__ import annotations
import asyncio
import functools
from bumble import att, gatt, gatt_client
from bumble.att import CommonErrorCode
from bumble.core import InvalidArgumentError, InvalidStateError
from bumble.device import Device, Connection
from bumble.utils import AsyncRunner, OpenIntEnum
@@ -352,16 +351,16 @@ class HearingAccessService(gatt.TemplateService):
logging.warning(f'HAS require MTU >= 49: {connection}')
if self.read_presets_request_in_progress:
raise att.ATT_Error(CommonErrorCode.PROCEDURE_ALREADY_IN_PROGRESS)
raise att.ATT_Error(att.ErrorCode.PROCEDURE_ALREADY_IN_PROGRESS)
self.read_presets_request_in_progress = True
start_index = value[1]
if start_index == 0x00:
raise att.ATT_Error(CommonErrorCode.OUT_OF_RANGE)
raise att.ATT_Error(att.ErrorCode.OUT_OF_RANGE)
num_presets = value[2]
if num_presets == 0x00:
raise att.ATT_Error(CommonErrorCode.OUT_OF_RANGE)
raise att.ATT_Error(att.ErrorCode.OUT_OF_RANGE)
# Sending `num_presets` presets ordered by increasing index field, starting from start_index
presets = [
@@ -371,7 +370,7 @@ class HearingAccessService(gatt.TemplateService):
]
del presets[num_presets:]
if len(presets) == 0:
raise att.ATT_Error(CommonErrorCode.OUT_OF_RANGE)
raise att.ATT_Error(att.ErrorCode.OUT_OF_RANGE)
AsyncRunner.spawn(self._read_preset_response(connection, presets))
@@ -468,7 +467,7 @@ class HearingAccessService(gatt.TemplateService):
assert connection
if self.read_presets_request_in_progress:
raise att.ATT_Error(CommonErrorCode.PROCEDURE_ALREADY_IN_PROGRESS)
raise att.ATT_Error(att.ErrorCode.PROCEDURE_ALREADY_IN_PROGRESS)
index = value[1]
preset = self.preset_records.get(index, None)