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

9 statements  

« prev     ^ index     » next       coverage.py v7.14.3, created at 2026-06-28 01:26 +0000

1"""AP Sync Key Material characteristic (0x2BF7). 

2 

316-byte key material for AP synchronisation. 

4 

5References: 

6 Bluetooth SIG Common Audio Profile specification 

7""" 

8 

9from __future__ import annotations 

10 

11from ..context import CharacteristicContext 

12from .base import BaseCharacteristic 

13 

14 

15class APSyncKeyMaterialCharacteristic(BaseCharacteristic[bytes]): 

16 """AP Sync Key Material characteristic (0x2BF7). 

17 

18 org.bluetooth.characteristic.ap_sync_key_material 

19 

20 16-byte key material used for audio profile synchronisation. 

21 """ 

22 

23 expected_length = 16 

24 

25 def _decode_value( 

26 self, data: bytearray, ctx: CharacteristicContext | None = None, *, validate: bool = True 

27 ) -> bytes: 

28 return bytes(data[:16]) 

29 

30 def _encode_value(self, data: bytes) -> bytearray: 

31 return bytearray(data[:16].ljust(16, b"\x00"))