Coverage for src / bluetooth_sig / gatt / characteristics / emergency_id.py: 100%
14 statements
« prev ^ index » next coverage.py v7.13.5, created at 2026-04-03 16:41 +0000
« prev ^ index » next coverage.py v7.13.5, created at 2026-04-03 16:41 +0000
1"""Emergency ID characteristic (0x2B2D)."""
3from __future__ import annotations
5from ..context import CharacteristicContext
6from .base import BaseCharacteristic
8_EMERGENCY_ID_LENGTH = 6
11class EmergencyIdCharacteristic(BaseCharacteristic[bytes]):
12 """Emergency ID characteristic (0x2B2D).
14 org.bluetooth.characteristic.emergency_id
16 6-octet identifier: the first 48 bits of a randomly generated 128-bit
17 number. Assigned at manufacture or provisioning; static for the lifetime
18 of the device. Read-only, encryption required.
19 """
21 expected_length: int = _EMERGENCY_ID_LENGTH
22 min_length: int = _EMERGENCY_ID_LENGTH
24 def _decode_value(
25 self, data: bytearray, ctx: CharacteristicContext | None = None, *, validate: bool = True
26 ) -> bytes:
27 return bytes(data[:_EMERGENCY_ID_LENGTH])
29 def _encode_value(self, data: bytes) -> bytearray:
30 if len(data) != _EMERGENCY_ID_LENGTH:
31 msg = f"Emergency ID must be exactly {_EMERGENCY_ID_LENGTH} bytes, got {len(data)}"
32 raise ValueError(msg)
33 return bytearray(data)