Coverage for src / bluetooth_sig / gatt / characteristics / current_time.py: 100%
9 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"""Current Time characteristic (0x2A2B) implementation.
3Represents exact time with date, time, fractions, and adjustment reasons.
4Used by Current Time Service (0x1805).
6Based on Bluetooth SIG GATT Specification:
7- Current Time: 10 bytes (Date Time + Day of Week + Fractions256 + Adjust Reason)
8- Date Time: Year (uint16) + Month + Day + Hours + Minutes + Seconds (7 bytes)
9- Day of Week: uint8 (1=Monday to 7=Sunday, 0=Unknown)
10- Fractions256: uint8 (0-255, representing 1/256 fractions of a second)
11- Adjust Reason: uint8 bitfield (Manual Update, External Reference, Time Zone, DST)
12"""
14from __future__ import annotations
16from ...types.gatt_enums import ValueType
17from .base import BaseCharacteristic
18from .templates import TimeData, TimeDataTemplate
21class CurrentTimeCharacteristic(BaseCharacteristic[TimeData]):
22 """Current Time characteristic (0x2A2B).
24 Represents exact time with date, time, fractions, and adjustment reasons.
25 Used by Current Time Service (0x1805).
27 Structure (10 bytes):
28 - Year: uint16 (1582-9999, 0=unknown)
29 - Month: uint8 (1-12, 0=unknown)
30 - Day: uint8 (1-31, 0=unknown)
31 - Hours: uint8 (0-23)
32 - Minutes: uint8 (0-59)
33 - Seconds: uint8 (0-59)
34 - Day of Week: uint8 (0=unknown, 1=Monday...7=Sunday)
35 - Fractions256: uint8 (0-255, representing 1/256 fractions of a second)
36 - Adjust Reason: uint8 bitfield
37 """
39 # Validation attributes
40 _manual_value_type: ValueType | str | None = ValueType.DICT
42 def __init__(self) -> None:
43 """Initialize the Current Time characteristic."""
44 super().__init__()
45 self._template = TimeDataTemplate()