Skip to content

Commit

Permalink
Fix double-disable legacy advertising set
Browse files Browse the repository at this point in the history
When legacy advertising set is disabled passively(by set termination),
the legacy advertising set won't be released, and the next
stop_advertising() call will try to disable it again and cause an error.
  • Loading branch information
zxzxwu committed Feb 4, 2024
1 parent 1a3272d commit 5b10549
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions bumble/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -2065,7 +2065,8 @@ async def stop_advertising(self) -> None:
"""Stop legacy advertising."""
# Disable advertising
if self.legacy_advertising_set:
await self.legacy_advertising_set.stop()
if self.legacy_advertising_set.enabled:
await self.legacy_advertising_set.stop()
self.legacy_advertising_set = None
elif self.legacy_advertiser:
await self.legacy_advertiser.stop()
Expand Down Expand Up @@ -3544,7 +3545,15 @@ def on_advertising_set_termination(
if not (
advertising_set := (
self.extended_advertising_sets.get(advertising_handle)
or self.legacy_advertising_set
or (
self.legacy_advertising_set
if self.legacy_advertising_set
and (
self.legacy_advertising_set.advertising_handle
== advertising_handle
)
else None
)
)
):
logger.warning(f'advertising set {advertising_handle} not found')
Expand Down

0 comments on commit 5b10549

Please sign in to comment.