Coverage for src / bluetooth_sig / gatt / constants.py: 100%
61 statements
« prev ^ index » next coverage.py v7.13.5, created at 2026-03-18 11:17 +0000
« prev ^ index » next coverage.py v7.13.5, created at 2026-03-18 11:17 +0000
1"""Shared constants for GATT characteristics and services.
3This module provides commonly used constants throughout the Bluetooth
4SIG implementation to avoid duplication and ensure consistency.
5"""
7from __future__ import annotations
9# Data type maximum and minimum values
10UINT8_MAX = (1 << 8) - 1 # 255
11UINT16_MAX = (1 << 16) - 1 # 65535
12UINT24_MAX = (1 << 24) - 1 # 16777215
13UINT32_MAX = (1 << 32) - 1 # 4294967295
14UINT48_MAX = (1 << 48) - 1 # 281474976710655
16SINT8_MIN = -(1 << 7) # -128
17SINT8_MAX = (1 << 7) - 1 # 127
18SINT16_MIN = -(1 << 15) # -32768
19SINT16_MAX = (1 << 15) - 1 # 32767
20SINT24_MIN = -(1 << 23) # -8388608
21SINT24_MAX = (1 << 23) - 1 # 8388607
22SINT32_MIN = -(1 << 31) # -2147483648
23SINT32_MAX = (1 << 31) - 1 # 2147483647
25# Common measurement ranges
26PERCENTAGE_MIN = 0
27PERCENTAGE_MAX = 100 # Maximum percentage value
28EXTENDED_PERCENTAGE_MAX = 200
29ABSOLUTE_ZERO_CELSIUS = -273.15 # Absolute zero temperature in Celsius
31# Common resolution values
32TEMPERATURE_RESOLUTION = 0.01 # Standard temperature resolution (°C)
33PRESSURE_RESOLUTION = 0.1 # Standard pressure resolution (Pa)
34HUMIDITY_RESOLUTION = 0.01 # Standard humidity resolution (%)
35WIND_SPEED_RESOLUTION = 0.01 # Standard wind speed resolution (m/s)
36WIND_DIRECTION_RESOLUTION = 0.01 # Standard wind direction resolution (°)
37SOUND_PRESSURE_RESOLUTION = 0.1 # Standard sound pressure resolution (dB)
39# Common unit strings
40UNIT_CELSIUS = "°C"
41UNIT_FAHRENHEIT = "°F"
42UNIT_KELVIN = "K"
43UNIT_PERCENT = "%"
44UNIT_PPM = "ppm"
45UNIT_PASCAL = "Pa"
46UNIT_HECTOPASCAL = "hPa"
47UNIT_METER_PER_SECOND = "m/s"
48UNIT_DEGREE = "°"
49UNIT_DECIBEL = "dB"
50UNIT_VOLT = "V"
51UNIT_AMPERE = "A"
52UNIT_WATT = "W"
53UNIT_JOULE = "J"
54UNIT_KILOJOULE = "kJ"
55UNIT_TESLA = "T"
56UNIT_MICROTESLA = "µT"
57UNIT_LUX = "lx"
58UNIT_METER = "m"
59UNIT_BEATS_PER_MINUTE = "bpm"
60UNIT_DBM = "dBm"
62# Common data validation ranges
63MAX_CONCENTRATION_PPM = 65535.0 # Maximum concentration in ppm
64MAX_TEMPERATURE_CELSIUS = 1000.0 # Maximum reasonable temperature
65MAX_PRESSURE_PA = 200000.0 # Maximum atmospheric pressure (2000 hPa)
66MAX_POWER_WATTS = 65535.0 # Maximum power in watts
68# Human physiological ranges
69HEART_RATE_MIN = 30 # Minimum reasonable human heart rate (bpm)
70HEART_RATE_MAX = 300 # Maximum reasonable human heart rate (bpm)
72# Domain-specific constants
73DEGREES_IN_CIRCLE = 360 # Degrees in a complete circle
74MAX_YEAR_VALUE = 9999 # Maximum year value in date fields
76# Common protocol field sizes (in bytes)
77SIZE_UINT8 = 1
78SIZE_UINT16 = 2
79SIZE_UINT24 = 3
80SIZE_UINT32 = 4
81SIZE_UINT48 = 6
82SIZE_UINT64 = 8
83SIZE_UUID16 = 2
84SIZE_UUID128 = 16