Coverage for src/bluetooth_sig/gatt/characteristics/ringer_control_point.py: 92%

13 statements  

« prev     ^ index     » next       coverage.py v7.11.0, created at 2025-10-30 00:10 +0000

1"""Ringer Control Point characteristic implementation.""" 

2 

3from __future__ import annotations 

4 

5from enum import IntEnum 

6 

7import msgspec 

8 

9from .base import BaseCharacteristic 

10 

11 

12class RingerControlCommand(IntEnum): 

13 """Ringer Control Point command values.""" 

14 

15 SILENT_MODE = 1 

16 MUTE_ONCE = 2 

17 CANCEL_SILENT_MODE = 3 

18 

19 

20class RingerControlPointData(msgspec.Struct, frozen=True, kw_only=True): # pylint: disable=too-few-public-methods 

21 """Data for Ringer Control Point characteristic commands.""" 

22 

23 command: RingerControlCommand 

24 

25 

26class RingerControlPointCharacteristic(BaseCharacteristic): 

27 """Ringer Control Point characteristic (0x2A40). 

28 

29 org.bluetooth.characteristic.ringer_control_point 

30 

31 The Ringer Control Point characteristic defines the Control Point of Ringer. 

32 This is a write-only characteristic used to control ringer behavior. 

33 

34 Commands: 

35 - 1: Silent Mode (sets ringer to silent) 

36 - 2: Mute Once (silences ringer once) 

37 - 3: Cancel Silent Mode (sets ringer to normal) 

38 - 0, 4-255: Reserved for future use 

39 """ 

40 

41 def encode_value(self, data: RingerControlPointData) -> bytearray: 

42 """Encode RingerControlPointData command to bytes. 

43 

44 Args: 

45 data: RingerControlPointData instance to encode 

46 

47 Returns: 

48 Encoded bytes representing the ringer control command 

49 

50 """ 

51 return bytearray([data.command.value]) 

52 

53 # Note: This characteristic is write-only, so decode_value is not implemented 

54 # Reading this characteristic is not supported per Bluetooth SIG specification