Coverage for src / bluetooth_sig / gatt / constants.py: 100%
48 statements
« prev ^ index » next coverage.py v7.13.1, created at 2026-01-11 20:14 +0000
« prev ^ index » next coverage.py v7.13.1, created at 2026-01-11 20:14 +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
15SINT8_MIN = -(1 << 7) # -128
16SINT8_MAX = (1 << 7) - 1 # 127
17SINT16_MIN = -(1 << 15) # -32768
18SINT16_MAX = (1 << 15) - 1 # 32767
19SINT24_MIN = -(1 << 23) # -8388608
20SINT24_MAX = (1 << 23) - 1 # 8388607
21SINT32_MIN = -(1 << 31) # -2147483648
22SINT32_MAX = (1 << 31) - 1 # 2147483647
24# Common measurement ranges
25PERCENTAGE_MIN = 0
26PERCENTAGE_MAX = 100 # Maximum percentage value
27EXTENDED_PERCENTAGE_MAX = 200
28ABSOLUTE_ZERO_CELSIUS = -273.15 # Absolute zero temperature in Celsius
30# Common resolution values
31TEMPERATURE_RESOLUTION = 0.01 # Standard temperature resolution (°C)
32PRESSURE_RESOLUTION = 0.1 # Standard pressure resolution (Pa)
33HUMIDITY_RESOLUTION = 0.01 # Standard humidity resolution (%)
34WIND_SPEED_RESOLUTION = 0.01 # Standard wind speed resolution (m/s)
35WIND_DIRECTION_RESOLUTION = 0.01 # Standard wind direction resolution (°)
36SOUND_PRESSURE_RESOLUTION = 0.1 # Standard sound pressure resolution (dB)
38# Common unit strings
39UNIT_CELSIUS = "°C"
40UNIT_FAHRENHEIT = "°F"
41UNIT_KELVIN = "K"
42UNIT_PERCENT = "%"
43UNIT_PPM = "ppm"
44UNIT_PASCAL = "Pa"
45UNIT_HECTOPASCAL = "hPa"
46UNIT_METER_PER_SECOND = "m/s"
47UNIT_DEGREE = "°"
48UNIT_DECIBEL = "dB"
49UNIT_VOLT = "V"
50UNIT_AMPERE = "A"
51UNIT_WATT = "W"
52UNIT_JOULE = "J"
53UNIT_KILOJOULE = "kJ"
54UNIT_TESLA = "T"
55UNIT_MICROTESLA = "µT"
56UNIT_LUX = "lx"
57UNIT_METER = "m"
58UNIT_BEATS_PER_MINUTE = "bpm"
59UNIT_DBM = "dBm"
61# Common data validation ranges
62MAX_CONCENTRATION_PPM = 65535.0 # Maximum concentration in ppm
63MAX_TEMPERATURE_CELSIUS = 1000.0 # Maximum reasonable temperature
64MAX_PRESSURE_PA = 200000.0 # Maximum atmospheric pressure (2000 hPa)
65MAX_POWER_WATTS = 65535.0 # Maximum power in watts