-
-
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
base: master
Are you sure you want to change the base?
Conversation
This is needed for the POSIX port, so we don't have to make special handlers to protect init from running twice.
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>
| uint16_t manufacturer; | ||
| /** LMP/PAL subversion. */ | ||
| uint16_t lmp_pal_subversion; | ||
| } pbdrv_bluetooth_btstack_device_discriminator_t; |
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 would put local_version_info in the name rather than device_discriminator. The latter describes one use for it, but the former describes what it actually is and where it came from.
This is just an unpacked version of the return values from HCI Read Local Version Info.
| // not used | ||
| } | ||
|
|
||
| static bool do_poll_handler; |
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.
Probably should be volatile if pbdrv_bluetooth_btstack_run_loop_trigger() is called from IRQ handlers.
| info.hci_version = rp[1]; | ||
| info.hci_revision = pbio_get_uint16_le(&rp[2]); | ||
| info.lmp_pal_version = rp[4]; | ||
| info.manufacturer = pbio_get_uint16_le(&rp[5]); | ||
| info.lmp_pal_subversion = pbio_get_uint16_le(&rp[7]); |
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.
It wouldn't hurt to put this unpacking in a separate function.
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.