Skip to content

Commit 49b020c

Browse files
Alain Michaudholtmann
authored andcommitted
Bluetooth: Adding a configurable autoconnect timeout
This patch adds a configurable LE autoconnect timeout. Signed-off-by: Alain Michaud <[email protected]> Signed-off-by: Marcel Holtmann <[email protected]>
1 parent 343ad39 commit 49b020c

File tree

4 files changed

+16
-1
lines changed

4 files changed

+16
-1
lines changed

include/net/bluetooth/hci_core.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,7 @@ struct hci_dev {
376376
__u16 def_br_lsto;
377377
__u16 def_page_timeout;
378378
__u16 def_multi_adv_rotation_duration;
379+
__u16 def_le_autoconnect_timeout;
379380

380381
__u16 pkt_type;
381382
__u16 esco_type;

net/bluetooth/hci_core.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3569,6 +3569,7 @@ struct hci_dev *hci_alloc_dev(void)
35693569
hdev->le_rx_def_phys = HCI_LE_SET_PHY_1M;
35703570
hdev->le_num_of_adv_sets = HCI_MAX_ADV_INSTANCES;
35713571
hdev->def_multi_adv_rotation_duration = HCI_DEFAULT_ADV_DURATION;
3572+
hdev->def_le_autoconnect_timeout = HCI_LE_AUTOCONN_TIMEOUT;
35723573

35733574
hdev->rpa_timeout = HCI_DEFAULT_RPA_TIMEOUT;
35743575
hdev->discov_interleaved_timeout = DISCOV_INTERLEAVED_TIMEOUT;

net/bluetooth/hci_event.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5315,7 +5315,7 @@ static struct hci_conn *check_pending_le_conn(struct hci_dev *hdev,
53155315
}
53165316

53175317
conn = hci_connect_le(hdev, addr, addr_type, BT_SECURITY_LOW,
5318-
HCI_LE_AUTOCONN_TIMEOUT, HCI_ROLE_MASTER,
5318+
hdev->def_le_autoconnect_timeout, HCI_ROLE_MASTER,
53195319
direct_rpa);
53205320
if (!IS_ERR(conn)) {
53215321
/* If HCI_AUTO_CONN_EXPLICIT is set, conn is already owned

net/bluetooth/mgmt_config.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@
1717
{ cpu_to_le16(hdev->_param_name_) } \
1818
}
1919

20+
#define HDEV_PARAM_U16_JIFFIES_TO_MSECS(_param_code_, _param_name_) \
21+
{ \
22+
{ cpu_to_le16(_param_code_), sizeof(__u16) }, \
23+
{ cpu_to_le16(jiffies_to_msecs(hdev->_param_name_)) } \
24+
}
25+
2026
int read_def_system_config(struct sock *sk, struct hci_dev *hdev, void *data,
2127
u16 data_len)
2228
{
@@ -59,6 +65,8 @@ int read_def_system_config(struct sock *sk, struct hci_dev *hdev, void *data,
5965
HDEV_PARAM_U16(0x0018, le_conn_max_interval),
6066
HDEV_PARAM_U16(0x0019, le_conn_latency),
6167
HDEV_PARAM_U16(0x001a, le_supv_timeout),
68+
HDEV_PARAM_U16_JIFFIES_TO_MSECS(0x001b,
69+
def_le_autoconnect_timeout),
6270
};
6371
struct mgmt_rp_read_def_system_config *rp = (void *)params;
6472

@@ -129,6 +137,7 @@ int set_def_system_config(struct sock *sk, struct hci_dev *hdev, void *data,
129137
case 0x0018:
130138
case 0x0019:
131139
case 0x001a:
140+
case 0x001b:
132141
if (len != sizeof(u16)) {
133142
bt_dev_warn(hdev, "invalid length %d, exp %zu for type %d",
134143
len, sizeof(u16), type);
@@ -238,6 +247,10 @@ int set_def_system_config(struct sock *sk, struct hci_dev *hdev, void *data,
238247
case 0x0001a:
239248
hdev->le_supv_timeout = TLV_GET_LE16(buffer);
240249
break;
250+
case 0x0001b:
251+
hdev->def_le_autoconnect_timeout =
252+
msecs_to_jiffies(TLV_GET_LE16(buffer));
253+
break;
241254
default:
242255
bt_dev_warn(hdev, "unsupported parameter %u", type);
243256
break;

0 commit comments

Comments
 (0)