From c3f557c12b32f4081174b32e0121c76a7ef34590 Mon Sep 17 00:00:00 2001 From: Thomas Ebert Hansen Date: Fri, 11 Dec 2020 15:45:23 +0100 Subject: [PATCH] Bluetooth: controller: User defined CPR intervals Some proprietary protocols that reuse the Bluetooth LLCP logic requires that the CPR interval has a valid range that differs from the Bluetooth specification defined. Vendor must implement the function (ull_vendor.h) uint16_t ull_conn_interval_min_get(struct ll_conn *conn) that returns the valid limit for the given connection. Signed-off-by: Thomas Ebert Hansen --- .../bluetooth/controller/Kconfig.ll_sw_split | 7 +++++++ subsys/bluetooth/controller/ll_sw/ull_conn.c | 18 +++++++++++++++--- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/subsys/bluetooth/controller/Kconfig.ll_sw_split b/subsys/bluetooth/controller/Kconfig.ll_sw_split index b85d71f5ba3..0a1aad05d82 100644 --- a/subsys/bluetooth/controller/Kconfig.ll_sw_split +++ b/subsys/bluetooth/controller/Kconfig.ll_sw_split @@ -551,6 +551,13 @@ config BT_RX_USER_PDU_LEN header and payload. It does not account for HCI event headers as these PDUs are assumed to not go across HCI. +config BT_CTLR_USER_CPR_INTERVAL_MIN + bool "Enable proprietary Connection Parameter Request minimum interval" + depends on BT_CTLR_USER_EXT + help + When enabled, controller will accept Connection Parameter Request + intervals down to a proprietary minimum value. + endmenu comment "BLE Controller hardware configuration" diff --git a/subsys/bluetooth/controller/ll_sw/ull_conn.c b/subsys/bluetooth/controller/ll_sw/ull_conn.c index a0e47f3542e..17c7d853f2a 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_conn.c +++ b/subsys/bluetooth/controller/ll_sw/ull_conn.c @@ -51,6 +51,18 @@ #include "ull_vendor.h" #endif /* CONFIG_BT_CTLR_USER_EXT */ +/** + * User CPR Interval + */ +#if !defined(CONFIG_BT_CTLR_USER_CPR_INTERVAL_MIN) +/* Bluetooth defined CPR Interval Minimum (7.5ms) */ +#define CONN_INTERVAL_MIN(x) (6) +#else /* CONFIG_BT_CTLR_USER_CPR_INTERVAL_MIN */ +/* Proprietary user defined CPR Interval Minimum */ +extern uint16_t ull_conn_interval_min_get(struct ll_conn *conn); +#define CONN_INTERVAL_MIN(x) (MAX(ull_conn_interval_min_get(x), 1)) +#endif /* CONFIG_BT_CTLR_USER_CPR_INTERVAL_MIN */ + inline void ull_conn_upd_curr_reset(void); static int init_reset(void); @@ -5697,7 +5709,7 @@ static inline int ctrl_rx(memq_link_t *link, struct node_rx_pdu **rx, cpr->preferred_periodicity; /* Invalid parameters */ - if ((interval_min < 6) || + if ((interval_min < CONN_INTERVAL_MIN(conn)) || (interval_max > 3200) || (interval_min > interval_max) || (latency > 499) || @@ -5803,7 +5815,7 @@ static inline int ctrl_rx(memq_link_t *link, struct node_rx_pdu **rx, cpr->preferred_periodicity; /* Invalid parameters */ - if ((interval_min < 6) || + if ((interval_min < CONN_INTERVAL_MIN(conn)) || (interval_max > 3200) || (interval_min > interval_max) || (latency > 499) || @@ -5899,7 +5911,7 @@ static inline int ctrl_rx(memq_link_t *link, struct node_rx_pdu **rx, cpr->preferred_periodicity; /* Invalid parameters */ - if ((interval_min < 6) || + if ((interval_min < CONN_INTERVAL_MIN(conn)) || (interval_max > 3200) || (interval_min > interval_max) || (latency > 499) ||