Coverage for src / bluetooth_sig / gatt / characteristics / current_time.py: 100%
7 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"""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 .base import BaseCharacteristic
17from .templates import TimeData, TimeDataTemplate
20class CurrentTimeCharacteristic(BaseCharacteristic[TimeData]):
21 """Current Time characteristic (0x2A2B).
23 Represents exact time with date, time, fractions, and adjustment reasons.
24 Used by Current Time Service (0x1805).
26 Structure (10 bytes):
27 - Year: uint16 (1582-9999, 0=unknown)
28 - Month: uint8 (1-12, 0=unknown)
29 - Day: uint8 (1-31, 0=unknown)
30 - Hours: uint8 (0-23)
31 - Minutes: uint8 (0-59)
32 - Seconds: uint8 (0-59)
33 - Day of Week: uint8 (0=unknown, 1=Monday...7=Sunday)
34 - Fractions256: uint8 (0-255, representing 1/256 fractions of a second)
35 - Adjust Reason: uint8 bitfield
36 """
38 def __init__(self) -> None:
39 """Initialize the Current Time characteristic."""
40 super().__init__()
41 self._template = TimeDataTemplate()