Fix a misconfig of HCI_PIN_Code_Reply_Command

The pin_code field is of fixed length of 16 bytes
This commit is contained in:
Hui Peng
2023-03-24 11:29:38 -07:00
parent 4c6320f98a
commit bd25cf27df
2 changed files with 9 additions and 3 deletions

View File

@@ -2102,7 +2102,7 @@ class HCI_Link_Key_Request_Negative_Reply_Command(HCI_Command):
fields=[
('bd_addr', Address.parse_address),
('pin_code_length', 1),
('pin_code', '*'),
('pin_code', 16),
],
return_parameters_fields=[
('status', STATUS_SPEC),

View File

@@ -215,12 +215,18 @@ def test_HCI_Command():
# -----------------------------------------------------------------------------
def test_HCI_PIN_Code_Request_Reply_Command():
pin_code = b'1234'
pin_code_length = len(pin_code)
# here to make the test pass, we need to
# pad pin_code, as HCI_Object.format_fields
# does not do it for us
padded_pin_code = pin_code + bytes(16 - pin_code_length)
command = HCI_PIN_Code_Request_Reply_Command(
bd_addr=Address(
'00:11:22:33:44:55', address_type=Address.PUBLIC_DEVICE_ADDRESS
),
pin_code_length=4,
pin_code=b'1234',
pin_code_length=pin_code_length,
pin_code=padded_pin_code,
)
basic_check(command)