mirror of
https://github.com/google/bumble.git
synced 2026-05-08 03:58:01 +00:00
Remove att.CommonErrorCode
This commit is contained in:
@@ -23,7 +23,6 @@
|
|||||||
# Imports
|
# Imports
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
from bumble.utils import OpenIntEnum
|
|
||||||
|
|
||||||
import enum
|
import enum
|
||||||
import functools
|
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
|
# 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
|
# Exceptions
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ from __future__ import annotations
|
|||||||
import asyncio
|
import asyncio
|
||||||
import functools
|
import functools
|
||||||
from bumble import att, gatt, gatt_client
|
from bumble import att, gatt, gatt_client
|
||||||
from bumble.att import CommonErrorCode
|
|
||||||
from bumble.core import InvalidArgumentError, InvalidStateError
|
from bumble.core import InvalidArgumentError, InvalidStateError
|
||||||
from bumble.device import Device, Connection
|
from bumble.device import Device, Connection
|
||||||
from bumble.utils import AsyncRunner, OpenIntEnum
|
from bumble.utils import AsyncRunner, OpenIntEnum
|
||||||
@@ -352,16 +351,16 @@ class HearingAccessService(gatt.TemplateService):
|
|||||||
logging.warning(f'HAS require MTU >= 49: {connection}')
|
logging.warning(f'HAS require MTU >= 49: {connection}')
|
||||||
|
|
||||||
if self.read_presets_request_in_progress:
|
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
|
self.read_presets_request_in_progress = True
|
||||||
|
|
||||||
start_index = value[1]
|
start_index = value[1]
|
||||||
if start_index == 0x00:
|
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]
|
num_presets = value[2]
|
||||||
if num_presets == 0x00:
|
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
|
# Sending `num_presets` presets ordered by increasing index field, starting from start_index
|
||||||
presets = [
|
presets = [
|
||||||
@@ -371,7 +370,7 @@ class HearingAccessService(gatt.TemplateService):
|
|||||||
]
|
]
|
||||||
del presets[num_presets:]
|
del presets[num_presets:]
|
||||||
if len(presets) == 0:
|
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))
|
AsyncRunner.spawn(self._read_preset_response(connection, presets))
|
||||||
|
|
||||||
@@ -468,7 +467,7 @@ class HearingAccessService(gatt.TemplateService):
|
|||||||
assert connection
|
assert connection
|
||||||
|
|
||||||
if self.read_presets_request_in_progress:
|
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]
|
index = value[1]
|
||||||
preset = self.preset_records.get(index, None)
|
preset = self.preset_records.get(index, None)
|
||||||
|
|||||||
Reference in New Issue
Block a user