diff --git a/subsys/bluetooth/host/conn.c b/subsys/bluetooth/host/conn.c index 0aa0a7bee85..f532ed6a0a5 100644 --- a/subsys/bluetooth/host/conn.c +++ b/subsys/bluetooth/host/conn.c @@ -2293,19 +2293,6 @@ struct bt_conn *bt_conn_create_slave_le(const bt_addr_le_t *peer, if (conn) { switch (conn->state) { case BT_CONN_CONNECT_DIR_ADV: - /* Handle the case when advertising is stopped with - * bt_le_adv_stop function - */ - err = bt_le_adv_start_internal(¶m_int, NULL, 0, - NULL, 0, peer); - if (err && (err != -EALREADY)) { - BT_WARN("Directed advertising could not be" - " started: %d", err); - bt_conn_unref(conn); - return NULL; - } - - case BT_CONN_CONNECT: case BT_CONN_CONNECTED: return conn; case BT_CONN_DISCONNECTED: diff --git a/subsys/bluetooth/host/hci_core.c b/subsys/bluetooth/host/hci_core.c index 7bd62e298ef..4574711b0b5 100644 --- a/subsys/bluetooth/host/hci_core.c +++ b/subsys/bluetooth/host/hci_core.c @@ -5992,6 +5992,16 @@ int bt_le_adv_stop(void) return 0; } + if (IS_ENABLED(CONFIG_BT_PERIPHERAL)) { + struct bt_conn *conn; + + conn = bt_conn_lookup_state_le(NULL, BT_CONN_CONNECT_DIR_ADV); + if (conn) { + bt_conn_set_state(conn, BT_CONN_DISCONNECTED); + bt_conn_unref(conn); + } + } + err = set_advertise_enable(false); if (err) { return err;