Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 0 additions & 17 deletions include/zephyr/bluetooth/conn.h
Original file line number Diff line number Diff line change
Expand Up @@ -1418,23 +1418,6 @@ int bt_conn_le_create_auto(const struct bt_conn_le_create_param *create_param,
*/
int bt_conn_create_auto_stop(void);

/** @brief Automatically connect to remote device if it's in range.
*
* This function enables/disables automatic connection initiation.
* Every time the device loses the connection with peer, this connection
* will be re-established if connectable advertisement from peer is received.
*
* @note Auto connect is disabled during explicit scanning.
*
* @param addr Remote Bluetooth address.
* @param param If non-NULL, auto connect is enabled with the given
* parameters. If NULL, auto connect is disabled.
*
* @return Zero on success or error code otherwise.
*/
int bt_le_set_auto_conn(const bt_addr_le_t *addr,
const struct bt_le_conn_param *param);

/** @brief Set security level for a connection.
*
* This function enable security (encryption) for a connection. If the device
Expand Down
70 changes: 0 additions & 70 deletions subsys/bluetooth/host/conn.c
Original file line number Diff line number Diff line change
Expand Up @@ -1851,18 +1851,6 @@ static int conn_disconnect(struct bt_conn *conn, uint8_t reason)

int bt_conn_disconnect(struct bt_conn *conn, uint8_t reason)
{
/* Disconnection is initiated by us, so auto connection shall
* be disabled. Otherwise the passive scan would be enabled
* and we could send LE Create Connection as soon as the remote
* starts advertising.
*/
#if !defined(CONFIG_BT_FILTER_ACCEPT_LIST)
if (IS_ENABLED(CONFIG_BT_CENTRAL) &&
conn->type == BT_CONN_TYPE_LE) {
bt_le_set_auto_conn(&conn->le.dst, NULL);
}
#endif /* !defined(CONFIG_BT_FILTER_ACCEPT_LIST) */

switch (conn->state) {
case BT_CONN_SCAN_BEFORE_INITIATING:
conn->err = reason;
Expand Down Expand Up @@ -3856,64 +3844,6 @@ int bt_conn_le_create_synced(const struct bt_le_ext_adv *adv,
return 0;
}

#if !defined(CONFIG_BT_FILTER_ACCEPT_LIST)
int bt_le_set_auto_conn(const bt_addr_le_t *addr,
const struct bt_le_conn_param *param)
{
struct bt_conn *conn;

if (!atomic_test_bit(bt_dev.flags, BT_DEV_READY)) {
return -EAGAIN;
}

if (param && !bt_le_conn_params_valid(param)) {
return -EINVAL;
}

if (!bt_id_scan_random_addr_check()) {
return -EINVAL;
}

/* Only default identity is supported */
conn = bt_conn_lookup_addr_le(BT_ID_DEFAULT, addr);
if (!conn) {
conn = bt_conn_add_le(BT_ID_DEFAULT, addr);
if (!conn) {
return -ENOMEM;
}
}

if (param) {
bt_conn_set_param_le(conn, param);

if (!atomic_test_and_set_bit(conn->flags,
BT_CONN_AUTO_CONNECT)) {
bt_conn_ref(conn);
}
} else {
if (atomic_test_and_clear_bit(conn->flags,
BT_CONN_AUTO_CONNECT)) {
bt_conn_unref(conn);
if (conn->state == BT_CONN_SCAN_BEFORE_INITIATING) {
bt_conn_set_state(conn, BT_CONN_DISCONNECTED);
}
}
}

int err = 0;
if (conn->state == BT_CONN_DISCONNECTED &&
atomic_test_bit(bt_dev.flags, BT_DEV_READY)) {
if (param) {
bt_conn_set_state(conn, BT_CONN_SCAN_BEFORE_INITIATING);
err = bt_le_scan_user_add(BT_LE_SCAN_USER_CONN);
}
}

bt_conn_unref(conn);

return err;
}
#endif /* !defined(CONFIG_BT_FILTER_ACCEPT_LIST) */
#endif /* CONFIG_BT_CENTRAL */

int bt_conn_le_conn_update(struct bt_conn *conn,
Expand Down
2 changes: 1 addition & 1 deletion subsys/bluetooth/host/conn_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ typedef enum __packed {
enum {
/** The connection context is used for automatic connection establishment
*
* That is, with @ref bt_conn_le_create_auto() or bt_le_set_auto_conn().
* That is, with @ref bt_conn_le_create_auto().
* This flag is set even after the connection has been established so
* that the connection can be reestablished once disconnected.
* The connection establishment may be performed with or without the filter
Expand Down
30 changes: 0 additions & 30 deletions subsys/bluetooth/host/shell/bt.c
Original file line number Diff line number Diff line change
Expand Up @@ -3320,33 +3320,6 @@ static int cmd_connect_le(const struct shell *sh, size_t argc, char *argv[])
return 0;
}

#if !defined(CONFIG_BT_FILTER_ACCEPT_LIST)
static int cmd_auto_conn(const struct shell *sh, size_t argc, char *argv[])
{
bt_addr_le_t addr;
int err;

err = bt_addr_le_from_str(argv[1], argv[2], &addr);
if (err) {
shell_error(sh, "Invalid peer address (err %d)", err);
return err;
}

if (argc < 4) {
return bt_le_set_auto_conn(&addr, BT_LE_CONN_PARAM_DEFAULT);
} else if (!strcmp(argv[3], "on")) {
return bt_le_set_auto_conn(&addr, BT_LE_CONN_PARAM_DEFAULT);
} else if (!strcmp(argv[3], "off")) {
return bt_le_set_auto_conn(&addr, NULL);
} else {
shell_help(sh);
return SHELL_CMD_HELP_PRINTED;
}

return 0;
}
#endif /* !defined(CONFIG_BT_FILTER_ACCEPT_LIST) */

static int cmd_connect_le_name(const struct shell *sh, size_t argc, char *argv[])
{
const struct bt_le_scan_param param = {
Expand Down Expand Up @@ -5075,9 +5048,6 @@ SHELL_STATIC_SUBCMD_SET_CREATE(bt_cmds,
#if defined(CONFIG_BT_CENTRAL)
SHELL_CMD_ARG(connect, NULL, HELP_ADDR_LE EXT_ADV_SCAN_OPT,
cmd_connect_le, 1, 3),
#if !defined(CONFIG_BT_FILTER_ACCEPT_LIST)
SHELL_CMD_ARG(auto-conn, NULL, HELP_ADDR_LE, cmd_auto_conn, 3, 0),
#endif /* !defined(CONFIG_BT_FILTER_ACCEPT_LIST) */
SHELL_CMD_ARG(connect-name, NULL, "<name filter>",
cmd_connect_le_name, 2, 0),
#endif /* CONFIG_BT_CENTRAL */
Expand Down
Loading