Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix double-disable legacy advertising set #424

Merged
merged 1 commit into from
Feb 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading