Coverage for src / bluetooth_sig / types / alert.py: 100%

44 statements  

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

1"""Alert Notification types and enumerations. 

2 

3Provides common types used across Alert Notification Service characteristics. 

4Based on Bluetooth SIG GATT Specification for Alert Notification Service (0x1811). 

5""" 

6 

7from __future__ import annotations 

8 

9from enum import IntEnum, IntFlag 

10 

11# Alert Category ID value ranges 

12ALERT_CATEGORY_DEFINED_MAX = 9 # 0-9 are defined categories 

13ALERT_CATEGORY_RESERVED_MIN = 10 # 10-250 are reserved 

14ALERT_CATEGORY_RESERVED_MAX = 250 

15ALERT_CATEGORY_SERVICE_SPECIFIC_MIN = 251 # 251-255 are service-specific 

16 

17# Alert text constraints 

18ALERT_TEXT_MAX_LENGTH = 18 # Maximum UTF-8 text length in bytes 

19 

20# Unread count special values 

21UNREAD_COUNT_MAX = 254 # 0-254 explicit count 

22UNREAD_COUNT_MORE_THAN_MAX = 255 # 255 means >254 unread 

23 

24# Control point command range 

25ALERT_COMMAND_MAX = 5 # Valid command IDs are 0-5 

26 

27 

28class AlertCategoryID(IntEnum): 

29 """Alert category enumeration per Bluetooth SIG specification. 

30 

31 Values 0-9 are defined, 10-250 reserved, 251-255 service-specific. 

32 """ 

33 

34 SIMPLE_ALERT = 0 

35 EMAIL = 1 

36 NEWS = 2 

37 CALL = 3 

38 MISSED_CALL = 4 

39 SMS_MMS = 5 

40 VOICE_MAIL = 6 

41 SCHEDULE = 7 

42 HIGH_PRIORITIZED_ALERT = 8 

43 INSTANT_MESSAGE = 9 

44 # Service-specific values (251-255) 

45 SERVICE_SPECIFIC_1 = 251 

46 SERVICE_SPECIFIC_2 = 252 

47 SERVICE_SPECIFIC_3 = 253 

48 SERVICE_SPECIFIC_4 = 254 

49 SERVICE_SPECIFIC_5 = 255 

50 

51 

52class AlertCategoryBitMask(IntFlag): 

53 """Alert category bit mask flags. 

54 

55 Each bit represents support for a specific alert category. 

56 Bits 10-15 are reserved for future use. 

57 """ 

58 

59 SIMPLE_ALERT = 1 << 0 

60 EMAIL = 1 << 1 

61 NEWS = 1 << 2 

62 CALL = 1 << 3 

63 MISSED_CALL = 1 << 4 

64 SMS_MMS = 1 << 5 

65 VOICE_MAIL = 1 << 6 

66 SCHEDULE = 1 << 7 

67 HIGH_PRIORITIZED_ALERT = 1 << 8 

68 INSTANT_MESSAGE = 1 << 9 

69 

70 

71class AlertNotificationCommandID(IntEnum): 

72 """Alert Notification Control Point command enumeration.""" 

73 

74 ENABLE_NEW_ALERT = 0 

75 ENABLE_UNREAD_STATUS = 1 

76 DISABLE_NEW_ALERT = 2 

77 DISABLE_UNREAD_STATUS = 3 

78 NOTIFY_NEW_ALERT_IMMEDIATELY = 4 

79 NOTIFY_UNREAD_STATUS_IMMEDIATELY = 5