Coverage for tropicsquare / config / uap_pairing_key.py: 87%
38 statements
« prev ^ index » next coverage.py v7.13.5, created at 2026-03-27 21:24 +0000
« prev ^ index » next coverage.py v7.13.5, created at 2026-03-27 21:24 +0000
1"""UAP Pairing Key configuration classes"""
3from tropicsquare.config.uap_base import UapMultiSlotConfig, UapPermissionField
4from tropicsquare.config.constants import (
5 UAP_PKEY_SLOT_0_POS,
6 UAP_PKEY_SLOT_1_POS,
7 UAP_PKEY_SLOT_2_POS,
8 UAP_PKEY_SLOT_3_POS
9)
12class PairingKeyConfig(UapMultiSlotConfig):
13 """UAP Pairing Key base configuration"""
15 @property
16 def pkey_slot_0(self) -> UapPermissionField:
17 """Permission field for pairing key slot 0 write."""
18 return self._get_slot_field(UAP_PKEY_SLOT_0_POS)
20 @pkey_slot_0.setter
21 def pkey_slot_0(self, field) -> None:
22 self._set_slot_field(UAP_PKEY_SLOT_0_POS, field)
24 @property
25 def pkey_slot_1(self) -> UapPermissionField:
26 """Permission field for pairing key slot 1 write."""
27 return self._get_slot_field(UAP_PKEY_SLOT_1_POS)
29 @pkey_slot_1.setter
30 def pkey_slot_1(self, field) -> None:
31 self._set_slot_field(UAP_PKEY_SLOT_1_POS, field)
33 @property
34 def pkey_slot_2(self) -> UapPermissionField:
35 """Permission field for pairing key slot 2 write."""
36 return self._get_slot_field(UAP_PKEY_SLOT_2_POS)
38 @pkey_slot_2.setter
39 def pkey_slot_2(self, field) -> None:
40 self._set_slot_field(UAP_PKEY_SLOT_2_POS, field)
42 @property
43 def pkey_slot_3(self) -> UapPermissionField:
44 """Permission field for pairing key slot 3 write."""
45 return self._get_slot_field(UAP_PKEY_SLOT_3_POS)
47 @pkey_slot_3.setter
48 def pkey_slot_3(self, field) -> None:
49 self._set_slot_field(UAP_PKEY_SLOT_3_POS, field)
51 def to_dict(self) -> dict:
52 """Export fields as dictionary."""
53 return {
54 'pkey_slot_0': self.pkey_slot_0.to_dict(),
55 'pkey_slot_1': self.pkey_slot_1.to_dict(),
56 'pkey_slot_2': self.pkey_slot_2.to_dict(),
57 'pkey_slot_3': self.pkey_slot_3.to_dict()
58 }
60 def __str__(self) -> str:
61 """Table row with pairing key slot specific field names."""
62 s0 = str(self.pkey_slot_0)
63 s1 = str(self.pkey_slot_1)
64 s2 = str(self.pkey_slot_2)
65 s3 = str(self.pkey_slot_3)
66 return "{:26s} | {} || {} || {} || {} |".format(
67 self.__class__.__name__,
68 s0, s1, s2, s3
69 )
72class PairingKeyWriteConfig(PairingKeyConfig):
73 """UAP Pairing Key Write configuration (CFG_UAP_PAIRING_KEY_WRITE @ 0x20).
75 Controls which pairing key slots can write to each pairing key slot.
76 Has 4 slots, each with 8-bit permission field.
77 """
80class PairingKeyReadConfig(PairingKeyConfig):
81 """UAP Pairing Key Read configuration (CFG_UAP_PAIRING_KEY_READ @ 0x24).
83 Controls which pairing key slots can read from each pairing key slot.
84 """
87class PairingKeyInvalidateConfig(PairingKeyConfig):
88 """UAP Pairing Key Invalidate configuration (CFG_UAP_PAIRING_KEY_INVALIDATE @ 0x28).
90 Controls which pairing key slots can invalidate each pairing key slot.
91 """