struct hci_chan *hci_chan_lookup_handle(struct hci_dev *hdev, __u16 handle);
struct hci_conn *hci_connect_le(struct hci_dev *hdev, bdaddr_t *dst,
- u8 dst_type, u8 sec_level, u16 conn_timeout);
+ u8 dst_type, u8 sec_level, u16 conn_timeout,
+ bool master);
struct hci_conn *hci_connect_acl(struct hci_dev *hdev, bdaddr_t *dst,
u8 sec_level, u8 auth_type);
struct hci_conn *hci_connect_sco(struct hci_dev *hdev, int type, bdaddr_t *dst,
}
struct hci_conn *hci_connect_le(struct hci_dev *hdev, bdaddr_t *dst,
- u8 dst_type, u8 sec_level, u16 conn_timeout)
+ u8 dst_type, u8 sec_level, u16 conn_timeout,
+ bool master)
{
struct hci_conn_params *params;
struct hci_conn *conn;
hci_req_init(&req, hdev);
- if (test_bit(HCI_ADVERTISING, &hdev->dev_flags)) {
+ /* If requested to connect as slave use directed advertising */
+ if (!master) {
hci_req_directed_advertising(&req, conn);
goto create_conn;
}
return;
connect:
+ /* Request connection in master = true role */
conn = hci_connect_le(hdev, addr, addr_type, BT_SECURITY_LOW,
- HCI_LE_AUTOCONN_TIMEOUT);
+ HCI_LE_AUTOCONN_TIMEOUT, true);
if (!IS_ERR(conn))
return;
chan->dcid = cid;
if (bdaddr_type_is_le(dst_type)) {
+ bool master;
+
/* Convert from L2CAP channel address type to HCI address type
*/
if (dst_type == BDADDR_LE_PUBLIC)
else
dst_type = ADDR_LE_DEV_RANDOM;
+ master = !test_bit(HCI_ADVERTISING, &hdev->dev_flags);
+
hcon = hci_connect_le(hdev, dst, dst_type, chan->sec_level,
- HCI_LE_CONN_TIMEOUT);
+ HCI_LE_CONN_TIMEOUT, master);
} else {
u8 auth_type = l2cap_get_auth_type(chan);
hcon = hci_connect_acl(hdev, dst, chan->sec_level, auth_type);
*/
hci_conn_params_add(hdev, &cp->addr.bdaddr, addr_type);
+ /* Request a connection with master = true role */
conn = hci_connect_le(hdev, &cp->addr.bdaddr, addr_type,
- sec_level, HCI_LE_CONN_TIMEOUT);
+ sec_level, HCI_LE_CONN_TIMEOUT, true);
}
if (IS_ERR(conn)) {