Zephyr API Documentation  3.6.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
conn.h File Reference

Bluetooth connection handling. More...

Go to the source code of this file.

Data Structures

struct  bt_le_conn_param
 Connection parameters for LE connections. More...
 
struct  bt_conn_le_phy_info
 Connection PHY information for LE connections. More...
 
struct  bt_conn_le_phy_param
 Preferred PHY parameters for LE connections. More...
 
struct  bt_conn_le_data_len_info
 Connection data length information for LE connections. More...
 
struct  bt_conn_le_data_len_param
 Connection data length parameters for LE connections. More...
 
struct  bt_conn_le_info
 LE Connection Info Structure. More...
 
struct  bt_conn_br_info
 BR/EDR Connection Info Structure. More...
 
struct  bt_security_info
 Security Info Structure. More...
 
struct  bt_conn_info
 Connection Info Structure. More...
 
struct  bt_conn_le_remote_info
 LE Connection Remote Info Structure. More...
 
struct  bt_conn_br_remote_info
 BR/EDR Connection Remote Info structure. More...
 
struct  bt_conn_remote_info
 Connection Remote Info Structure. More...
 
struct  bt_conn_le_tx_power
 LE Transmit Power Level Structure. More...
 
struct  bt_conn_le_tx_power_report
 LE Transmit Power Reporting Structure. More...
 
struct  bt_conn_le_create_param
 
struct  bt_conn_le_create_synced_param
 
struct  bt_conn_cb
 Connection callback structure. More...
 
struct  bt_conn_oob_info
 Info Structure for OOB pairing. More...
 
struct  bt_conn_pairing_feat
 Pairing request and pairing response info structure. More...
 
struct  bt_conn_auth_cb
 Authenticated pairing callback structure. More...
 
struct  bt_conn_auth_info_cb
 Authenticated pairing information callback structure. More...
 
struct  bt_br_conn_param
 Connection parameters for BR/EDR connections. More...
 

Macros

#define BT_LE_CONN_PARAM_INIT(int_min, int_max, lat, to)
 Initialize connection parameters.
 
#define BT_LE_CONN_PARAM(int_min, int_max, lat, to)
 Helper to declare connection parameters inline.
 
#define BT_LE_CONN_PARAM_DEFAULT
 Default LE connection parameters: Connection Interval: 30-50 ms Latency: 0 Timeout: 4 s.
 
#define BT_CONN_LE_PHY_PARAM_INIT(_pref_tx_phy, _pref_rx_phy)
 Initialize PHY parameters.
 
#define BT_CONN_LE_PHY_PARAM(_pref_tx_phy, _pref_rx_phy)
 Helper to declare PHY parameters inline.
 
#define BT_CONN_LE_PHY_PARAM_1M
 Only LE 1M PHY.
 
#define BT_CONN_LE_PHY_PARAM_2M
 Only LE 2M PHY.
 
#define BT_CONN_LE_PHY_PARAM_CODED
 Only LE Coded PHY.
 
#define BT_CONN_LE_PHY_PARAM_ALL
 All LE PHYs.
 
#define BT_CONN_LE_DATA_LEN_PARAM_INIT(_tx_max_len, _tx_max_time)
 Initialize transmit data length parameters.
 
#define BT_CONN_LE_DATA_LEN_PARAM(_tx_max_len, _tx_max_time)
 Helper to declare transmit data length parameters inline.
 
#define BT_LE_DATA_LEN_PARAM_DEFAULT
 Default LE data length parameters.
 
#define BT_LE_DATA_LEN_PARAM_MAX
 Maximum LE data length parameters.
 
#define BT_CONN_INTERVAL_TO_MS(interval)   ((interval) * 5U / 4U)
 Convert connection interval to milliseconds.
 
#define BT_CONN_INTERVAL_TO_US(interval)   ((interval) * 1250U)
 Convert connection interval to microseconds.
 
#define BT_CONN_ROLE_MASTER   __DEPRECATED_MACRO BT_CONN_ROLE_CENTRAL
 Connection role (central or peripheral)
 
#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.
 
#define BT_CONN_LE_CREATE_PARAM(_options, _interval, _window)
 Helper to declare create connection parameters inline.
 
#define BT_CONN_LE_CREATE_CONN
 Default LE create connection parameters.
 
#define BT_CONN_LE_CREATE_CONN_AUTO
 Default LE create connection using filter accept list parameters.
 
#define BT_CONN_CB_DEFINE(_name)
 Register a callback structure for connection events.
 
#define BT_PASSKEY_INVALID   0xffffffff
 Special passkey value that can be used to disable a previously set fixed passkey.
 
#define BT_BR_CONN_PARAM_INIT(role_switch)
 Initialize BR/EDR connection parameters.
 
#define BT_BR_CONN_PARAM(role_switch)
 Helper to declare BR/EDR connection parameters inline.
 
#define BT_BR_CONN_PARAM_DEFAULT   BT_BR_CONN_PARAM(true)
 Default BR/EDR connection parameters: Role switch allowed.
 

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) }
 Connection PHY options. More...
 
enum  bt_conn_type {
  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
}
 Connection Type. More...
 
enum  { BT_CONN_ROLE_CENTRAL = 0 , BT_CONN_ROLE_PERIPHERAL = 1 }
 
enum  bt_conn_state { BT_CONN_STATE_DISCONNECTED , BT_CONN_STATE_CONNECTING , BT_CONN_STATE_CONNECTED , BT_CONN_STATE_DISCONNECTING }
 
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)
}
 Security level. More...
 
enum  bt_security_flag { BT_SECURITY_FLAG_SC = BIT(0) , BT_SECURITY_FLAG_OOB = BIT(1) }
 Security Info Flags. More...
 
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_auth_keypress {
  BT_CONN_AUTH_KEYPRESS_ENTRY_STARTED = 0x00 , BT_CONN_AUTH_KEYPRESS_DIGIT_ENTERED = 0x01 , BT_CONN_AUTH_KEYPRESS_DIGIT_ERASED = 0x02 , BT_CONN_AUTH_KEYPRESS_CLEARED = 0x03 ,
  BT_CONN_AUTH_KEYPRESS_ENTRY_COMPLETED = 0x04
}
 Passkey Keypress Notification type. More...
 
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_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_KEY_REJECTED , BT_SECURITY_ERR_UNSPECIFIED
}
 

Functions

struct bt_conn * bt_conn_ref (struct bt_conn *conn)
 Increment a connection's reference count.
 
void bt_conn_unref (struct bt_conn *conn)
 Decrement a connection's reference count.
 
void bt_conn_foreach (enum bt_conn_type type, void(*func)(struct bt_conn *conn, void *data), void *data)
 Iterate through all bt_conn objects.
 
struct bt_conn * bt_conn_lookup_addr_le (uint8_t id, const bt_addr_le_t *peer)
 Look up an existing connection by address.
 
const bt_addr_le_tbt_conn_get_dst (const struct bt_conn *conn)
 Get destination (peer) address of a connection.
 
uint8_t bt_conn_index (const struct bt_conn *conn)
 Get array index of a connection.
 
int bt_conn_get_info (const struct bt_conn *conn, struct bt_conn_info *info)
 Get connection info.
 
int bt_conn_get_remote_info (struct bt_conn *conn, struct bt_conn_remote_info *remote_info)
 Get connection info for the remote device.
 
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.
 
int bt_conn_le_enhanced_get_tx_power_level (struct bt_conn *conn, struct bt_conn_le_tx_power *tx_power)
 Get local enhanced connection transmit power level.
 
int bt_conn_le_get_remote_tx_power_level (struct bt_conn *conn, enum bt_conn_le_tx_power_phy phy)
 Get remote (peer) transmit power level.
 
int bt_conn_le_set_tx_power_report_enable (struct bt_conn *conn, bool local_enable, bool remote_enable)
 Enable transmit power reporting.
 
int bt_conn_le_param_update (struct bt_conn *conn, const struct bt_le_conn_param *param)
 Update the connection parameters.
 
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.
 
int bt_conn_le_phy_update (struct bt_conn *conn, const struct bt_conn_le_phy_param *param)
 Update the connection PHY parameters.
 
int bt_conn_disconnect (struct bt_conn *conn, uint8_t reason)
 Disconnect from a remote device or cancel pending connection.
 
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.
 
int bt_conn_le_create_synced (const struct bt_le_ext_adv *adv, const struct bt_conn_le_create_synced_param *synced_param, const struct bt_le_conn_param *conn_param, struct bt_conn **conn)
 Create a connection to a synced device.
 
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.
 
int bt_conn_create_auto_stop (void)
 Stop automatic connect creation.
 
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.
 
int bt_conn_set_security (struct bt_conn *conn, bt_security_t sec)
 Set security level for a connection.
 
bt_security_t bt_conn_get_security (const struct bt_conn *conn)
 Get security level for a connection.
 
uint8_t bt_conn_enc_key_size (const struct bt_conn *conn)
 Get encryption key size.
 
void bt_conn_cb_register (struct bt_conn_cb *cb)
 Register connection callbacks.
 
int bt_conn_cb_unregister (struct bt_conn_cb *cb)
 Unregister connection callbacks.
 
void bt_set_bondable (bool enable)
 Enable/disable bonding.
 
int bt_conn_set_bondable (struct bt_conn *conn, bool enable)
 Set/clear the bonding flag for a given connection.
 
void bt_le_oob_set_sc_flag (bool enable)
 Allow/disallow remote LE SC OOB data to be used for pairing.
 
void bt_le_oob_set_legacy_flag (bool enable)
 Allow/disallow remote legacy OOB data to be used for pairing.
 
int bt_le_oob_set_legacy_tk (struct bt_conn *conn, const uint8_t *tk)
 Set OOB Temporary Key to be used for pairing.
 
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.
 
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.
 
int bt_passkey_set (unsigned int passkey)
 Set a fixed passkey to be used for pairing.
 
int bt_conn_auth_cb_register (const struct bt_conn_auth_cb *cb)
 Register authentication callbacks.
 
int bt_conn_auth_cb_overlay (struct bt_conn *conn, const struct bt_conn_auth_cb *cb)
 Overlay authentication callbacks used for a given connection.
 
int bt_conn_auth_info_cb_register (struct bt_conn_auth_info_cb *cb)
 Register authentication information callbacks.
 
int bt_conn_auth_info_cb_unregister (struct bt_conn_auth_info_cb *cb)
 Unregister authentication information callbacks.
 
int bt_conn_auth_passkey_entry (struct bt_conn *conn, unsigned int passkey)
 Reply with entered passkey.
 
int bt_conn_auth_keypress_notify (struct bt_conn *conn, enum bt_conn_auth_keypress type)
 Send Passkey Keypress Notification during pairing.
 
int bt_conn_auth_cancel (struct bt_conn *conn)
 Cancel ongoing authenticated pairing.
 
int bt_conn_auth_passkey_confirm (struct bt_conn *conn)
 Reply if passkey was confirmed to match by user.
 
int bt_conn_auth_pairing_confirm (struct bt_conn *conn)
 Reply if incoming pairing was confirmed by user.
 
int bt_conn_auth_pincode_entry (struct bt_conn *conn, const char *pin)
 Reply with entered PIN code.
 
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.
 

Detailed Description

Bluetooth connection handling.