mirror of
https://github.com/google/bumble.git
synced 2026-05-08 03:58:01 +00:00
Fix HCI_PIN_Code_Reply_Command in Device.on_pin_code_request
This commit is contained in:
@@ -2808,11 +2808,23 @@ class Device(CompositeEventEmitter):
|
||||
)
|
||||
|
||||
if pin_code is not None:
|
||||
pin_code = bytes(str(pin_code).zfill(6))
|
||||
# TODO: make pin code input more flexible,
|
||||
# so far only numbers are allowed
|
||||
pin_code = bytes(str(pin_code), encoding='utf8')
|
||||
pin_code_len = len(pin_code)
|
||||
if pin_code_len > 16:
|
||||
logger.warning(
|
||||
'pin_code is longer than 16 bytes, truncated to 16'
|
||||
)
|
||||
pin_code_len = 16
|
||||
# the pin_code will be truncated according to pin_code_len
|
||||
# when converted to byte array in HCI_Object, so we
|
||||
# are not doing truncation here
|
||||
|
||||
await self.host.send_command(
|
||||
HCI_PIN_Code_Request_Reply_Command(
|
||||
bd_addr=connection.peer_address,
|
||||
pin_code_length=len(pin_code),
|
||||
pin_code_length=pin_code_len,
|
||||
pin_code=pin_code,
|
||||
)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user