Bluetooth: Update LE Exchange Features event handler
Adds conditions to trigger L2CAP based Update Connection Parameters and HCI based Connection Parameters Request Procedure. Change-Id: I66e4a977b534afc4a10d4eba54ee3eb95c2166ef Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com> Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
This commit is contained in:
parent
d3dc91e73a
commit
87b219cc05
3 changed files with 38 additions and 18 deletions
|
@ -746,6 +746,32 @@ static int hci_le_read_remote_features(struct bt_conn *conn)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int update_conn_params(struct bt_conn *conn)
|
||||
{
|
||||
BT_DBG("status %u, handle %u,features 0x%x\n", evt->status, handle,
|
||||
conn->le_features[0]);
|
||||
|
||||
/* Check if there's a need to update conn params */
|
||||
if (conn->le_conn_interval >= LE_CONN_MIN_INTERVAL &&
|
||||
conn->le_conn_interval <= LE_CONN_MAX_INTERVAL) {
|
||||
return -EALREADY;
|
||||
}
|
||||
|
||||
if ((conn->role == BT_HCI_ROLE_SLAVE) &&
|
||||
!(bt_dev.le_features[0] & BT_HCI_LE_CONN_PARAM_REQ_PROC)) {
|
||||
return bt_l2cap_update_conn_param(conn);
|
||||
}
|
||||
|
||||
if ((conn->le_features[0] & BT_HCI_LE_CONN_PARAM_REQ_PROC) &&
|
||||
(bt_dev.le_features[0] & BT_HCI_LE_CONN_PARAM_REQ_PROC)) {
|
||||
return bt_conn_le_conn_update(conn, LE_CONN_MIN_INTERVAL,
|
||||
LE_CONN_MAX_INTERVAL,
|
||||
LE_CONN_LATENCY, LE_CONN_TIMEOUT);
|
||||
}
|
||||
|
||||
return -EBUSY;
|
||||
}
|
||||
|
||||
static void le_conn_complete(struct bt_buf *buf)
|
||||
{
|
||||
struct bt_hci_evt_le_conn_complete *evt = (void *)buf->data;
|
||||
|
@ -806,14 +832,11 @@ static void le_conn_complete(struct bt_buf *buf)
|
|||
if (!err) {
|
||||
goto done;
|
||||
}
|
||||
} else if (!(bt_dev.le_features[0] & BT_HCI_LE_CONN_PARAM_REQ_PROC)) {
|
||||
err = bt_l2cap_update_conn_param(conn);
|
||||
if (!err) {
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
bt_conn_connected(conn);
|
||||
if (update_conn_params(conn)) {
|
||||
bt_conn_connected(conn);
|
||||
}
|
||||
|
||||
done:
|
||||
bt_conn_put(conn);
|
||||
|
@ -837,7 +860,9 @@ static void le_remote_feat_complete(struct bt_buf *buf)
|
|||
sizeof(conn->le_features));
|
||||
}
|
||||
|
||||
/* TODO Update connection parameters or notify about connection */
|
||||
if (update_conn_params(conn)) {
|
||||
bt_conn_connected(conn);
|
||||
}
|
||||
|
||||
bt_conn_put(conn);
|
||||
}
|
||||
|
|
|
@ -51,6 +51,12 @@
|
|||
#define lmp_bredr_capable(dev) (!((dev).features[4] & BT_LMP_NO_BREDR))
|
||||
#define lmp_le_capable(dev) ((dev).features[4] & BT_LMP_LE)
|
||||
|
||||
/* LL connection parameters */
|
||||
#define LE_CONN_MIN_INTERVAL 0x0028
|
||||
#define LE_CONN_MAX_INTERVAL 0x0038
|
||||
#define LE_CONN_LATENCY 0x0000
|
||||
#define LE_CONN_TIMEOUT 0x002a
|
||||
|
||||
/* bt_dev flags: the flags defined here represent BT controller state */
|
||||
enum {
|
||||
BT_DEV_ADVERTISING,
|
||||
|
|
|
@ -52,11 +52,6 @@
|
|||
#define BT_DBG(fmt, ...)
|
||||
#endif
|
||||
|
||||
#define LE_CONN_MIN_INTERVAL 0x0028
|
||||
#define LE_CONN_MAX_INTERVAL 0x0038
|
||||
#define LE_CONN_LATENCY 0x0000
|
||||
#define LE_CONN_TIMEOUT 0x002a
|
||||
|
||||
#define BT_L2CAP_CONN_PARAM_ACCEPTED 0
|
||||
#define BT_L2CAP_CONN_PARAM_REJECTED 1
|
||||
|
||||
|
@ -324,12 +319,6 @@ int bt_l2cap_update_conn_param(struct bt_conn *conn)
|
|||
struct bt_l2cap_conn_param_req *req;
|
||||
struct bt_buf *buf;
|
||||
|
||||
/* Check if we need to update anything */
|
||||
if (conn->le_conn_interval >= LE_CONN_MIN_INTERVAL &&
|
||||
conn->le_conn_interval <= LE_CONN_MAX_INTERVAL) {
|
||||
return -EALREADY;
|
||||
}
|
||||
|
||||
buf = bt_l2cap_create_pdu(conn);
|
||||
if (!buf) {
|
||||
return -ENOBUFS;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue