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

68 statements  

« prev     ^ index     » next       coverage.py v7.13.5, created at 2026-04-03 16:41 +0000

1"""Physical Activity Monitor Features characteristic (0x2B3B). 

2 

364-bit bitfield of supported Physical Activity Monitor features. 

4 

5References: 

6 Bluetooth SIG Physical Activity Monitor Service 1.0 

7""" 

8 

9from __future__ import annotations 

10 

11from enum import IntFlag 

12 

13from ..context import CharacteristicContext 

14from .base import BaseCharacteristic 

15 

16 

17class PhysicalActivityMonitorFeatures(IntFlag): 

18 """Physical Activity Monitor feature flags (uint64, 8 octets).""" 

19 

20 MULTIPLE_USERS_SUPPORTED = 1 << 0 

21 USER_DATA_SERVICE_SUPPORTED = 1 << 1 

22 DEVICE_WORN_SUPPORTED = 1 << 2 

23 NORMAL_WALKING_ENERGY_EXPENDITURE_SUPPORTED = 1 << 3 

24 NORMAL_WALKING_ENERGY_EXPENDITURE_PER_HOUR_SUPPORTED = 1 << 4 

25 INTENSITY_ENERGY_EXPENDITURE_SUPPORTED = 1 << 5 

26 INTENSITY_ENERGY_EXPENDITURE_PER_HOUR_SUPPORTED = 1 << 6 

27 TOTAL_ENERGY_EXPENDITURE_SUPPORTED = 1 << 7 

28 TOTAL_ENERGY_EXPENDITURE_PER_HOUR_SUPPORTED = 1 << 8 

29 FAT_BURNED_SUPPORTED = 1 << 9 

30 FAT_BURNED_PER_HOUR_SUPPORTED = 1 << 10 

31 METABOLIC_EQUIVALENT_SUPPORTED = 1 << 11 

32 DISTANCE_SUPPORTED = 1 << 12 

33 SPEED_SUPPORTED = 1 << 13 

34 DURATION_NORMAL_WALKING_EPISODES_SUPPORTED = 1 << 14 

35 DURATION_INTENSITY_WALKING_EPISODES_SUPPORTED = 1 << 15 

36 MOTION_CADENCE_SUPPORTED = 1 << 16 

37 FLOORS_SUPPORTED = 1 << 17 

38 POSITIVE_ELEVATION_GAIN_SUPPORTED = 1 << 18 

39 NEGATIVE_ELEVATION_GAIN_SUPPORTED = 1 << 19 

40 ELEVATION_SUPPORTED = 1 << 20 

41 ACTIVITY_COUNT_SUPPORTED = 1 << 21 

42 ACTIVITY_COUNT_PER_MINUTE_SUPPORTED = 1 << 22 

43 ACTIVITY_LEVEL_SUPPORTED = 1 << 23 

44 ACTIVITY_TYPE_SUPPORTED = 1 << 24 

45 WORN_DURATION_SUPPORTED = 1 << 25 

46 TIME_IN_HR_ZONE1_SUPPORTED = 1 << 26 

47 TIME_IN_HR_ZONE2_SUPPORTED = 1 << 27 

48 TIME_IN_HR_ZONE3_SUPPORTED = 1 << 28 

49 TIME_IN_HR_ZONE4_SUPPORTED = 1 << 29 

50 TIME_IN_HR_ZONE5_SUPPORTED = 1 << 30 

51 VO2_MAX_SUPPORTED = 1 << 31 

52 HEART_RATE_SUPPORTED = 1 << 32 

53 PULSE_INTER_BEAT_INTERVAL_SUPPORTED = 1 << 33 

54 RESTING_HEART_RATE_SUPPORTED = 1 << 34 

55 HEART_RATE_VARIABILITY_SUPPORTED = 1 << 35 

56 RESPIRATION_RATE_SUPPORTED = 1 << 36 

57 RESTING_RESPIRATION_RATE_SUPPORTED = 1 << 37 

58 NORMAL_WALKING_STEPS_SUPPORTED = 1 << 38 

59 INTENSITY_STEPS_SUPPORTED = 1 << 39 

60 FLOOR_STEPS_SUPPORTED = 1 << 40 

61 TOTAL_SLEEP_TIME_SUPPORTED = 1 << 41 

62 TOTAL_WAKE_TIME_SUPPORTED = 1 << 42 

63 TOTAL_BED_TIME_SUPPORTED = 1 << 43 

64 NUMBER_OF_AWAKENINGS_SUPPORTED = 1 << 44 

65 SLEEP_LATENCY_SUPPORTED = 1 << 45 

66 SLEEP_EFFICIENCY_SUPPORTED = 1 << 46 

67 SNOOZE_TIME_SUPPORTED = 1 << 47 

68 NUMBER_OF_TOSS_AND_TURN_EVENTS_SUPPORTED = 1 << 48 

69 TIME_OF_AWAKENING_AFTER_ALARM_SUPPORTED = 1 << 49 

70 VISIBLE_LIGHT_LEVEL_SUPPORTED = 1 << 50 

71 UV_LIGHT_LEVEL_SUPPORTED = 1 << 51 

72 IR_LIGHT_LEVEL_SUPPORTED = 1 << 52 

73 SLEEP_STAGE_SUPPORTED = 1 << 53 

74 SLEEPING_HEART_RATE_SUPPORTED = 1 << 54 

75 

76 

77class PhysicalActivityMonitorFeaturesCharacteristic(BaseCharacteristic[PhysicalActivityMonitorFeatures]): 

78 """Physical Activity Monitor Features characteristic (0x2B3B). 

79 

80 org.bluetooth.characteristic.physical_activity_monitor_features 

81 

82 Reports supported features of the Physical Activity Monitor. 

83 64-bit feature bitfield (8 octets, no FlagTemplate.uint64 available). 

84 """ 

85 

86 min_length = 8 

87 allow_variable_length = False 

88 

89 def _decode_value( 

90 self, data: bytearray, ctx: CharacteristicContext | None = None, *, validate: bool = True 

91 ) -> PhysicalActivityMonitorFeatures: 

92 """Parse Physical Activity Monitor Features (uint64 LE).""" 

93 raw = int.from_bytes(data[:8], byteorder="little") 

94 return PhysicalActivityMonitorFeatures(raw) 

95 

96 def _encode_value(self, data: PhysicalActivityMonitorFeatures) -> bytearray: 

97 """Encode Physical Activity Monitor Features (uint64 LE).""" 

98 return bytearray(int(data).to_bytes(8, byteorder="little"))