smp: emit enough information on pairing complete to deduce security level
diff --git a/bumble/device.py b/bumble/device.py
index 70d154e..66f11a1 100644
--- a/bumble/device.py
+++ b/bumble/device.py
@@ -413,6 +413,8 @@
self.parameters = parameters
self.encryption = 0
self.authenticated = False
+ self.sc = False
+ self.link_key_type = None
self.phy = phy
self.att_mtu = ATT_DEFAULT_MTU
self.data_length = DEVICE_DEFAULT_DATA_LENGTH
@@ -1404,7 +1406,7 @@
Notes:
* A `connect` to the same peer will also complete this call.
* The `timeout` parameter is only handled while waiting for the connection request,
- once received and accepeted, the controller shall issue a connection complete event.
+ once received and accepted, the controller shall issue a connection complete event.
'''
if type(peer_address) is str:
@@ -1848,6 +1850,9 @@
asyncio.create_task(store_keys())
+ if (connection := self.find_connection_by_bd_addr(bd_addr, transport=BT_BR_EDR_TRANSPORT)):
+ connection.link_key_type = key_type
+
def add_service(self, service):
self.gatt_server.add_service(service)
@@ -2273,7 +2278,9 @@
connection.emit('pairing_start')
@with_connection_from_handle
- def on_pairing(self, connection, keys):
+ def on_pairing(self, connection, keys, sc):
+ connection.sc = sc
+ connection.authenticated = True
connection.emit('pairing', keys)
@with_connection_from_handle
diff --git a/bumble/smp.py b/bumble/smp.py
index 6d2d7d9..62f346b 100644
--- a/bumble/smp.py
+++ b/bumble/smp.py
@@ -1583,7 +1583,7 @@
asyncio.create_task(store_keys())
# Notify the device
- self.device.on_pairing(session.connection.handle, keys)
+ self.device.on_pairing(session.connection.handle, keys, session.sc)
def on_pairing_failure(self, session, reason):
self.device.on_pairing_failure(session.connection.handle, reason)