fix legacy advertising auto restart

This commit is contained in:
Gilles Boccon-Gibod
2024-06-03 19:08:46 -07:00
parent 090309302f
commit 394137b6f7

View File

@@ -3701,7 +3701,6 @@ class Device(CompositeEventEmitter):
# We were connected via a legacy advertisement. # We were connected via a legacy advertisement.
if self.legacy_advertiser: if self.legacy_advertiser:
own_address_type = self.legacy_advertiser.own_address_type own_address_type = self.legacy_advertiser.own_address_type
self.legacy_advertiser = None
else: else:
# This should not happen, but just in case, pick a default. # This should not happen, but just in case, pick a default.
logger.warning("connection without an advertiser") logger.warning("connection without an advertiser")
@@ -3732,15 +3731,14 @@ class Device(CompositeEventEmitter):
) )
self.connections[connection_handle] = connection self.connections[connection_handle] = connection
if ( if role == HCI_PERIPHERAL_ROLE and self.legacy_advertiser:
role == HCI_PERIPHERAL_ROLE if self.legacy_advertiser.auto_restart:
and self.legacy_advertiser connection.once(
and self.legacy_advertiser.auto_restart 'disconnection',
): lambda _: self.abort_on('flush', self.legacy_advertiser.start()),
connection.once( )
'disconnection', else:
lambda _: self.abort_on('flush', self.legacy_advertiser.start()), self.legacy_advertiser = None
)
if role == HCI_CENTRAL_ROLE or not self.supports_le_extended_advertising: if role == HCI_CENTRAL_ROLE or not self.supports_le_extended_advertising:
# We can emit now, we have all the info we need # We can emit now, we have all the info we need