diff --git a/subsys/bluetooth/controller/hci/hci.c b/subsys/bluetooth/controller/hci/hci.c index a8262c5a06b..b0869bb0cd8 100644 --- a/subsys/bluetooth/controller/hci/hci.c +++ b/subsys/bluetooth/controller/hci/hci.c @@ -2990,6 +2990,25 @@ static void le_df_set_conn_cte_req_enable(struct net_buf *buf, struct net_buf ** rp->status = status; rp->handle = handle_le16; } +#endif /* CONFIG_BT_CTLR_DF_CONN_CTE_REQ */ + +#if defined(CONFIG_BT_CTLR_DF_CONN_CTE_RSP) +static void le_df_set_conn_cte_rsp_enable(struct net_buf *buf, struct net_buf **evt) +{ + struct bt_hci_cp_le_conn_cte_rsp_enable *cmd = (void *)buf->data; + struct bt_hci_rp_le_conn_cte_rsp_enable *rp; + uint16_t handle, handle_le16; + uint8_t status; + + handle_le16 = cmd->handle; + handle = sys_le16_to_cpu(handle_le16); + + status = ll_df_set_conn_cte_rsp_enable(handle, cmd->enable); + rp = hci_cmd_complete(evt, sizeof(*rp)); + + rp->status = status; + rp->handle = handle_le16; +} #endif /* CONFIG_BT_CTLR_DF_CONN_CTE_RSP */ static void le_df_read_ant_inf(struct net_buf *buf, struct net_buf **evt) @@ -4346,6 +4365,11 @@ static int controller_cmd_handle(uint16_t ocf, struct net_buf *cmd, le_df_set_conn_cte_req_enable(cmd, evt); break; #endif /* CONFIG_BT_CTLR_DF_CONN_CTE_REQ */ +#if defined(CONFIG_BT_CTLR_DF_CONN_CTE_RSP) + case BT_OCF(BT_HCI_OP_LE_CONN_CTE_RSP_ENABLE): + le_df_set_conn_cte_rsp_enable(cmd, evt); + break; +#endif /* CONFIG_BT_CTLR_DF_CONN_CTE_RSP */ #endif /* CONFIG_BT_CTLR_DF */ #if defined(CONFIG_BT_CTLR_DTM_HCI) diff --git a/subsys/bluetooth/controller/include/ll.h b/subsys/bluetooth/controller/include/ll.h index 83d07d11800..577a04d29c5 100644 --- a/subsys/bluetooth/controller/include/ll.h +++ b/subsys/bluetooth/controller/include/ll.h @@ -305,6 +305,8 @@ uint8_t ll_df_set_conn_cte_rx_params(uint16_t handle, uint8_t sampling_enable, /* Enables or disables CTE request control procedure in direction fingin connected mode. */ uint8_t ll_df_set_conn_cte_req_enable(uint16_t handle, uint8_t enable, uint8_t cte_request_interval, uint8_t requested_cte_length, uint8_t requested_cte_type); +/* Enables or disables CTE response control procedure in direction fingin connected mode. */ +uint8_t ll_df_set_conn_cte_rsp_enable(uint16_t handle, uint8_t enable); /* Enables or disables CTE sampling in periodic advertising scan */ uint8_t ll_df_set_cl_iq_sampling_enable(uint16_t handle, uint8_t sampling_enable, diff --git a/subsys/bluetooth/controller/ll_sw/ull_df.c b/subsys/bluetooth/controller/ll_sw/ull_df.c index c2675d7bec0..c600254668f 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_df.c +++ b/subsys/bluetooth/controller/ll_sw/ull_df.c @@ -1205,6 +1205,51 @@ uint8_t ll_df_set_conn_cte_req_enable(uint16_t handle, uint8_t enable, uint8_t c } #endif /* CONFIG_BT_CTLR_DF_CONN_CTE_REQ */ +#if defined(CONFIG_BT_CTLR_DF_CONN_CTE_RSP) +/** + * @brief Function enables or disables CTE response control procedure for a connection. + * + * @param handle Connection handle. + * @param enable Enable or disable CTE response. + * + * @return HCI Status of command completion. + */ +uint8_t ll_df_set_conn_cte_rsp_enable(uint16_t handle, uint8_t enable) +{ + struct ll_conn *conn; + + conn = ll_connected_get(handle); + if (!conn) { + return BT_HCI_ERR_UNKNOWN_CONN_ID; + } + + if (enable) { + if (conn->lll.df_tx_cfg.state == DF_CTE_SAMPLING_UNINITIALIZED) { + return BT_HCI_ERR_CMD_DISALLOWED; + } + +#if defined(CONFIG_BT_CTLR_PHY) + /* CTE may not be send over CODED PHY */ + if (conn->lll.phy_tx == PHY_CODED) { + return BT_HCI_ERR_CMD_DISALLOWED; + } +#endif /* CONFIG_BT_CTLR_PHY */ + conn->lll.df_tx_cfg.cte_rsp_en = true; + + ull_cp_cte_rsp_enable(conn, enable, LLL_DF_MAX_CTE_LEN, + conn->lll.df_tx_cfg.cte_types_allowed); + } else { + /* There is no parameter validation for disable operation. */ + + /* TODO: Add missing implementation of disable CTE request. + * Requires refactored LLCPs. + */ + } + + return BT_HCI_ERR_SUCCESS; +} +#endif /* CONFIG_BT_CTLR_DF_CONN_CTE_RSP */ + /* @brief Function provides information about Direction Finding * antennas switching and sampling related settings. *