Skip to content

Commit

Permalink
Merge pull request #500 from google/gbg/fix-advertising-auto-restart
Browse files Browse the repository at this point in the history
fix legacy advertising auto restart
  • Loading branch information
barbibulle committed Jun 4, 2024
2 parents 0903093 + 394137b commit 181467f
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions bumble/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -3701,7 +3701,6 @@ def on_connection(
# We were connected via a legacy advertisement.
if self.legacy_advertiser:
own_address_type = self.legacy_advertiser.own_address_type
self.legacy_advertiser = None
else:
# This should not happen, but just in case, pick a default.
logger.warning("connection without an advertiser")
Expand Down Expand Up @@ -3732,15 +3731,14 @@ def on_connection(
)
self.connections[connection_handle] = connection

if (
role == HCI_PERIPHERAL_ROLE
and self.legacy_advertiser
and self.legacy_advertiser.auto_restart
):
connection.once(
'disconnection',
lambda _: self.abort_on('flush', self.legacy_advertiser.start()),
)
if role == HCI_PERIPHERAL_ROLE and self.legacy_advertiser:
if self.legacy_advertiser.auto_restart:
connection.once(
'disconnection',
lambda _: self.abort_on('flush', self.legacy_advertiser.start()),
)
else:
self.legacy_advertiser = None

if role == HCI_CENTRAL_ROLE or not self.supports_le_extended_advertising:
# We can emit now, we have all the info we need
Expand Down

0 comments on commit 181467f

Please sign in to comment.