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

7 statements  

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

1"""Uncertainty characteristic implementation.""" 

2 

3from __future__ import annotations 

4 

5from .base import BaseCharacteristic 

6from .templates import ScaledUint8Template 

7 

8 

9class UncertaintyCharacteristic(BaseCharacteristic[float]): 

10 """Uncertainty characteristic (0x2AB4). 

11 

12 org.bluetooth.characteristic.uncertainty 

13 

14 Uncertainty characteristic for Indoor Positioning Service. 

15 

16 This characteristic represents the uncertainty or accuracy of the indoor positioning 

17 measurements. It provides an estimate of the error margin for the position coordinates 

18 (Local North Coordinate, Local East Coordinate, and Altitude). 

19 

20 The uncertainty value indicates the radius of a circle (in 2D) or sphere (in 3D) within 

21 which the actual position is expected to lie with a certain confidence level. The value 

22 is encoded as a scaled uint8 with 0.1 meter resolution, providing a range of 0-25.5 meters. 

23 

24 A value of 0 indicates the highest accuracy (no uncertainty), while higher values 

25 indicate increasing uncertainty in the position measurements. 

26 

27 Args: 

28 data: Raw bytes from BLE characteristic (exactly 1 byte, uint8) 

29 ctx: Optional context for parsing 

30 

31 Returns: 

32 Uncertainty radius in meters (0.0 to 25.5) 

33 

34 Raises: 

35 InsufficientDataError: If data is not exactly 1 byte 

36 ValueRangeError: If decoded value exceeds maximum 25.5 meters 

37 

38 Spec Reference: 

39 Bluetooth SIG Assigned Numbers, Uncertainty characteristic (0x2AB4) 

40 Indoor Positioning Service specification 

41 """ 

42 

43 # Manual overrides required as Bluetooth SIG registry doesn't provide unit/value type 

44 _manual_unit = "m" 

45 _manual_value_type = "float" 

46 _template = ScaledUint8Template(scale_factor=0.1)