Coverage for src / bluetooth_sig / gatt / characteristics / report_map.py: 100%
12 statements
« prev ^ index » next coverage.py v7.13.5, created at 2026-04-03 16:41 +0000
« prev ^ index » next coverage.py v7.13.5, created at 2026-04-03 16:41 +0000
1"""Report Map characteristic implementation."""
3from __future__ import annotations
5import msgspec
7from ..context import CharacteristicContext
8from .base import BaseCharacteristic
11class ReportMapData(msgspec.Struct, frozen=True):
12 """Parsed data from Report Map characteristic.
14 Attributes:
15 data: Report map data bytes (up to 512 octets)
16 """
18 data: bytes
21class ReportMapCharacteristic(BaseCharacteristic[ReportMapData]):
22 """Report Map characteristic (0x2A4B).
24 org.bluetooth.characteristic.report_map
26 Report Map characteristic.
27 """
29 min_length = 1
31 def _decode_value(
32 self, data: bytearray, ctx: CharacteristicContext | None = None, *, validate: bool = True
33 ) -> ReportMapData:
34 """Parse report map data.
36 Args:
37 data: Raw bytearray from BLE characteristic.
38 ctx: Optional context.
39 validate: Whether to validate ranges (default True)
41 Returns:
42 ReportMapData containing the report map bytes.
43 """
44 return ReportMapData(data=bytes(data))
46 def _encode_value(self, data: ReportMapData) -> bytearray:
47 """Encode report map back to bytes.
49 Args:
50 data: ReportMapData instance to encode
52 Returns:
53 Encoded bytes
54 """
55 return bytearray(data.data)