Zephyr API Documentation  2.7.0-rc2
A Scalable Open Source RTOS
conn.h File Reference

Bluetooth connection handling. More...

#include <stdbool.h>
#include <bluetooth/bluetooth.h>
#include <bluetooth/hci_err.h>
#include <bluetooth/addr.h>
#include <bluetooth/gap.h>

Go to the source code of this file.

Data Structures

struct  bt_le_conn_param
 
struct  bt_conn_le_phy_info
 
struct  bt_conn_le_phy_param
 
struct  bt_conn_le_data_len_info
 
struct  bt_conn_le_data_len_param
 
struct  bt_conn_le_info
 
struct  bt_conn_br_info
 
struct  bt_conn_info
 
struct  bt_conn_le_remote_info
 
struct  bt_conn_br_remote_info
 
struct  bt_conn_remote_info
 Connection Remote Info Structure. More...
 
struct  bt_conn_le_tx_power
 
struct  bt_conn_le_create_param
 
struct  bt_conn_cb
 Connection callback structure. More...
 
struct  bt_conn_oob_info
 
struct  bt_conn_pairing_feat
 Pairing request and pairing response info structure. More...
 
struct  bt_conn_auth_cb
 
struct  bt_br_conn_param
 

Macros

#define BT_LE_CONN_PARAM_INIT(int_min, int_max, lat, to)
 Initialize connection parameters. More...
 
#define BT_LE_CONN_PARAM(int_min, int_max, lat, to)
 
#define BT_LE_CONN_PARAM_DEFAULT
 
#define BT_CONN_LE_PHY_PARAM_INIT(_pref_tx_phy, _pref_rx_phy)
 
#define BT_CONN_LE_PHY_PARAM(_pref_tx_phy, _pref_rx_phy)
 
#define BT_CONN_LE_PHY_PARAM_1M
 
#define BT_CONN_LE_PHY_PARAM_2M
 
#define BT_CONN_LE_PHY_PARAM_CODED
 
#define BT_CONN_LE_PHY_PARAM_ALL
 
#define BT_CONN_LE_DATA_LEN_PARAM_INIT(_tx_max_len, _tx_max_time)
 
#define BT_CONN_LE_DATA_LEN_PARAM(_tx_max_len, _tx_max_time)
 
#define BT_LE_DATA_LEN_PARAM_DEFAULT
 
#define BT_LE_DATA_LEN_PARAM_MAX
 
#define BT_CONN_ROLE_MASTER   __DEPRECATED_MACRO BT_CONN_ROLE_CENTRAL
 
#define BT_CONN_ROLE_SLAVE   __DEPRECATED_MACRO BT_CONN_ROLE_PERIPHERAL
 
#define BT_CONN_LE_CREATE_PARAM_INIT(_options, _interval, _window)
 Initialize create connection parameters. More...
 
#define BT_CONN_LE_CREATE_PARAM(_options, _interval, _window)
 
#define BT_CONN_LE_CREATE_CONN
 
#define BT_CONN_LE_CREATE_CONN_AUTO
 
#define BT_CONN_CB_DEFINE(_name)
 Register a callback structure for connection events. More...
 
#define BT_PASSKEY_INVALID   0xffffffff
 
#define BT_BR_CONN_PARAM_INIT(role_switch)
 Initialize BR/EDR connection parameters. More...
 
#define BT_BR_CONN_PARAM(role_switch)
 
#define BT_BR_CONN_PARAM_DEFAULT   BT_BR_CONN_PARAM(true)
 

Enumerations

enum  { BT_CONN_LE_PHY_OPT_NONE = 0 , BT_CONN_LE_PHY_OPT_CODED_S2 = BIT(0) , BT_CONN_LE_PHY_OPT_CODED_S8 = BIT(1) }
 
enum  {
  BT_CONN_TYPE_LE = BIT(0) , BT_CONN_TYPE_BR = BIT(1) , BT_CONN_TYPE_SCO = BIT(2) , BT_CONN_TYPE_ISO = BIT(3) ,
  BT_CONN_TYPE_ALL
}
 
enum  { BT_CONN_ROLE_CENTRAL = 0 , BT_CONN_ROLE_PERIPHERAL = 1 }
 
enum  bt_conn_le_tx_power_phy {
  BT_CONN_LE_TX_POWER_PHY_NONE , BT_CONN_LE_TX_POWER_PHY_1M , BT_CONN_LE_TX_POWER_PHY_2M , BT_CONN_LE_TX_POWER_PHY_CODED_S8 ,
  BT_CONN_LE_TX_POWER_PHY_CODED_S2
}
 
enum  { BT_CONN_LE_OPT_NONE = 0 , BT_CONN_LE_OPT_CODED = BIT(0) , BT_CONN_LE_OPT_NO_1M = BIT(1) }
 
enum  bt_security_t {
  BT_SECURITY_L0 , BT_SECURITY_L1 , BT_SECURITY_L2 , BT_SECURITY_L3 ,
  BT_SECURITY_L4 , BT_SECURITY_FORCE_PAIR = BIT(7)
}
 
enum  bt_security_err {
  BT_SECURITY_ERR_SUCCESS , BT_SECURITY_ERR_AUTH_FAIL , BT_SECURITY_ERR_PIN_OR_KEY_MISSING , BT_SECURITY_ERR_OOB_NOT_AVAILABLE ,
  BT_SECURITY_ERR_AUTH_REQUIREMENT , BT_SECURITY_ERR_PAIR_NOT_SUPPORTED , BT_SECURITY_ERR_PAIR_NOT_ALLOWED , BT_SECURITY_ERR_INVALID_PARAM ,
  BT_SECURITY_ERR_UNSPECIFIED
}
 

Functions

struct bt_conn * bt_conn_ref (struct bt_conn *conn)
 Increment a connection's reference count. More...
 
void bt_conn_unref (struct bt_conn *conn)
 Decrement a connection's reference count. More...
 
void bt_conn_foreach (int type, void(*func)(struct bt_conn *conn, void *data), void *data)
 Iterate through all existing connections. More...
 
struct bt_conn * bt_conn_lookup_addr_le (uint8_t id, const bt_addr_le_t *peer)
 Look up an existing connection by address. More...
 
const bt_addr_le_tbt_conn_get_dst (const struct bt_conn *conn)
 Get destination (peer) address of a connection. More...
 
uint8_t bt_conn_index (struct bt_conn *conn)
 Get array index of a connection. More...
 
int bt_conn_get_info (const struct bt_conn *conn, struct bt_conn_info *info)
 Get connection info. More...
 
int bt_conn_get_remote_info (struct bt_conn *conn, struct bt_conn_remote_info *remote_info)
 Get connection info for the remote device. More...
 
int bt_conn_le_get_tx_power_level (struct bt_conn *conn, struct bt_conn_le_tx_power *tx_power_level)
 Get connection transmit power level. More...
 
int bt_conn_le_param_update (struct bt_conn *conn, const struct bt_le_conn_param *param)
 Update the connection parameters. More...
 
int bt_conn_le_data_len_update (struct bt_conn *conn, const struct bt_conn_le_data_len_param *param)
 Update the connection transmit data length parameters. More...
 
int bt_conn_le_phy_update (struct bt_conn *conn, const struct bt_conn_le_phy_param *param)
 Update the connection PHY parameters. More...
 
int bt_conn_disconnect (struct bt_conn *conn, uint8_t reason)
 Disconnect from a remote device or cancel pending connection. More...
 
int bt_conn_le_create (const bt_addr_le_t *peer, const struct bt_conn_le_create_param *create_param, const struct bt_le_conn_param *conn_param, struct bt_conn **conn)
 Initiate an LE connection to a remote device. More...
 
int bt_conn_le_create_auto (const struct bt_conn_le_create_param *create_param, const struct bt_le_conn_param *conn_param)
 Automatically connect to remote devices in the filter accept list.. More...
 
int bt_conn_create_auto_stop (void)
 Stop automatic connect creation. More...
 
int bt_le_set_auto_conn (const bt_addr_le_t *addr, const struct bt_le_conn_param *param)
 Automatically connect to remote device if it's in range. More...
 
int bt_conn_set_security (struct bt_conn *conn, bt_security_t sec)
 Set security level for a connection. More...
 
bt_security_t bt_conn_get_security (struct bt_conn *conn)
 Get security level for a connection. More...
 
uint8_t bt_conn_enc_key_size (struct bt_conn *conn)
 Get encryption key size. More...
 
void bt_conn_cb_register (struct bt_conn_cb *cb)
 Register connection callbacks. More...
 
void bt_set_bondable (bool enable)
 Enable/disable bonding. More...
 
void bt_set_oob_data_flag (bool enable)
 Allow/disallow remote OOB data to be used for pairing. More...
 
int bt_le_oob_set_legacy_tk (struct bt_conn *conn, const uint8_t *tk)
 Set OOB Temporary Key to be used for pairing. More...
 
int bt_le_oob_set_sc_data (struct bt_conn *conn, const struct bt_le_oob_sc_data *oobd_local, const struct bt_le_oob_sc_data *oobd_remote)
 Set OOB data during LE Secure Connections (SC) pairing procedure. More...
 
int bt_le_oob_get_sc_data (struct bt_conn *conn, const struct bt_le_oob_sc_data **oobd_local, const struct bt_le_oob_sc_data **oobd_remote)
 Get OOB data used for LE Secure Connections (SC) pairing procedure. More...
 
int bt_passkey_set (unsigned int passkey)
 Set a fixed passkey to be used for pairing. More...
 
int bt_conn_auth_cb_register (const struct bt_conn_auth_cb *cb)
 Register authentication callbacks. More...
 
int bt_conn_auth_passkey_entry (struct bt_conn *conn, unsigned int passkey)
 Reply with entered passkey. More...
 
int bt_conn_auth_cancel (struct bt_conn *conn)
 Cancel ongoing authenticated pairing. More...
 
int bt_conn_auth_passkey_confirm (struct bt_conn *conn)
 Reply if passkey was confirmed to match by user. More...
 
int bt_conn_auth_pairing_confirm (struct bt_conn *conn)
 Reply if incoming pairing was confirmed by user. More...
 
int bt_conn_auth_pincode_entry (struct bt_conn *conn, const char *pin)
 Reply with entered PIN code. More...
 
struct bt_conn * bt_conn_create_br (const bt_addr_t *peer, const struct bt_br_conn_param *param)
 Initiate an BR/EDR connection to a remote device. More...
 
struct bt_conn * bt_conn_create_sco (const bt_addr_t *peer)
 Initiate an SCO connection to a remote device. More...
 

Detailed Description

Bluetooth connection handling.