Skip to content

Commit

Permalink
Bluetooth: hci_sync: Wait for proper events when connecting LE
Browse files Browse the repository at this point in the history
When using HCI_OP_LE_CREATE_CONN wait for HCI_EV_LE_CONN_COMPLETE before
completing it and for HCI_OP_LE_EXT_CREATE_CONN wait for
HCI_EV_LE_ENHANCED_CONN_COMPLETE before resuming advertising.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
  • Loading branch information
Luiz Augusto von Dentz authored and Marcel Holtmann committed Dec 22, 2021
1 parent 85b5685 commit 6cd29ec
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions net/bluetooth/hci_sync.c
Original file line number Diff line number Diff line change
Expand Up @@ -5182,8 +5182,10 @@ int hci_le_ext_create_conn_sync(struct hci_dev *hdev, struct hci_conn *conn,
plen += sizeof(*p);
}

return __hci_cmd_sync_status(hdev, HCI_OP_LE_EXT_CREATE_CONN,
plen, data, HCI_CMD_TIMEOUT);
return __hci_cmd_sync_status_sk(hdev, HCI_OP_LE_EXT_CREATE_CONN,
plen, data,
HCI_EV_LE_ENHANCED_CONN_COMPLETE,
HCI_CMD_TIMEOUT, NULL);
}

int hci_le_create_conn_sync(struct hci_dev *hdev, struct hci_conn *conn)
Expand Down Expand Up @@ -5269,8 +5271,9 @@ int hci_le_create_conn_sync(struct hci_dev *hdev, struct hci_conn *conn)
cp.min_ce_len = cpu_to_le16(0x0000);
cp.max_ce_len = cpu_to_le16(0x0000);

err = __hci_cmd_sync_status(hdev, HCI_OP_LE_CREATE_CONN,
sizeof(cp), &cp, HCI_CMD_TIMEOUT);
err = __hci_cmd_sync_status_sk(hdev, HCI_OP_LE_CREATE_CONN,
sizeof(cp), &cp, HCI_EV_LE_CONN_COMPLETE,
HCI_CMD_TIMEOUT, NULL);

done:
hci_resume_advertising_sync(hdev);
Expand Down

0 comments on commit 6cd29ec

Please sign in to comment.