10#ifndef ZEPHYR_INCLUDE_BLUETOOTH_CONN_H_
11#define ZEPHYR_INCLUDE_BLUETOOTH_CONN_H_
52#define BT_LE_CONN_PARAM_INIT(int_min, int_max, lat, to) \
54 .interval_min = (int_min), \
55 .interval_max = (int_max), \
67#define BT_LE_CONN_PARAM(int_min, int_max, lat, to) \
68 ((struct bt_le_conn_param[]) { \
69 BT_LE_CONN_PARAM_INIT(int_min, int_max, lat, to) \
77#define BT_LE_CONN_PARAM_DEFAULT BT_LE_CONN_PARAM(BT_GAP_INIT_CONN_INT_MIN, \
78 BT_GAP_INIT_CONN_INT_MAX, \
111#define BT_CONN_LE_PHY_PARAM_INIT(_pref_tx_phy, _pref_rx_phy) \
113 .options = BT_CONN_LE_PHY_OPT_NONE, \
114 .pref_tx_phy = (_pref_tx_phy), \
115 .pref_rx_phy = (_pref_rx_phy), \
123#define BT_CONN_LE_PHY_PARAM(_pref_tx_phy, _pref_rx_phy) \
124 ((struct bt_conn_le_phy_param []) { \
125 BT_CONN_LE_PHY_PARAM_INIT(_pref_tx_phy, _pref_rx_phy) \
129#define BT_CONN_LE_PHY_PARAM_1M BT_CONN_LE_PHY_PARAM(BT_GAP_LE_PHY_1M, \
133#define BT_CONN_LE_PHY_PARAM_2M BT_CONN_LE_PHY_PARAM(BT_GAP_LE_PHY_2M, \
137#define BT_CONN_LE_PHY_PARAM_CODED BT_CONN_LE_PHY_PARAM(BT_GAP_LE_PHY_CODED, \
141#define BT_CONN_LE_PHY_PARAM_ALL BT_CONN_LE_PHY_PARAM(BT_GAP_LE_PHY_1M | \
143 BT_GAP_LE_PHY_CODED, \
173#define BT_CONN_LE_DATA_LEN_PARAM_INIT(_tx_max_len, _tx_max_time) \
175 .tx_max_len = (_tx_max_len), \
176 .tx_max_time = (_tx_max_time), \
184#define BT_CONN_LE_DATA_LEN_PARAM(_tx_max_len, _tx_max_time) \
185 ((struct bt_conn_le_data_len_param[]) { \
186 BT_CONN_LE_DATA_LEN_PARAM_INIT(_tx_max_len, _tx_max_time) \
190#define BT_LE_DATA_LEN_PARAM_DEFAULT \
191 BT_CONN_LE_DATA_LEN_PARAM(BT_GAP_DATA_LEN_DEFAULT, \
192 BT_GAP_DATA_TIME_DEFAULT)
195#define BT_LE_DATA_LEN_PARAM_MAX \
196 BT_CONN_LE_DATA_LEN_PARAM(BT_GAP_DATA_LEN_MAX, \
197 BT_GAP_DATA_TIME_MAX)
304#if defined(CONFIG_BT_USER_PHY_UPDATE)
308#if defined(CONFIG_BT_USER_DATA_LEN_UPDATE)
321#define BT_CONN_INTERVAL_TO_MS(interval) ((interval) * 5U / 4U)
327#define BT_CONN_INTERVAL_TO_US(interval) ((interval) * 1250U)
351typedef enum __packed {
387#define BT_CONN_ROLE_MASTER __DEPRECATED_MACRO BT_CONN_ROLE_CENTRAL
388#define BT_CONN_ROLE_SLAVE __DEPRECATED_MACRO BT_CONN_ROLE_PERIPHERAL
651#define BT_CONN_LE_CREATE_PARAM_INIT(_options, _interval, _window) \
653 .options = (_options), \
654 .interval = (_interval), \
655 .window = (_window), \
656 .interval_coded = 0, \
667#define BT_CONN_LE_CREATE_PARAM(_options, _interval, _window) \
668 ((struct bt_conn_le_create_param[]) { \
669 BT_CONN_LE_CREATE_PARAM_INIT(_options, _interval, _window) \
675#define BT_CONN_LE_CREATE_CONN \
676 BT_CONN_LE_CREATE_PARAM(BT_CONN_LE_OPT_NONE, \
677 BT_GAP_SCAN_FAST_INTERVAL, \
678 BT_GAP_SCAN_FAST_INTERVAL)
684#define BT_CONN_LE_CREATE_CONN_AUTO \
685 BT_CONN_LE_CREATE_PARAM(BT_CONN_LE_OPT_NONE, \
686 BT_GAP_SCAN_FAST_INTERVAL, \
687 BT_GAP_SCAN_FAST_WINDOW)
711 struct bt_conn **conn);
966#if defined(CONFIG_BT_SMP)
980#if defined(CONFIG_BT_SMP) || defined(CONFIG_BT_BREDR)
1001#if defined(CONFIG_BT_REMOTE_INFO)
1014#if defined(CONFIG_BT_USER_PHY_UPDATE)
1027#if defined(CONFIG_BT_USER_DATA_LEN_UPDATE)
1040#if defined(CONFIG_BT_DF_CONNECTION_CTE_RX)
1047 void (*cte_report_cb)(
struct bt_conn *conn,
1067#define BT_CONN_CB_DEFINE(_name) \
1068 static const STRUCT_SECTION_ITERABLE(bt_conn_cb, \
1069 _CONCAT(bt_conn_cb_, \
1158#define BT_PASSKEY_INVALID 0xffffffff
1207#if defined(CONFIG_BT_SMP_APP_PAIRING_ACCEPT)
1241#if defined(CONFIG_BT_SMP_APP_PAIRING_ACCEPT)
1293#if defined(CONFIG_BT_PASSKEY_KEYPRESS)
1315 void (*passkey_display_keypress)(
struct bt_conn *conn,
1415#if defined(CONFIG_BT_BREDR)
1603#define BT_BR_CONN_PARAM_INIT(role_switch) \
1605 .allow_role_switch = (role_switch), \
1612#define BT_BR_CONN_PARAM(role_switch) \
1613 ((struct bt_br_conn_param[]) { \
1614 BT_BR_CONN_PARAM_INIT(role_switch) \
1620#define BT_BR_CONN_PARAM_DEFAULT BT_BR_CONN_PARAM(true)
Bluetooth device address definitions and utilities.
Bluetooth subsystem core APIs.
ZTEST_BMEM int timeout
Definition: main.c:31
Bluetooth Generic Access Profile defines and Assigned Numbers.
void bt_set_bondable(bool enable)
Enable/disable bonding.
struct bt_conn * bt_conn_ref(struct bt_conn *conn)
Increment a connection's reference count.
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_le_oob_set_legacy_tk(struct bt_conn *conn, const uint8_t *tk)
Set OOB Temporary Key to be used for pairing.
int bt_conn_disconnect(struct bt_conn *conn, uint8_t reason)
Disconnect from a remote device or cancel pending connection.
int bt_conn_auth_cb_register(const struct bt_conn_auth_cb *cb)
Register authentication callbacks.
struct bt_conn * bt_conn_lookup_addr_le(uint8_t id, const bt_addr_le_t *peer)
Look up an existing connection by address.
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_get_info(const struct bt_conn *conn, struct bt_conn_info *info)
Get connection info.
bt_security_flag
Definition: conn.h:369
int bt_passkey_set(unsigned int passkey)
Set a fixed passkey to be used for pairing.
void bt_conn_cb_register(struct bt_conn_cb *cb)
Register connection callbacks.
int bt_conn_auth_passkey_entry(struct bt_conn *conn, unsigned int passkey)
Reply with entered passkey.
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.
void bt_conn_unref(struct bt_conn *conn)
Decrement a connection's reference count.
bt_security_t bt_conn_get_security(const struct bt_conn *conn)
Get security level for a connection.
bt_conn_auth_keypress
Passkey Keypress Notification type.
Definition: conn.h:486
void bt_conn_foreach(int type, void(*func)(struct bt_conn *conn, void *data), void *data)
Iterate through all bt_conn objects.
int bt_conn_create_auto_stop(void)
Stop automatic connect creation.
int bt_conn_get_remote_info(struct bt_conn *conn, struct bt_conn_remote_info *remote_info)
Get connection info for the remote device.
bt_conn_le_tx_power_phy
Definition: conn.h:455
const bt_addr_le_t * bt_conn_get_dst(const struct bt_conn *conn)
Get destination (peer) address of a connection.
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_cancel(struct bt_conn *conn)
Cancel ongoing authenticated pairing.
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_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_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.
bt_conn_state
Definition: conn.h:339
void bt_le_oob_set_legacy_flag(bool enable)
Allow/disallow remote legacy OOB data to be used for pairing.
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_get_tx_power_level(struct bt_conn *conn, struct bt_conn_le_tx_power *tx_power_level)
Get connection transmit power level.
bt_security_err
Definition: conn.h:839
int bt_conn_le_param_update(struct bt_conn *conn, const struct bt_le_conn_param *param)
Update the connection parameters.
int bt_conn_auth_passkey_confirm(struct bt_conn *conn)
Reply if passkey was confirmed to match by user.
struct bt_conn * bt_conn_create_sco(const bt_addr_t *peer)
Initiate an SCO connection to a remote device.
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_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.
void bt_le_oob_set_sc_flag(bool enable)
Allow/disallow remote LE SC OOB data to be used for pairing.
uint8_t bt_conn_index(const struct bt_conn *conn)
Get array index of a connection.
int bt_conn_set_security(struct bt_conn *conn, bt_security_t sec)
Set security level for a connection.
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_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..
bt_security_t
Definition: conn.h:351
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.
uint8_t bt_conn_enc_key_size(const struct bt_conn *conn)
Get encryption key size.
@ BT_SECURITY_FLAG_OOB
Definition: conn.h:373
@ BT_SECURITY_FLAG_SC
Definition: conn.h:371
@ BT_CONN_AUTH_KEYPRESS_DIGIT_ERASED
Definition: conn.h:489
@ BT_CONN_AUTH_KEYPRESS_DIGIT_ENTERED
Definition: conn.h:488
@ BT_CONN_AUTH_KEYPRESS_CLEARED
Definition: conn.h:490
@ BT_CONN_AUTH_KEYPRESS_ENTRY_STARTED
Definition: conn.h:487
@ BT_CONN_AUTH_KEYPRESS_ENTRY_COMPLETED
Definition: conn.h:491
@ BT_CONN_LE_TX_POWER_PHY_NONE
Definition: conn.h:457
@ BT_CONN_LE_TX_POWER_PHY_CODED_S2
Definition: conn.h:465
@ BT_CONN_LE_TX_POWER_PHY_CODED_S8
Definition: conn.h:463
@ BT_CONN_LE_TX_POWER_PHY_1M
Definition: conn.h:459
@ BT_CONN_LE_TX_POWER_PHY_2M
Definition: conn.h:461
@ BT_CONN_LE_PHY_OPT_CODED_S2
Definition: conn.h:93
@ BT_CONN_LE_PHY_OPT_CODED_S8
Definition: conn.h:96
@ BT_CONN_LE_PHY_OPT_NONE
Definition: conn.h:90
@ BT_CONN_STATE_CONNECTING
Definition: conn.h:343
@ BT_CONN_STATE_CONNECTED
Definition: conn.h:345
@ BT_CONN_STATE_DISCONNECTED
Definition: conn.h:341
@ BT_CONN_STATE_DISCONNECTING
Definition: conn.h:347
@ BT_SECURITY_ERR_OOB_NOT_AVAILABLE
Definition: conn.h:850
@ BT_SECURITY_ERR_AUTH_REQUIREMENT
Definition: conn.h:853
@ BT_SECURITY_ERR_KEY_REJECTED
Definition: conn.h:865
@ BT_SECURITY_ERR_UNSPECIFIED
Definition: conn.h:868
@ BT_SECURITY_ERR_INVALID_PARAM
Definition: conn.h:862
@ BT_SECURITY_ERR_PAIR_NOT_SUPPORTED
Definition: conn.h:856
@ BT_SECURITY_ERR_AUTH_FAIL
Definition: conn.h:844
@ BT_SECURITY_ERR_PIN_OR_KEY_MISSING
Definition: conn.h:847
@ BT_SECURITY_ERR_SUCCESS
Definition: conn.h:841
@ BT_SECURITY_ERR_PAIR_NOT_ALLOWED
Definition: conn.h:859
@ BT_CONN_ROLE_PERIPHERAL
Definition: conn.h:336
@ BT_CONN_ROLE_CENTRAL
Definition: conn.h:335
@ BT_SECURITY_L4
Definition: conn.h:361
@ BT_SECURITY_L0
Definition: conn.h:353
@ BT_SECURITY_L3
Definition: conn.h:359
@ BT_SECURITY_FORCE_PAIR
Definition: conn.h:365
@ BT_SECURITY_L1
Definition: conn.h:355
@ BT_SECURITY_L2
Definition: conn.h:357
@ BT_CONN_TYPE_LE
Definition: conn.h:276
@ BT_CONN_TYPE_ALL
Definition: conn.h:284
@ BT_CONN_TYPE_BR
Definition: conn.h:278
@ BT_CONN_TYPE_ISO
Definition: conn.h:282
@ BT_CONN_TYPE_SCO
Definition: conn.h:280
@ BT_CONN_LE_OPT_NONE
Definition: conn.h:595
@ BT_CONN_LE_OPT_NO_1M
Disable LE 1M PHY.
Definition: conn.h:609
@ BT_CONN_LE_OPT_CODED
Enable LE Coded PHY.
Definition: conn.h:601
#define BIT(n)
Unsigned integer with bit position n set (signed in assembly language).
Definition: util_macro.h:44
struct _snode sys_snode_t
Definition: slist.h:33
#define bool
Definition: stdbool.h:13
__UINT32_TYPE__ uint32_t
Definition: stdint.h:90
__UINT8_TYPE__ uint8_t
Definition: stdint.h:88
__UINT16_TYPE__ uint16_t
Definition: stdint.h:89
__INT8_TYPE__ int8_t
Definition: stdint.h:72
bool allow_role_switch
Definition: conn.h:1596
void(* passkey_entry)(struct bt_conn *conn)
Request the user to enter a passkey.
Definition: conn.h:1337
void(* passkey_display)(struct bt_conn *conn, unsigned int passkey)
Display a passkey to the user.
Definition: conn.h:1291
void(* passkey_confirm)(struct bt_conn *conn, unsigned int passkey)
Request the user to confirm a passkey.
Definition: conn.h:1360
enum bt_security_err(* pairing_accept)(struct bt_conn *conn, const struct bt_conn_pairing_feat *const feat)
Query to proceed incoming pairing or not.
Definition: conn.h:1269
void(* pincode_entry)(struct bt_conn *conn, bool highsec)
Request the user to enter a passkey.
Definition: conn.h:1434
void(* oob_data_request)(struct bt_conn *conn, struct bt_conn_oob_info *info)
Request the user to provide Out of Band (OOB) data.
Definition: conn.h:1378
void(* pairing_confirm)(struct bt_conn *conn)
Request confirmation for an incoming pairing.
Definition: conn.h:1413
void(* cancel)(struct bt_conn *conn)
Cancel the ongoing user request.
Definition: conn.h:1393
void(* pairing_failed)(struct bt_conn *conn, enum bt_security_err reason)
notify that pairing process has failed.
Definition: conn.h:1456
void(* pairing_complete)(struct bt_conn *conn, bool bonded)
notify that pairing procedure was complete.
Definition: conn.h:1449
void(* bond_deleted)(uint8_t id, const bt_addr_le_t *peer)
Notify that bond has been deleted.
Definition: conn.h:1467
sys_snode_t node
Definition: conn.h:1470
const bt_addr_t * dst
Definition: conn.h:331
uint8_t num_pages
Definition: conn.h:425
const uint8_t * features
Definition: conn.h:422
Connection callback structure.
Definition: conn.h:881
void(* le_param_updated)(struct bt_conn *conn, uint16_t interval, uint16_t latency, uint16_t timeout)
The parameters for an LE connection have been updated.
Definition: conn.h:964
void(* le_data_len_updated)(struct bt_conn *conn, struct bt_conn_le_data_len_info *info)
The data length parameters of the connection has changed.
Definition: conn.h:1036
bool(* le_param_req)(struct bt_conn *conn, struct bt_le_conn_param *param)
LE connection parameter update request.
Definition: conn.h:951
void(* disconnected)(struct bt_conn *conn, uint8_t reason)
A connection has been disconnected.
Definition: conn.h:925
void(* connected)(struct bt_conn *conn, uint8_t err)
A new connection has been established.
Definition: conn.h:906
void(* le_phy_updated)(struct bt_conn *conn, struct bt_conn_le_phy_info *param)
The PHY of the connection has changed.
Definition: conn.h:1023
void(* security_changed)(struct bt_conn *conn, bt_security_t level, enum bt_security_err err)
The security level of a connection has changed.
Definition: conn.h:997
void(* identity_resolved)(struct bt_conn *conn, const bt_addr_le_t *rpa, const bt_addr_le_t *identity)
Remote Identity Address has been resolved.
Definition: conn.h:976
void(* remote_info_available)(struct bt_conn *conn, struct bt_conn_remote_info *remote_info)
Remote information procedures has completed.
Definition: conn.h:1010
uint8_t id
Definition: conn.h:397
struct bt_conn_le_info le
Definition: conn.h:401
uint8_t type
Definition: conn.h:393
struct bt_conn_br_info br
Definition: conn.h:403
uint8_t role
Definition: conn.h:395
struct bt_security_info security
Definition: conn.h:408
enum bt_conn_state state
Definition: conn.h:406
uint16_t interval_coded
Scan interval LE Coded PHY (N * 0.625 MS)
Definition: conn.h:627
uint16_t window
Definition: conn.h:621
uint32_t options
Definition: conn.h:615
uint16_t timeout
Connection initiation timeout (N * 10 MS)
Definition: conn.h:642
uint16_t interval
Definition: conn.h:618
uint16_t window_coded
Scan window LE Coded PHY (N * 0.625 MS)
Definition: conn.h:633
const bt_addr_le_t * peer
Remote address.
Definition: conn.h:720
uint8_t subevent
Definition: conn.h:723
uint16_t tx_max_time
Definition: conn.h:153
uint16_t rx_max_len
Definition: conn.h:155
uint16_t tx_max_len
Definition: conn.h:151
uint16_t rx_max_time
Definition: conn.h:157
uint16_t tx_max_len
Definition: conn.h:163
uint16_t tx_max_time
Definition: conn.h:165
const bt_addr_le_t * dst
Definition: conn.h:295
const struct bt_conn_le_phy_info * phy
Definition: conn.h:305
const bt_addr_le_t * remote
Definition: conn.h:299
const bt_addr_le_t * local
Definition: conn.h:297
const bt_addr_le_t * src
Definition: conn.h:291
uint16_t interval
Definition: conn.h:300
uint16_t latency
Definition: conn.h:301
const struct bt_conn_le_data_len_info * data_len
Definition: conn.h:310
uint16_t timeout
Definition: conn.h:302
uint8_t rx_phy
Definition: conn.h:84
uint8_t tx_phy
Definition: conn.h:83
uint16_t options
Definition: conn.h:101
uint8_t pref_rx_phy
Definition: conn.h:103
uint8_t pref_tx_phy
Definition: conn.h:102
const uint8_t * features
Definition: conn.h:415
int8_t max_level
Definition: conn.h:478
int8_t current_level
Definition: conn.h:475
uint8_t phy
Definition: conn.h:472
enum bt_conn_oob_info::@54 type
@ BT_CONN_OOB_LE_LEGACY
Definition: conn.h:1180
@ BT_CONN_OOB_LE_SC
Definition: conn.h:1183
@ BT_CONN_OOB_NO_DATA
Definition: conn.h:1201
@ BT_CONN_OOB_LOCAL_ONLY
Definition: conn.h:1192
@ BT_CONN_OOB_REMOTE_ONLY
Definition: conn.h:1195
@ BT_CONN_OOB_BOTH_PEERS
Definition: conn.h:1198
struct bt_conn_oob_info::@55::@57 lesc
enum bt_conn_oob_info::@55::@57::@58 oob_config
Pairing request and pairing response info structure.
Definition: conn.h:1214
uint8_t resp_key_dist
Definition: conn.h:1235
uint8_t io_capability
Definition: conn.h:1216
uint8_t init_key_dist
Definition: conn.h:1230
uint8_t max_enc_key_size
Definition: conn.h:1225
uint8_t auth_req
Definition: conn.h:1222
uint8_t oob_data_flag
Definition: conn.h:1219
Connection Remote Info Structure.
Definition: conn.h:433
uint8_t version
Definition: conn.h:438
uint16_t subversion
Definition: conn.h:444
uint16_t manufacturer
Definition: conn.h:441
uint8_t type
Definition: conn.h:435
struct bt_conn_br_remote_info br
Definition: conn.h:451
struct bt_conn_le_remote_info le
Definition: conn.h:448
Definition: direction.h:165
uint16_t latency
Definition: conn.h:41
uint16_t interval_max
Definition: conn.h:40
uint16_t timeout
Definition: conn.h:42
uint16_t interval_min
Definition: conn.h:39
Definition: bluetooth.h:2302
uint8_t enc_key_size
Definition: conn.h:381
bt_security_t level
Definition: conn.h:379
enum bt_security_flag flags
Definition: conn.h:383
static fdata_t data[2]
Definition: test_fifo_contexts.c:15