Skip to content

Commit

Permalink
[nrf fromtree] Bluetooth: HCI: Expose bt_hci_conn_lookup_handle()
Browse files Browse the repository at this point in the history
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 <[email protected]>
(cherry picked from commit 2967bd8)
  • Loading branch information
rugeGerritsen authored and nordicjm committed Aug 2, 2024
1 parent 2071857 commit 65acb95
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
12 changes: 12 additions & 0 deletions include/zephyr/bluetooth/hci.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,18 @@ int bt_hci_cmd_send_sync(uint16_t opcode, struct net_buf *buf,
*/
int bt_hci_get_conn_handle(const struct bt_conn *conn, uint16_t *conn_handle);

/** @brief Get connection given a connection handle.
*
* The caller gets a new reference to the connection object which must be
* released with bt_conn_unref() once done using the object.
*
* @param handle The connection handle
*
* @returns The corresponding connection object on success.
* NULL if it does not exist.
*/
struct bt_conn *bt_hci_conn_lookup_handle(uint16_t handle);

/** @brief Get advertising handle for an advertising set.
*
* @param adv Advertising set.
Expand Down
5 changes: 5 additions & 0 deletions subsys/bluetooth/host/conn.c
Original file line number Diff line number Diff line change
Expand Up @@ -1355,6 +1355,11 @@ struct bt_conn *bt_conn_lookup_handle(uint16_t handle, enum bt_conn_type type)
return NULL;
}

struct bt_conn *bt_hci_conn_lookup_handle(uint16_t handle)
{
return bt_conn_lookup_handle(handle, BT_CONN_TYPE_ALL);
}

void bt_conn_foreach(enum bt_conn_type type,
void (*func)(struct bt_conn *conn, void *data),
void *data)
Expand Down

0 comments on commit 65acb95

Please sign in to comment.