From 999a91e30da2a51c85258ca21bafd4bd44be4353 Mon Sep 17 00:00:00 2001 From: Joakim Andersson Date: Tue, 13 Oct 2020 13:27:16 +0200 Subject: [PATCH] Bluetooth: host: Fix application conn param update not started Fix application conn param update submitted before the timeout of CONFIG_BT_CONN_PARAM_UPDATE has expired being ignored when CONFIG_BT_GAP_AUTO_UPDATE_CONN_PARAMS=n. Signed-off-by: Joakim Andersson --- subsys/bluetooth/host/conn.c | 34 +++++++++++++++------------------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/subsys/bluetooth/host/conn.c b/subsys/bluetooth/host/conn.c index 32102069d4..c5711733d4 100644 --- a/subsys/bluetooth/host/conn.c +++ b/subsys/bluetooth/host/conn.c @@ -376,27 +376,23 @@ static void deferred_work(struct k_work *work) return; } - if (IS_ENABLED(CONFIG_BT_GAP_AUTO_UPDATE_CONN_PARAMS)) { - /* if application set own params use those, otherwise - * use defaults. - */ - if (atomic_test_and_clear_bit(conn->flags, - BT_CONN_SLAVE_PARAM_SET)) { - param = BT_LE_CONN_PARAM(conn->le.interval_min, - conn->le.interval_max, - conn->le.pending_latency, - conn->le.pending_timeout); - send_conn_le_param_update(conn, param); - } else { + /* if application set own params use those, otherwise use defaults. */ + if (atomic_test_and_clear_bit(conn->flags, + BT_CONN_SLAVE_PARAM_SET)) { + param = BT_LE_CONN_PARAM(conn->le.interval_min, + conn->le.interval_max, + conn->le.pending_latency, + conn->le.pending_timeout); + send_conn_le_param_update(conn, param); + } else if (IS_ENABLED(CONFIG_BT_GAP_AUTO_UPDATE_CONN_PARAMS)) { #if defined(CONFIG_BT_GAP_PERIPHERAL_PREF_PARAMS) - param = BT_LE_CONN_PARAM( - CONFIG_BT_PERIPHERAL_PREF_MIN_INT, - CONFIG_BT_PERIPHERAL_PREF_MAX_INT, - CONFIG_BT_PERIPHERAL_PREF_SLAVE_LATENCY, - CONFIG_BT_PERIPHERAL_PREF_TIMEOUT); - send_conn_le_param_update(conn, param); + param = BT_LE_CONN_PARAM( + CONFIG_BT_PERIPHERAL_PREF_MIN_INT, + CONFIG_BT_PERIPHERAL_PREF_MAX_INT, + CONFIG_BT_PERIPHERAL_PREF_SLAVE_LATENCY, + CONFIG_BT_PERIPHERAL_PREF_TIMEOUT); + send_conn_le_param_update(conn, param); #endif - } } atomic_set_bit(conn->flags, BT_CONN_SLAVE_PARAM_UPDATE);