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

10 statements  

« prev     ^ index     » next       coverage.py v7.11.0, created at 2025-10-30 00:10 +0000

1"""Voltage characteristic implementation.""" 

2 

3from __future__ import annotations 

4 

5from ...types.units import ElectricalUnit 

6from ..constants import UINT16_MAX 

7from .base import BaseCharacteristic 

8from .templates import ScaledUint16Template 

9 

10 

11class VoltageCharacteristic(BaseCharacteristic): 

12 """Voltage characteristic (0x2B18). 

13 

14 org.bluetooth.characteristic.voltage 

15 

16 Voltage characteristic. 

17 

18 Measures voltage with 1/64 V resolution. 

19 """ 

20 

21 _template = ScaledUint16Template(scale_factor=1 / 64, offset=0) 

22 

23 _manual_unit: str = ElectricalUnit.VOLTS.value # Override template's "units" default 

24 

25 # Template configuration 

26 resolution: float = 1 / 64 # 1/64 V resolution 

27 max_value: float = UINT16_MAX / 64 # ~1024 V max