Skip to content

Conversation

@laurensvalk
Copy link
Member

This should help us with #435, so we can avoid inserting POSIX code directly into bluetooth_btstack with #ifs. It also makes us use the standard BTstack IRQ poll mechanism to simplify the next step.

There is also an init hook that runs before any btstack code runs. This should help avoid having to do things like static bool already_ran = false; already_ran = already_ran just to get something to run once. This is where we could parse environment variables or set up logging, etc.

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>
@coveralls
Copy link

coveralls commented Dec 23, 2025

Coverage Status

coverage: 55.842% (+0.03%) from 55.816%
when pulling 4402e8a on btstack
into d92d07d on master.

uint16_t manufacturer;
/** LMP/PAL subversion. */
uint16_t lmp_pal_subversion;
} pbdrv_bluetooth_btstack_device_discriminator_t;
Copy link
Member

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;
Copy link
Member

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.

Comment on lines +232 to +236
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]);
Copy link
Member

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.

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.

4 participants