Coverage for src / bluetooth_sig / gatt / characteristics / peripheral_privacy_flag.py: 100%
10 statements
« prev ^ index » next coverage.py v7.13.1, created at 2026-01-11 20:14 +0000
« prev ^ index » next coverage.py v7.13.1, created at 2026-01-11 20:14 +0000
1"""Peripheral Privacy Flag characteristic implementation."""
3from __future__ import annotations
5from ..context import CharacteristicContext
6from .base import BaseCharacteristic
7from .utils.data_parser import DataParser
10class PeripheralPrivacyFlagCharacteristic(BaseCharacteristic[bool]):
11 """Peripheral Privacy Flag characteristic (0x2A02).
13 org.bluetooth.characteristic.gap.peripheral_privacy_flag
15 Indicates whether privacy is enabled (True) or disabled (False).
16 """
18 def _decode_value(self, data: bytearray, ctx: CharacteristicContext | None = None) -> bool:
19 """Decode the privacy flag value."""
20 value = DataParser.parse_int8(data, 0, signed=False)
21 return bool(value)
23 def _encode_value(self, data: bool) -> bytearray:
24 """Encode the privacy flag value."""
25 return DataParser.encode_int8(1 if data else 0, signed=False)