Coverage for src / bluetooth_sig / gatt / characteristics / reconnection_configuration_control_point.py: 100%
49 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"""Reconnection Configuration Control Point characteristic (0x2B1F).
3Control point for executing procedures on the Reconnection Configuration
4server, including parameter negotiation and connection management.
6References:
7 Bluetooth SIG Reconnection Configuration Service v1.0.1, Section 3.3
8"""
10from __future__ import annotations
12from enum import IntEnum
14import msgspec
16from ..context import CharacteristicContext
17from .base import BaseCharacteristic
18from .utils import DataParser
21class RCCPOpCode(IntEnum):
22 """RCCP opcodes as per RCS v1.0.1 Table 3.7."""
24 ENABLE_DISCONNECT = 0x00
25 GET_ACTUAL_COMMUNICATION_PARAMETERS = 0x01
26 PROPOSE_SETTINGS = 0x02
27 ACTIVATE_STORED_SETTINGS = 0x03
28 GET_MAX_VALUES = 0x04
29 GET_MIN_VALUES = 0x05
30 GET_STORED_VALUES = 0x06
31 SET_FILTER_ACCEPT_LIST_TIMER = 0x07
32 GET_FILTER_ACCEPT_LIST_TIMER = 0x08
33 SET_ADVERTISEMENT_CONFIGURATION = 0x09
34 UPGRADE_TO_LESC_ONLY = 0x0A
35 SWITCH_OOB_PAIRING = 0x0B
36 LIMITED_ACCESS = 0x0C
37 PROCEDURE_RESPONSE = 0x0E
38 COMMUNICATION_PARAMETER_RESPONSE = 0x0F
39 FILTER_ACCEPT_LIST_TIMER_RESPONSE = 0x10
40 CLIENT_PARAMETER_INDICATION = 0x11
43class RCCPResultCode(IntEnum):
44 """RCCP result codes as per RCS v1.0.1 Table 3.10."""
46 SUCCESS = 0x01
47 OPCODE_NOT_SUPPORTED = 0x02
48 INVALID_OPERAND = 0x03
49 OPERATION_FAILED = 0x04
50 COMMUNICATION_PARAMETER_OUT_OF_RANGE = 0x05
51 INVALID_PARAMETER_COMBINATION = 0x06
52 DEVICE_BUSY = 0x07
53 COMMUNICATION_PARAMETERS_REJECTED = 0x08
54 PROPOSAL_ACCEPTED = 0x09
57class ReconnectionConfigurationControlPointData(msgspec.Struct, frozen=True, kw_only=True):
58 """Parsed data from Reconnection Configuration Control Point.
60 Attributes:
61 op_code: The RCCP opcode identifying the procedure.
62 parameter: Raw operand/parameter bytes (None if absent).
64 """
66 op_code: RCCPOpCode
67 parameter: bytes | None = None
70class ReconnectionConfigurationControlPointCharacteristic(
71 BaseCharacteristic[ReconnectionConfigurationControlPointData],
72):
73 """Reconnection Configuration Control Point characteristic (0x2B1F).
75 org.bluetooth.characteristic.reconnection_configuration_control_point
77 Structure: Opcode (uint8) + Operand (0-17 octets) + [E2E-CRC (uint16)].
78 E2E-CRC is conditionally present when E2E-CRC Supported is set in RC Feature.
79 """
81 min_length = 1
82 allow_variable_length = True
84 def _decode_value(
85 self, data: bytearray, ctx: CharacteristicContext | None = None, *, validate: bool = True
86 ) -> ReconnectionConfigurationControlPointData:
87 """Parse RCCP data per RCS v1.0.1 Section 3.3."""
88 op_code = RCCPOpCode(DataParser.parse_int8(data, 0, signed=False))
89 parameter = bytes(data[1:]) if len(data) > 1 else None
91 return ReconnectionConfigurationControlPointData(
92 op_code=op_code,
93 parameter=parameter,
94 )
96 def _encode_value(self, data: ReconnectionConfigurationControlPointData) -> bytearray:
97 """Encode RCCP data."""
98 result = bytearray([int(data.op_code)])
99 if data.parameter is not None:
100 result.extend(data.parameter)
101 return result