From b91d0e24c16476a92050a98a2a18635948ba7a39 Mon Sep 17 00:00:00 2001 From: Abel Lucas Date: Fri, 11 Nov 2022 18:43:35 +0000 Subject: [PATCH] device: handle HCI passkey notification event --- bumble/device.py | 9 +++++++++ bumble/hci.py | 11 +++++++++++ bumble/host.py | 3 +++ 3 files changed, 23 insertions(+) diff --git a/bumble/device.py b/bumble/device.py index d73276e..1b8ab55 100644 --- a/bumble/device.py +++ b/bumble/device.py @@ -2159,6 +2159,15 @@ class Device(CompositeEventEmitter): HCI_User_Passkey_Request_Negative_Reply_Command(bd_addr=connection.peer_address) ) + # [Classic only] + @host_event_handler + @with_connection_from_address + def on_authentication_user_passkey_notification(self, connection, passkey): + # Ask what the pairing config should be for this connection + pairing_config = self.pairing_config_factory(connection) + + asyncio.create_task(pairing_config.delegate.display_number(passkey)) + # [Classic only] @host_event_handler @try_with_connection_from_address diff --git a/bumble/hci.py b/bumble/hci.py index 6fdabb1..1d55d92 100644 --- a/bumble/hci.py +++ b/bumble/hci.py @@ -4875,6 +4875,17 @@ class HCI_Link_Supervision_Timeout_Changed_Event(HCI_Event): ''' +# ----------------------------------------------------------------------------- +@HCI_Event.event([ + ('bd_addr', Address.parse_address), + ('passkey', 4) +]) +class HCI_User_Passkey_Notification_Event(HCI_Event): + ''' + See Bluetooth spec @ 7.7.48 User Passkey Notification Event + ''' + + # ----------------------------------------------------------------------------- @HCI_Event.event([ ('bd_addr', Address.parse_address), diff --git a/bumble/host.py b/bumble/host.py index a57299b..3b869b7 100644 --- a/bumble/host.py +++ b/bumble/host.py @@ -638,6 +638,9 @@ class Host(EventEmitter): def on_hci_user_passkey_request_event(self, event): self.emit('authentication_user_passkey_request', event.bd_addr) + def on_hci_user_passkey_notification_event(self, event): + self.emit('authentication_user_passkey_notification', event.bd_addr, event.passkey) + def on_hci_inquiry_complete_event(self, event): self.emit('inquiry_complete')