Skip to content

Commit

Permalink
Merge pull request #553 from zxzxwu/profiles
Browse files Browse the repository at this point in the history
Remove att.CommonErrorCode
  • Loading branch information
zxzxwu authored Sep 14, 2024
2 parents 56ca196 + dfdf370 commit 976e6cc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 16 deletions.
10 changes: 0 additions & 10 deletions bumble/att.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
# Imports
# -----------------------------------------------------------------------------
from __future__ import annotations
from bumble.utils import OpenIntEnum

import enum
import functools
Expand Down Expand Up @@ -213,15 +212,6 @@ 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
11 changes: 5 additions & 6 deletions bumble/profiles/hap.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
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
Expand Down Expand Up @@ -352,16 +351,16 @@ async def _on_read_presets_request(
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 = [
Expand All @@ -371,7 +370,7 @@ async def _on_read_presets_request(
]
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))

Expand Down Expand Up @@ -468,7 +467,7 @@ async def _on_write_preset_name(
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)
Expand Down

0 comments on commit 976e6cc

Please sign in to comment.