Bluetooth: Convert bt_conn_set_auto_conn to bt_le_set_auto_conn
Once we start persistently storing the addresses of devices we want to reconnect to we also need a way to reload them to the stack. Since we don't have a connection object at this point the API cannot take that as a parameter. Instead rename the function and have it take bt_addr_le_t as a parameter. The feature was also lacking proper reference counting for the connection, which this patch now adds (the flag itself owns a reference). The function is now also possible to call before bt_init() so that if we load the stack with multiple devices the HCI doesn't get bombarded with lots of scan enable/disable commands. Change-Id: I9072bf061eb64f2ecec96f74fb176be13e5bdaee Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This commit is contained in:
parent
f443be7205
commit
5a5061ef97
4 changed files with 58 additions and 26 deletions
|
@ -749,15 +749,6 @@ int bt_conn_get_info(const struct bt_conn *conn, struct bt_conn_info *info)
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
void bt_conn_set_auto_conn(struct bt_conn *conn, bool auto_conn)
|
||||
{
|
||||
if (auto_conn) {
|
||||
atomic_set_bit(conn->flags, BT_CONN_AUTO_CONNECT);
|
||||
} else {
|
||||
atomic_clear_bit(conn->flags, BT_CONN_AUTO_CONNECT);
|
||||
}
|
||||
}
|
||||
|
||||
static int bt_hci_disconnect(struct bt_conn *conn, uint8_t reason)
|
||||
{
|
||||
struct net_buf *buf;
|
||||
|
@ -805,12 +796,16 @@ static int bt_hci_connect_le_cancel(struct bt_conn *conn)
|
|||
|
||||
int bt_conn_disconnect(struct bt_conn *conn, uint8_t reason)
|
||||
{
|
||||
#if defined(CONFIG_BLUETOOTH_CENTRAL)
|
||||
/* 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.
|
||||
*/
|
||||
bt_conn_set_auto_conn(conn, false);
|
||||
if (conn->type == BT_CONN_TYPE_LE) {
|
||||
bt_le_set_auto_conn(&conn->le.dst, false);
|
||||
}
|
||||
#endif
|
||||
|
||||
switch (conn->state) {
|
||||
case BT_CONN_CONNECT_SCAN:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue