Coverage for src / bluetooth_sig / device / protocols.py: 100%
17 statements
« prev ^ index » next coverage.py v7.13.5, created at 2026-03-18 11:17 +0000
« prev ^ index » next coverage.py v7.13.5, created at 2026-03-18 11:17 +0000
1"""Protocol definitions for the device subsystem."""
3from __future__ import annotations
5from abc import abstractmethod
6from typing import Any, Protocol
8from ..gatt.characteristics import CharacteristicName
9from ..gatt.context import CharacteristicContext
10from ..gatt.services import ServiceName
11from ..types.uuid import BluetoothUUID
14class SIGTranslatorProtocol(Protocol): # pylint: disable=too-few-public-methods
15 """Protocol for SIG translator interface."""
17 @abstractmethod
18 def parse_characteristics(
19 self,
20 char_data: dict[str, bytes],
21 ctx: CharacteristicContext | None = None,
22 ) -> dict[str, Any]:
23 """Parse multiple characteristics at once."""
25 @abstractmethod
26 def parse_characteristic(
27 self,
28 uuid: str,
29 raw_data: bytes,
30 ctx: CharacteristicContext | None = None,
31 ) -> Any: # noqa: ANN401 # Runtime UUID dispatch cannot be type-safe
32 """Parse a single characteristic's raw bytes."""
34 @abstractmethod
35 def get_characteristic_uuid_by_name(self, name: CharacteristicName) -> BluetoothUUID | None:
36 """Get the UUID for a characteristic name enum (enum-only API)."""
38 @abstractmethod
39 def get_service_uuid_by_name(self, name: str | ServiceName) -> BluetoothUUID | None:
40 """Get the UUID for a service name or enum."""
42 def get_characteristic_info_by_name(self, name: CharacteristicName) -> Any | None: # noqa: ANN401 # Adapter-specific characteristic info
43 """Get characteristic info by enum name (optional method)."""