-
-
Notifications
You must be signed in to change notification settings - Fork 82
pbio/drv/bluetooth_btstack: Generalizations to prepare for POSIX variant. #442
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
Open
laurensvalk
wants to merge
14
commits into
master
Choose a base branch
from
btstack
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This is needed for the POSIX port, so we don't have to make special handlers to protect init from running twice.
dlech
reviewed
Dec 23, 2025
Most BTstack ports do it this way, including embedded variants. This will let us use the POSIX libusb variant without modifying it.
This is needed for the POSIX port, which needs to poll files.
Co-authored-by: James Aguilar <aguilar.james@gmail.com>
This will provide stdio even when Bluetooth is not enabled. The current Bluetooth mock driver does this too so we are currently duplicating it, but this will be replaced by an actual Bluetooth driver shortly.
This lets us test BLE features on the REPL as we enable the new Virtual Hub driver, so we can see it working.
In practice, we are allowing users to reinstantiate the hub. The question is whether we really should, but for now the simulation should be consistent with reality.
The POSIX variant needs to handle specific packets that are not relevant to the other platforms.
This will redirect debug output to usb and uart, when available.
No need to hook directly into the uart driver anymore.
We don't need duplicates for EV3 and the POSIX variants.
We call this again when we discover the local version. We shouldn't be calling this twice.
The pbdrv_bluetooth_is_connected check should protect against this, but if it fails we get a segfault if config was never set, so if no peripheral was ever connected.
On some platforms it may not be enabled, e.g. when the USB Bluetooth dongle is not plugged in.
dlech
approved these changes
Dec 29, 2025
Member
dlech
left a comment
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.
LGTM
| // Proceed to start Bluetooth process only if platform init passes. | ||
| pbio_error_t err = pbdrv_bluetooth_btstack_platform_init(); | ||
| if (err != PBIO_SUCCESS) { | ||
| return; |
Member
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.
Useful to debug print error code here?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This should help us with #435, so we can avoid inserting POSIX code directly into
bluetooth_btstackwith#ifs. It also makes us use the standard BTstack IRQ poll mechanism to simplify the next step.There is also an
inithook that runs before any btstack code runs. This should help avoid having to do things likestatic bool already_ran = false; already_ran = already_ranjust to get something to run once. This is where we could parse environment variables or set up logging, etc.