-
Notifications
You must be signed in to change notification settings - Fork 78
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
controller extended advertising #238
base: main
Are you sure you want to change the base?
Conversation
print() | ||
print(color('LMP Features:', 'yellow')) | ||
# TODO: support printing discrete enum values | ||
print(' ', response.return_parameters.lmp_features.hex()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be helpful to parse features into set
or IntFlag
or something else because sometimes we need to check controller capabilities for both dev and product evaluation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. I'll try to add that in a separate PR.
f58fb83
to
00ed035
Compare
) | ||
if response.return_parameters.status == HCI_SUCCESS: | ||
if response.return_parameters.max_page_number > 0: | ||
print() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the empty line intended?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. That's to ensure a blank line before the section.
bumble/controller.py
Outdated
|
||
|
||
# ----------------------------------------------------------------------------- | ||
def supported_commands_as_bytes(supported_commands): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def supported_commands_as_bytes(supported_commands): | |
def supported_commands_as_bytes(supported_commands: Sequence[HCI_Command]) -> bytes: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
bumble/controller.py
Outdated
@@ -78,6 +173,25 @@ class DataObject: | |||
pass | |||
|
|||
|
|||
# ----------------------------------------------------------------------------- | |||
def le_supported_features_as_bytes(supported_features): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def le_supported_features_as_bytes(supported_features): | |
def le_supported_features_as_bytes(supported_features: Sequence[int]) -> bytes: |
) | ||
) is None: | ||
return bytes([HCI_UNKNOWN_ADVERTISING_IDENTIFIER_ERROR]) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Add a TODO here to replace literals with Operation enums
bumble/controller.py
Outdated
else: | ||
self.stop_advertising() | ||
self.legacy_advertiser.enabled = True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.legacy_advertiser.enabled = True | |
self.legacy_advertiser.enabled = False |
bumble/controller.py
Outdated
@property | ||
def is_advertising(self): | ||
return self.advertising_timer_handle is not None | ||
# Extended advertising |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should all advertisers send data on each of them was scheduled?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is refactored now
bumble/controller.py
Outdated
self.advertising_timer_handle = asyncio.get_running_loop().call_soon( | ||
self.on_advertising_timer_fired | ||
# Compute the time of the next advertisement | ||
next_advertisement = min( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: This could be replaced with a heapq
# Advertiser
def send_advertising_data(self):
...
heappush(timer_heap, (time.time()+interval, self))
def on_advertising_timer_fired(self):
next_advertisement, advertiser = heappop(timer_heap)
advertiser.send_advertising_data()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
By the way, as RootCanal has implemented most of the feature, can we leverage the work instead of remaking the wheels? |
That’s exactly the plan: the local controller class is not intended to be compete and will not be enhanced in the future. It is only there to continue support for basic local unit testing and used by a few external users who have not moved to RootCanal yet. But now that RootCanal is available as a standalone project, the plan is to use that for any sort of full-feature need. |
23dfb1e
to
d12b15b
Compare
Enables basic support for extended advertising in the virtual controller object.