From 758e220cdc2b57f13af8b3a9880750ace51d3825 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Tue, 13 Dec 2016 09:28:35 +0200 Subject: [PATCH] Bluetooth: Remove inline declaration from bt_le_conn_params_valid The function is not particularly small, and is used from several places, so remove the inline declaration. This also prepares the way for the possibility of having an application callback for letting the application choose whether it's fine with the proposed parameters, and thereby influence the response we send to the remote device. Change-Id: I5848b179318b6fb6ee37fcbd479a919204f559f1 Signed-off-by: Johan Hedberg --- subsys/bluetooth/host/hci_core.c | 21 +++++++++++++++++++++ subsys/bluetooth/host/hci_core.h | 21 ++------------------- 2 files changed, 23 insertions(+), 19 deletions(-) diff --git a/subsys/bluetooth/host/hci_core.c b/subsys/bluetooth/host/hci_core.c index 0b6777a1a75..989abe7b576 100644 --- a/subsys/bluetooth/host/hci_core.c +++ b/subsys/bluetooth/host/hci_core.c @@ -822,6 +822,27 @@ static void le_remote_feat_complete(struct net_buf *buf) bt_conn_unref(conn); } +bool bt_le_conn_params_valid(uint16_t min, uint16_t max, + uint16_t latency, uint16_t timeout) +{ + if (min > max || min < 6 || max > 3200) { + return false; + } + + /* Limits according to BT Core spec 4.2 [Vol 2, Part E, 7.8.12] */ + if (timeout < 10 || timeout > 3200 || + (2 * timeout) < ((1 + latency) * max * 5)) { + return false; + } + + /* Limits according to BT Core spec 4.2 [Vol 6, Part B, 4.5.1] */ + if (latency > 499 || ((latency + 1) * max) > (timeout * 4)) { + return false; + } + + return true; +} + static int le_conn_param_neg_reply(uint16_t handle, uint8_t reason) { struct bt_hci_cp_le_conn_param_req_neg_reply *cp; diff --git a/subsys/bluetooth/host/hci_core.h b/subsys/bluetooth/host/hci_core.h index 98d87e2b1fe..1cf4a6cd006 100644 --- a/subsys/bluetooth/host/hci_core.h +++ b/subsys/bluetooth/host/hci_core.h @@ -138,25 +138,8 @@ extern const struct bt_storage *bt_storage; extern const struct bt_conn_auth_cb *bt_auth; #endif /* CONFIG_BLUETOOTH_SMP || CONFIG_BLUETOOTH_BREDR */ -static inline bool bt_le_conn_params_valid(uint16_t min, uint16_t max, - uint16_t latency, uint16_t timeout) -{ - if (min > max || min < 6 || max > 3200) { - return false; - } - - /* Limits according to BT Core spec 4.2 [Vol 2, Part E, 7.8.12] */ - if (timeout < 10 || timeout > 3200) { - return false; - } - - /* Limits according to BT Core spec 4.2 [Vol 6, Part B, 4.5.1] */ - if (latency > 499 || ((latency + 1) * max) > (timeout * 4)) { - return false; - } - - return true; -} +bool bt_le_conn_params_valid(uint16_t min, uint16_t max, + uint16_t latency, uint16_t timeout); struct net_buf *bt_hci_cmd_create(uint16_t opcode, uint8_t param_len); int bt_hci_cmd_send(uint16_t opcode, struct net_buf *buf);