Bluetooth: HCI: Add function to get connection handle of connection

Add public API function to get the connection handle of the connection.
The connection handle is needed by applications that intend to send
vendor specific commands for a given connection.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
This commit is contained in:
Joakim Andersson 2019-10-15 17:47:26 +02:00 committed by Carles Cufí
parent e53ee2d383
commit 0f06c7d8e4
2 changed files with 20 additions and 0 deletions

View file

@ -16,6 +16,7 @@
#include <net/buf.h>
#include <bluetooth/addr.h>
#include <bluetooth/hci_err.h>
#include <bluetooth/conn.h>
#ifdef __cplusplus
extern "C" {
@ -1768,6 +1769,15 @@ int bt_hci_cmd_send(u16_t opcode, struct net_buf *buf);
int bt_hci_cmd_send_sync(u16_t opcode, struct net_buf *buf,
struct net_buf **rsp);
/** @brief Get connection handle for a connection.
*
* @param conn Connection object.
* @param conn_handle Place to store the Connection handle.
*
* @return 0 on success or negative error value on failure.
*/
int bt_hci_get_conn_handle(const struct bt_conn *conn, u16_t *conn_handle);
/** @typedef bt_hci_vnd_evt_cb_t
* @brief Callback type for vendor handling of HCI Vendor-Specific Events.
*

View file

@ -3607,6 +3607,16 @@ static void le_adv_report(struct net_buf *buf)
}
#endif /* CONFIG_BT_OBSERVER */
int bt_hci_get_conn_handle(const struct bt_conn *conn, u16_t *conn_handle)
{
if (conn->state != BT_CONN_CONNECTED) {
return -ENOTCONN;
}
*conn_handle = conn->handle;
return 0;
}
#if defined(CONFIG_BT_HCI_VS_EVT_USER)
int bt_hci_register_vnd_evt_cb(bt_hci_vnd_evt_cb_t cb)
{