Coverage for src / bluetooth_sig / gatt / characteristics / plx_features.py: 100%
23 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"""PLX Features characteristic implementation."""
3from __future__ import annotations
5from enum import IntFlag
7from bluetooth_sig.gatt.context import CharacteristicContext
9from .base import BaseCharacteristic
10from .utils import DataParser
13class PLXFeatureFlags(IntFlag):
14 """PLX Features flags per Bluetooth SIG specification.
16 Spec: Bluetooth SIG Assigned Numbers, PLX Features characteristic
17 """
19 MEASUREMENT_STATUS_SUPPORT = 0x0001
20 DEVICE_AND_SENSOR_STATUS_SUPPORT = 0x0002
21 MEASUREMENT_STORAGE_SUPPORT = 0x0004
22 TIMESTAMP_SUPPORT = 0x0008
23 SPO2PR_FAST_SUPPORT = 0x0010
24 SPO2PR_SLOW_SUPPORT = 0x0020
25 PULSE_AMPLITUDE_INDEX_SUPPORT = 0x0040
26 MULTIPLE_BONDS_SUPPORT = 0x0080
27 # Bits 8-15 are reserved for future use
30class PLXFeaturesCharacteristic(BaseCharacteristic[PLXFeatureFlags]):
31 """PLX Features characteristic (0x2A60).
33 Describes the supported features of a pulse oximeter device.
34 Returns a 16-bit feature flags value.
36 Spec: Bluetooth SIG Assigned Numbers, PLX Features characteristic
37 """
39 expected_length: int | None = 2
41 def _decode_value(self, data: bytearray, ctx: CharacteristicContext | None = None) -> PLXFeatureFlags:
42 """Decode PLX features from raw bytes.
44 Args:
45 data: Raw bytes from BLE characteristic (2 bytes)
46 ctx: Unused, for signature compatibility
48 Returns:
49 PLXFeatureFlags enum with supported features
51 """
52 del ctx # Unused parameter
54 raw_value = DataParser.parse_int16(data, 0, signed=False)
55 return PLXFeatureFlags(raw_value)
57 def _encode_value(self, data: PLXFeatureFlags | int) -> bytearray:
58 """Encode PLX features to bytes.
60 Args:
61 data: PLXFeatureFlags enum or 16-bit feature flags as integer
63 Returns:
64 Encoded bytes (2 bytes, little-endian)
66 """
67 value = data.value if isinstance(data, PLXFeatureFlags) else data
68 return DataParser.encode_int16(value, signed=False)