Coverage for src / bluetooth_sig / types / protocols.py: 100%

7 statements  

« prev     ^ index     » next       coverage.py v7.13.1, created at 2026-01-11 20:14 +0000

1"""Protocol definitions for Bluetooth SIG standards.""" 

2 

3from __future__ import annotations 

4 

5from typing import Protocol 

6 

7 

8class CharacteristicProtocol(Protocol): 

9 """Protocol for characteristic validation and round-trip testing. 

10 

11 Defines the minimal interface for characteristics that support 

12 parse/encode operations without requiring full BaseCharacteristic import. 

13 Used primarily by debug utilities. 

14 """ 

15 

16 def _decode_value(self, data: bytearray) -> object: 

17 """Decode raw data into characteristic value.""" 

18 ... # pylint: disable=unnecessary-ellipsis 

19 

20 def parse_value(self, data: bytearray) -> object: 

21 """Parse raw data into characteristic value.""" 

22 ... # pylint: disable=unnecessary-ellipsis 

23 

24 def build_value(self, data: object, validate: bool = True) -> bytearray: 

25 """Encode characteristic value into raw bytes.""" 

26 ... # pylint: disable=unnecessary-ellipsis 

27 

28 def _encode_value(self, value: object) -> bytearray: 

29 """Internal encoding implementation.""" 

30 ... # pylint: disable=unnecessary-ellipsis