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 5, 2024
1 parent 1a3272d commit 971e35a
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions bumble/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -2065,7 +2065,9 @@ 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()
await self.legacy_advertising_set.remove()
self.legacy_advertising_set = None
elif self.legacy_advertiser:
await self.legacy_advertiser.stop()
Expand Down Expand Up @@ -3541,11 +3543,9 @@ def on_advertising_set_termination(
connection_handle,
number_of_completed_extended_advertising_events,
):
# Legacy advertising set is also one of extended advertising sets.
if not (
advertising_set := (
self.extended_advertising_sets.get(advertising_handle)
or self.legacy_advertising_set
)
advertising_set := self.extended_advertising_sets.get(advertising_handle)
):
logger.warning(f'advertising set {advertising_handle} not found')
return
Expand Down

0 comments on commit 971e35a

Please sign in to comment.