aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClaudio Takahasi <claudio.takahasi@openbossa.org>2011-02-16 17:44:53 -0500
committerGustavo F. Padovan <padovan@profusion.mobi>2011-02-16 18:13:21 -0500
commit2ce603ebe1f1420c7c5b013638ec29b4fc975180 (patch)
treeb315468b139f2bd7b7f8bbe45a3d32090dda01a2
parent6bd32326cdaa9b14794416150c88e4832fb7e592 (diff)
Bluetooth: Send LE Connection Update Command
If the new connection update parameter are accepted, the LE master host sends the LE Connection Update Command to its controller informing the new requested parameters. Signed-off-by: Claudio Takahasi <claudio.takahasi@openbossa.org> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
-rw-r--r--include/net/bluetooth/hci.h11
-rw-r--r--include/net/bluetooth/hci_core.h2
-rw-r--r--net/bluetooth/hci_conn.c20
-rw-r--r--net/bluetooth/l2cap_core.c8
4 files changed, 40 insertions, 1 deletions
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index 6d4e11624fef..a5f8c4684a32 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -677,6 +677,17 @@ struct hci_cp_le_create_conn {
677 677
678#define HCI_OP_LE_CREATE_CONN_CANCEL 0x200e 678#define HCI_OP_LE_CREATE_CONN_CANCEL 0x200e
679 679
680#define HCI_OP_LE_CONN_UPDATE 0x2013
681struct hci_cp_le_conn_update {
682 __le16 handle;
683 __le16 conn_interval_min;
684 __le16 conn_interval_max;
685 __le16 conn_latency;
686 __le16 supervision_timeout;
687 __le16 min_ce_len;
688 __le16 max_ce_len;
689} __packed;
690
680/* ---- HCI Events ---- */ 691/* ---- HCI Events ---- */
681#define HCI_EV_INQUIRY_COMPLETE 0x01 692#define HCI_EV_INQUIRY_COMPLETE 0x01
682 693
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index ecd2acf24420..7ee921d78a94 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -777,4 +777,6 @@ struct hci_sec_filter {
777 777
778void hci_req_complete(struct hci_dev *hdev, __u16 cmd, int result); 778void hci_req_complete(struct hci_dev *hdev, __u16 cmd, int result);
779 779
780void hci_le_conn_update(struct hci_conn *conn, u16 min, u16 max,
781 u16 latency, u16 to_multiplier);
780#endif /* __HCI_CORE_H */ 782#endif /* __HCI_CORE_H */
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index efcd2b508f5d..a050a6984901 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -183,6 +183,26 @@ void hci_setup_sync(struct hci_conn *conn, __u16 handle)
183 hci_send_cmd(hdev, HCI_OP_SETUP_SYNC_CONN, sizeof(cp), &cp); 183 hci_send_cmd(hdev, HCI_OP_SETUP_SYNC_CONN, sizeof(cp), &cp);
184} 184}
185 185
186void hci_le_conn_update(struct hci_conn *conn, u16 min, u16 max,
187 u16 latency, u16 to_multiplier)
188{
189 struct hci_cp_le_conn_update cp;
190 struct hci_dev *hdev = conn->hdev;
191
192 memset(&cp, 0, sizeof(cp));
193
194 cp.handle = cpu_to_le16(conn->handle);
195 cp.conn_interval_min = cpu_to_le16(min);
196 cp.conn_interval_max = cpu_to_le16(max);
197 cp.conn_latency = cpu_to_le16(latency);
198 cp.supervision_timeout = cpu_to_le16(to_multiplier);
199 cp.min_ce_len = cpu_to_le16(0x0001);
200 cp.max_ce_len = cpu_to_le16(0x0001);
201
202 hci_send_cmd(hdev, HCI_OP_LE_CONN_UPDATE, sizeof(cp), &cp);
203}
204EXPORT_SYMBOL(hci_le_conn_update);
205
186/* Device _must_ be locked */ 206/* Device _must_ be locked */
187void hci_sco_setup(struct hci_conn *conn, __u8 status) 207void hci_sco_setup(struct hci_conn *conn, __u8 status)
188{ 208{
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index e0e7b82cff02..bd3136710360 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -2529,6 +2529,7 @@ static inline int l2cap_conn_param_update_req(struct l2cap_conn *conn,
2529 struct l2cap_conn_param_update_req *req; 2529 struct l2cap_conn_param_update_req *req;
2530 struct l2cap_conn_param_update_rsp rsp; 2530 struct l2cap_conn_param_update_rsp rsp;
2531 u16 min, max, latency, to_multiplier, cmd_len; 2531 u16 min, max, latency, to_multiplier, cmd_len;
2532 int err;
2532 2533
2533 if (!(hcon->link_mode & HCI_LM_MASTER)) 2534 if (!(hcon->link_mode & HCI_LM_MASTER))
2534 return -EINVAL; 2535 return -EINVAL;
@@ -2547,7 +2548,9 @@ static inline int l2cap_conn_param_update_req(struct l2cap_conn *conn,
2547 min, max, latency, to_multiplier); 2548 min, max, latency, to_multiplier);
2548 2549
2549 memset(&rsp, 0, sizeof(rsp)); 2550 memset(&rsp, 0, sizeof(rsp));
2550 if (l2cap_check_conn_param(min, max, latency, to_multiplier)) 2551
2552 err = l2cap_check_conn_param(min, max, latency, to_multiplier);
2553 if (err)
2551 rsp.result = cpu_to_le16(L2CAP_CONN_PARAM_REJECTED); 2554 rsp.result = cpu_to_le16(L2CAP_CONN_PARAM_REJECTED);
2552 else 2555 else
2553 rsp.result = cpu_to_le16(L2CAP_CONN_PARAM_ACCEPTED); 2556 rsp.result = cpu_to_le16(L2CAP_CONN_PARAM_ACCEPTED);
@@ -2555,6 +2558,9 @@ static inline int l2cap_conn_param_update_req(struct l2cap_conn *conn,
2555 l2cap_send_cmd(conn, cmd->ident, L2CAP_CONN_PARAM_UPDATE_RSP, 2558 l2cap_send_cmd(conn, cmd->ident, L2CAP_CONN_PARAM_UPDATE_RSP,
2556 sizeof(rsp), &rsp); 2559 sizeof(rsp), &rsp);
2557 2560
2561 if (!err)
2562 hci_le_conn_update(hcon, min, max, latency, to_multiplier);
2563
2558 return 0; 2564 return 0;
2559} 2565}
2560 2566