summaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorSudha Bheemanna <b.sudha@samsung.com>2016-09-08 12:24:43 +0530
committerSeung-Woo Kim <sw0312.kim@samsung.com>2016-12-14 13:53:17 +0900
commit8095ed769f41eebf5d5878f7172e056d6215878f (patch)
tree6ea0903fe76bb5e1e552ddd7ed9d59544c5b137e /net
parentbfb2d61eeee235c0b8c8787a3bc43bfd565b8596 (diff)
Bluetooth: Set link Supervision timeout for a connection
This patch allows to set the supervision timeout for a connection if the device role is master. Change-Id: I7897167ec07803f3059f2ab4d3314b0b7a951533 Signed-off-by: Sudha Bheemanna <b.sudha@samsung.com>
Diffstat (limited to 'net')
-rw-r--r--net/bluetooth/hci_conn.c27
-rw-r--r--net/bluetooth/hci_core.c7
-rw-r--r--net/bluetooth/hci_event.c10
3 files changed, 44 insertions, 0 deletions
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index 24a1965b1d23..420ebf1aebcd 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -1147,6 +1147,29 @@ int hci_conn_switch_role(struct hci_conn *conn, __u8 role)
}
EXPORT_SYMBOL(hci_conn_switch_role);
+#ifdef TIZEN_BT
+int hci_conn_change_supervision_timeout(struct hci_conn *conn, __u16 timeout)
+{
+ struct hci_cp_write_link_supervision_timeout cp;
+
+ if (!((get_link_mode(conn)) & HCI_LM_MASTER))
+ return 1;
+
+ if (conn->handle == 0)
+ return 1;
+
+ memset(&cp, 0, sizeof(cp));
+ cp.handle = cpu_to_le16(conn->handle);
+ cp.timeout = cpu_to_le16(timeout);
+
+ if (hci_send_cmd(conn->hdev, HCI_OP_WRITE_LINK_SUPERVISION_TIMEOUT,
+ sizeof(cp), &cp) < 0)
+ BT_ERR("HCI_OP_WRITE_LINK_SUPERVISION_TIMEOUT is failed");
+
+ return 0;
+}
+#endif
+
/* Enter active mode */
void hci_conn_enter_active_mode(struct hci_conn *conn, __u8 force_active)
{
@@ -1204,7 +1227,11 @@ void hci_conn_check_pending(struct hci_dev *hdev)
hci_dev_unlock(hdev);
}
+#ifndef TIZEN_BT
static u32 get_link_mode(struct hci_conn *conn)
+#else
+u32 get_link_mode(struct hci_conn *conn)
+#endif
{
u32 link_mode = 0;
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index dd2cf2ac14d5..c821ee72c8fc 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -3092,12 +3092,19 @@ struct hci_dev *hci_alloc_dev(void)
hdev->adv_tx_power = HCI_TX_POWER_INVALID;
hdev->sniff_max_interval = 800;
+#ifdef TIZEN_BT
+ hdev->sniff_min_interval = 400;
+#else
hdev->sniff_min_interval = 80;
+#endif
hdev->le_adv_channel_map = 0x07;
hdev->le_adv_min_interval = 0x0800;
hdev->le_adv_max_interval = 0x0800;
#ifdef TIZEN_BT
+ /* automatically enable sniff mode for connection */
+ hdev->idle_timeout = TIZEN_SNIFF_TIMEOUT * 1000;
+
hdev->adv_filter_policy = 0x00;
hdev->adv_type = 0x00;
#endif
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 1a63bceb8c69..169ff4302382 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -2400,6 +2400,11 @@ static void hci_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
hci_send_cmd(hdev, HCI_OP_CHANGE_CONN_PTYPE, sizeof(cp),
&cp);
}
+#ifdef TIZEN_BT
+ if (get_link_mode(conn) & HCI_LM_MASTER)
+ hci_conn_change_supervision_timeout(conn,
+ LINK_SUPERVISION_TIMEOUT);
+#endif
} else {
conn->state = BT_CLOSED;
if (conn->type == ACL_LINK)
@@ -3343,6 +3348,11 @@ static void hci_role_change_evt(struct hci_dev *hdev, struct sk_buff *skb)
clear_bit(HCI_CONN_RSWITCH_PEND, &conn->flags);
hci_role_switch_cfm(conn, ev->status, ev->role);
+#ifdef TIZEN_BT
+ if (!ev->status && (get_link_mode(conn) & HCI_LM_MASTER))
+ hci_conn_change_supervision_timeout(conn,
+ LINK_SUPERVISION_TIMEOUT);
+#endif
}
hci_dev_unlock(hdev);