Coverage for src / bluetooth_sig / gatt / characteristics / search_results_object_id.py: 100%

16 statements  

« prev     ^ index     » next       coverage.py v7.13.5, created at 2026-04-03 16:41 +0000

1"""Search Results Object ID characteristic (0x2BA6).""" 

2 

3from __future__ import annotations 

4 

5from ...types.gatt_enums import CharacteristicRole 

6from ..constants import UINT48_MAX 

7from ..context import CharacteristicContext 

8from .base import BaseCharacteristic 

9from .utils import DataParser 

10 

11 

12class SearchResultsObjectIdCharacteristic(BaseCharacteristic[int]): 

13 """Search Results Object ID characteristic (0x2BA6). 

14 

15 org.bluetooth.characteristic.search_results_object_id 

16 

17 OTS object ID for the search results. 

18 """ 

19 

20 _manual_role = CharacteristicRole.INFO 

21 expected_length: int = 6 

22 min_length: int = 6 

23 min_value = 0 

24 max_value = UINT48_MAX 

25 

26 def _decode_value(self, data: bytearray, ctx: CharacteristicContext | None = None, *, validate: bool = True) -> int: 

27 """Parse search results object ID (uint48).""" 

28 return DataParser.parse_int48(data, 0, signed=False) 

29 

30 def _encode_value(self, data: int) -> bytearray: 

31 """Encode search results object ID to bytes.""" 

32 return DataParser.encode_int48(data, signed=False)