Coverage for src / bluetooth_sig / gatt / characteristics / alert_level.py: 100%

12 statements  

« prev     ^ index     » next       coverage.py v7.13.1, created at 2026-01-11 20:14 +0000

1"""Alert Level characteristic implementation.""" 

2 

3from __future__ import annotations 

4 

5from enum import IntEnum 

6 

7from .base import BaseCharacteristic 

8from .templates import EnumTemplate 

9 

10 

11class AlertLevel(IntEnum): 

12 """Alert level values as defined by Bluetooth SIG. 

13 

14 Values: 

15 NO_ALERT: No alert (0x00) 

16 MILD_ALERT: Mild alert (0x01) 

17 HIGH_ALERT: High alert (0x02) 

18 """ 

19 

20 NO_ALERT = 0x00 

21 MILD_ALERT = 0x01 

22 HIGH_ALERT = 0x02 

23 

24 

25class AlertLevelCharacteristic(BaseCharacteristic[int]): 

26 """Alert Level characteristic (0x2A06). 

27 

28 org.bluetooth.characteristic.alert_level 

29 

30 The Alert Level characteristic defines the level of alert and is 

31 used by services such as Immediate Alert (0x1802), Link Loss (0x1803), 

32 and Phone Alert Status (0x180E). 

33 

34 Valid values: 

35 - 0x00: No Alert 

36 - 0x01: Mild Alert 

37 - 0x02: High Alert 

38 - 0x03-0xFF: Reserved for Future Use 

39 

40 Spec: Bluetooth SIG GATT Specification Supplement, Alert Level 

41 """ 

42 

43 _template = EnumTemplate.uint8(AlertLevel) 

44 

45 # YAML has no range constraint; enforce valid enum bounds. 

46 min_value: int = AlertLevel.NO_ALERT # 0 

47 max_value: int = AlertLevel.HIGH_ALERT # 2