Skip to content

Commit f30bed3

Browse files
kipm-otjhedberg
authored andcommitted
Bluetooth: Host: Enable/Disable Automatic Sending of Conn Parameter update
Added a new Kconfig flag to enable/disable this feature. Signed-off-by: Kiran Paramaswaran <[email protected]>
1 parent 6412c07 commit f30bed3

File tree

2 files changed

+41
-30
lines changed

2 files changed

+41
-30
lines changed

subsys/bluetooth/host/Kconfig.gatt

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,16 +84,23 @@ config BT_GATT_READ_MULTIPLE
8484
This option enables support for the GATT Read Multiple Characteristic
8585
Values procedure.
8686

87+
config BT_GAP_AUTO_UPDATE_CONN_PARAMS
88+
bool "Automatic Update of Connection Parameters"
89+
default y
90+
depends on BT_PERIPHERAL
91+
help
92+
This option if enabled allows automatically sending request for connection
93+
parameters update after GAP recommended 5 seconds of connection as
94+
peripheral.
95+
8796
config BT_GAP_PERIPHERAL_PREF_PARAMS
8897
bool "Configure peripheral preferred connection parameters"
8998
default y
9099
depends on BT_PERIPHERAL
91100
help
92101
This allows to configure peripheral preferred connection parameters.
93-
Enabling this option results in adding PPCP characteristic in GAP
94-
and sending request for connection parameters update after GAP
95-
recommended 5 seconds of connection as peripheral. If disabled it is
96-
up to application to set expected connection parameters.
102+
Enabling this option results in adding PPCP characteristic in GAP.
103+
If disabled it is up to application to set expected connection parameters.
97104

98105
if BT_GAP_PERIPHERAL_PREF_PARAMS
99106
config BT_PERIPHERAL_PREF_MIN_INT

subsys/bluetooth/host/conn.c

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -331,34 +331,38 @@ static void conn_update_timeout(struct k_work *work)
331331
return;
332332
}
333333

334-
#if defined (CONFIG_BT_GAP_PERIPHERAL_PREF_PARAMS)
335-
/* if application set own params use those, otherwise use defaults */
336-
if (atomic_test_and_clear_bit(conn->flags, BT_CONN_SLAVE_PARAM_SET)) {
337-
param = BT_LE_CONN_PARAM(conn->le.interval_min,
338-
conn->le.interval_max,
339-
conn->le.pending_latency,
340-
conn->le.pending_timeout);
341-
342-
send_conn_le_param_update(conn, param);
343-
} else {
344-
param = BT_LE_CONN_PARAM(CONFIG_BT_PERIPHERAL_PREF_MIN_INT,
345-
CONFIG_BT_PERIPHERAL_PREF_MAX_INT,
346-
CONFIG_BT_PERIPHERAL_PREF_SLAVE_LATENCY,
347-
CONFIG_BT_PERIPHERAL_PREF_TIMEOUT);
348-
349-
send_conn_le_param_update(conn, param);
350-
}
334+
if (IS_ENABLED(CONFIG_BT_GAP_AUTO_UPDATE_CONN_PARAMS)) {
335+
#if defined(CONFIG_BT_GAP_PERIPHERAL_PREF_PARAMS)
336+
/* if application set own params use those, otherwise
337+
* use defaults
338+
*/
339+
if (atomic_test_and_clear_bit(conn->flags,
340+
BT_CONN_SLAVE_PARAM_SET)) {
341+
param = BT_LE_CONN_PARAM(conn->le.interval_min,
342+
conn->le.interval_max,
343+
conn->le.pending_latency,
344+
conn->le.pending_timeout);
345+
send_conn_le_param_update(conn, param);
346+
} else {
347+
param = BT_LE_CONN_PARAM(
348+
CONFIG_BT_PERIPHERAL_PREF_MIN_INT,
349+
CONFIG_BT_PERIPHERAL_PREF_MAX_INT,
350+
CONFIG_BT_PERIPHERAL_PREF_SLAVE_LATENCY,
351+
CONFIG_BT_PERIPHERAL_PREF_TIMEOUT);
352+
send_conn_le_param_update(conn, param);
353+
}
351354
#else
352-
/* update only if application set own params */
353-
if (atomic_test_and_clear_bit(conn->flags, BT_CONN_SLAVE_PARAM_SET)) {
354-
param = BT_LE_CONN_PARAM(conn->le.interval_min,
355-
conn->le.interval_max,
356-
conn->le.latency,
357-
conn->le.timeout);
358-
359-
send_conn_le_param_update(conn, param);
360-
}
355+
/* update only if application set own params */
356+
if (atomic_test_and_clear_bit(conn->flags,
357+
BT_CONN_SLAVE_PARAM_SET)) {
358+
param = BT_LE_CONN_PARAM(conn->le.interval_min,
359+
conn->le.interval_max,
360+
conn->le.latency,
361+
conn->le.timeout);
362+
send_conn_le_param_update(conn, param);
363+
}
361364
#endif
365+
}
362366

363367
atomic_set_bit(conn->flags, BT_CONN_SLAVE_PARAM_UPDATE);
364368
}

0 commit comments

Comments
 (0)