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

Add advertiser classes and handle adv set terminated events #366

Merged
merged 2 commits into from
Dec 8, 2023

Conversation

zxzxwu
Copy link
Collaborator

@zxzxwu zxzxwu commented Dec 6, 2023

  • Convert hci.OwnAddressType to enum
  • Add LegacyAdvertiser and ExtendedAdvertiser classes
  • Rename start/stop_advertising() => start/stop_legacy_advertising()
  • Handle HCI_Advertising_Set_Terminated
  • Properly restart advertisement on disconnection

@zxzxwu
Copy link
Collaborator Author

zxzxwu commented Dec 6, 2023

Maybe we should merge this request after we have a way to test extended advertising?

bumble/device.py Outdated

adv_handle = -1
# Find a free handle
for i in range(
DEVICE_MIN_EXTENDED_ADVERTISING_SET_HANDLE,
DEVICE_MAX_EXTENDED_ADVERTISING_SET_HANDLE + 1,
):
if i not in self.extended_advertising_handles:
if i not in self.extended_advertisers.keys():
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: if i not in self.extended_advertisers should be sufficient.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this could provide a better readability?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either way is fine, but in general I think it is more readable to use the standard/idiomatic way of using collections.
For looking up a key in a dict, the recommended way in most style guides is to just use key in dict (see https://google.github.io/styleguide/pyguide.html#284-decision for example).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's fair. Modified.

bumble/host.py Show resolved Hide resolved
bumble/host.py Outdated Show resolved Hide resolved
* Convert hci.OwnAddressType to enum
* Add LegacyAdvertiser and ExtendedAdvertiser classes
* Rename start/stop_advertising() => start/stop_legacy_advertising()
* Handle HCI_Advertising_Set_Terminated
* Properly restart advertisement on disconnection
@zxzxwu zxzxwu mentioned this pull request Dec 7, 2023
4 tasks
@zxzxwu zxzxwu merged commit 698d947 into google:main Dec 8, 2023
51 checks passed
@zxzxwu zxzxwu deleted the extadv branch December 12, 2023 05:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants