Bluetooth: HCI: Expose bt_hci_per_adv_sync_lookup_handle()

When implementing vendor specific HCI APIs and events,
we want to be able to convert between host objects,
handles and back again.

Exposing this API makes that possible.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
This commit is contained in:
Rubin Gerritsen 2024-07-23 12:47:45 +02:00 committed by Anas Nashif
parent 5b14748616
commit e28207d61b
5 changed files with 16 additions and 9 deletions

View file

@ -140,6 +140,15 @@ struct bt_le_ext_adv *bt_hci_adv_lookup_handle(uint8_t handle);
*/
int bt_hci_get_adv_sync_handle(const struct bt_le_per_adv_sync *sync, uint16_t *sync_handle);
/** @brief Get periodic advertising sync given an periodic advertising sync handle.
*
* @param handle The periodic sync set handle
*
* @retval The corresponding periodic advertising sync set object on success,
* NULL if it does not exist.
*/
struct bt_le_per_adv_sync *bt_hci_per_adv_sync_lookup_handle(uint16_t handle);
/** @brief Obtain the version string given a core version number.
*
* The core version of a controller can be obtained by issuing

View file

@ -383,7 +383,7 @@ int hci_df_prepare_connectionless_iq_report(struct net_buf *buf,
evt = net_buf_pull_mem(buf, sizeof(*evt));
per_adv_sync = bt_hci_get_per_adv_sync(sys_le16_to_cpu(evt->sync_handle));
per_adv_sync = bt_hci_per_adv_sync_lookup_handle(sys_le16_to_cpu(evt->sync_handle));
if (!per_adv_sync) {
LOG_ERR("Unknown handle 0x%04X for iq samples report",
@ -431,7 +431,7 @@ int hci_df_vs_prepare_connectionless_iq_report(struct net_buf *buf,
evt = net_buf_pull_mem(buf, sizeof(*evt));
per_adv_sync = bt_hci_get_per_adv_sync(sys_le16_to_cpu(evt->sync_handle));
per_adv_sync = bt_hci_per_adv_sync_lookup_handle(sys_le16_to_cpu(evt->sync_handle));
if (!per_adv_sync) {
LOG_ERR("Unknown handle 0x%04X for iq samples report",

View file

@ -1683,7 +1683,7 @@ static void le_enh_conn_complete_v2(struct net_buf *buf)
/* Created via PAwR sync, no adv set terminated event, needs separate handling */
struct bt_le_per_adv_sync *sync;
sync = bt_hci_get_per_adv_sync(evt->sync_handle);
sync = bt_hci_per_adv_sync_lookup_handle(evt->sync_handle);
if (!sync) {
LOG_ERR("Unknown sync handle %d", evt->sync_handle);

View file

@ -784,7 +784,7 @@ void bt_periodic_sync_disable(void)
}
}
struct bt_le_per_adv_sync *bt_hci_get_per_adv_sync(uint16_t handle)
struct bt_le_per_adv_sync *bt_hci_per_adv_sync_lookup_handle(uint16_t handle)
{
for (int i = 0; i < ARRAY_SIZE(per_adv_sync_pool); i++) {
if (per_adv_sync_pool[i].handle == handle &&
@ -845,7 +845,7 @@ static void bt_hci_le_per_adv_report_common(struct net_buf *buf)
evt = net_buf_pull_mem(buf, sizeof(*evt));
per_adv_sync = bt_hci_get_per_adv_sync(sys_le16_to_cpu(evt->handle));
per_adv_sync = bt_hci_per_adv_sync_lookup_handle(sys_le16_to_cpu(evt->handle));
if (!per_adv_sync) {
LOG_ERR("Unknown handle 0x%04X for periodic advertising report",
@ -1202,7 +1202,7 @@ void bt_hci_le_per_adv_sync_lost(struct net_buf *buf)
(struct bt_hci_evt_le_per_adv_sync_lost *)buf->data;
struct bt_le_per_adv_sync *per_adv_sync;
per_adv_sync = bt_hci_get_per_adv_sync(sys_le16_to_cpu(evt->handle));
per_adv_sync = bt_hci_per_adv_sync_lookup_handle(sys_le16_to_cpu(evt->handle));
if (!per_adv_sync) {
LOG_ERR("Unknown handle 0x%04Xfor periodic adv sync lost",
@ -1367,7 +1367,7 @@ void bt_hci_le_biginfo_adv_report(struct net_buf *buf)
evt = net_buf_pull_mem(buf, sizeof(*evt));
per_adv_sync = bt_hci_get_per_adv_sync(sys_le16_to_cpu(evt->sync_handle));
per_adv_sync = bt_hci_per_adv_sync_lookup_handle(sys_le16_to_cpu(evt->sync_handle));
if (!per_adv_sync) {
LOG_ERR("Unknown handle 0x%04X for periodic advertising report",

View file

@ -11,6 +11,4 @@ bool bt_id_scan_random_addr_check(void);
int bt_le_scan_set_enable(uint8_t enable);
struct bt_le_per_adv_sync *bt_hci_get_per_adv_sync(uint16_t handle);
void bt_periodic_sync_disable(void);