Skip to content

Commit

Permalink
Merge pull request #424 from zxzxwu/adv
Browse files Browse the repository at this point in the history
Fix double-disable legacy advertising set
  • Loading branch information
zxzxwu authored Feb 6, 2024
2 parents f4aeaa6 + 9eccc58 commit 90f4926
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 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 @@ -2207,9 +2209,6 @@ def is_advertising(self):
if self.legacy_advertiser:
return True

if self.legacy_advertising_set and self.legacy_advertising_set.enabled:
return True

return any(
advertising_set.enabled
for advertising_set in self.extended_advertising_sets.values()
Expand Down Expand Up @@ -3541,11 +3540,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 90f4926

Please sign in to comment.