Bluetooth: controller: hci: Add set connection CTE transmit params

Add implementation of HCI_LE_Set_Connection_CTE_Transmit_Parameters
for Bluetooth 5.1 Direction Finding.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
This commit is contained in:
Piotr Pryga 2020-10-26 06:36:42 -07:00 committed by Carles Cufí
commit 2589b7ace2
5 changed files with 85 additions and 1 deletions

View file

@ -1351,6 +1351,26 @@ struct bt_hci_cp_le_set_privacy_mode {
uint8_t mode;
} __packed;
#define BT_HCI_LE_AOA_CTE_RSP BIT(0)
#define BT_HCI_LE_AOD_CTE_RSP_1US BIT(1)
#define BT_HCI_LE_AOD_CTE_RSP_2US BIT(2)
#define BT_HCI_LE_SWITCH_PATTERN_LEN_MIN 0x2
#define BT_HCI_LE_SWITCH_PATTERN_LEN_MAX 0x4B
#define BT_HCI_OP_LE_SET_CONN_CTE_TX_PARAMS BT_OP(BT_OGF_LE, 0x0055)
struct bt_hci_cp_le_set_conn_cte_tx_params {
uint16_t handle;
uint8_t cte_types;
uint8_t switch_pattern_len;
uint8_t ant_id[0];
} __packed;
struct bt_hci_rp_le_set_conn_cte_tx_params {
uint8_t status;
uint16_t handle;
} __packed;
#define BT_HCI_LE_1US_AOD_TX BIT(0)
#define BT_HCI_LE_1US_AOD_RX BIT(1)
#define BT_HCI_LE_1US_AOA_RX BIT(2)

View file

@ -2064,6 +2064,29 @@ static void le_read_tx_power(struct net_buf *buf, struct net_buf **evt)
}
#if IS_ENABLED(CONFIG_BT_CTLR_DF)
#if IS_ENABLED(CONFIG_BT_CTLR_DF_CONN_CTE_RSP)
static void le_df_set_conn_cte_tx_params(struct net_buf *buf,
struct net_buf **evt)
{
struct bt_hci_cp_le_set_conn_cte_tx_params *cmd = (void *)buf->data;
struct bt_hci_rp_le_set_conn_cte_tx_params *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_tx_params(handle, cmd->cte_types,
cmd->switch_pattern_len,
cmd->ant_id);
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)
{
struct bt_hci_rp_le_read_ant_info *rp;
@ -3085,6 +3108,11 @@ static int controller_cmd_handle(uint16_t ocf, struct net_buf *cmd,
case BT_OCF(BT_HCI_OP_LE_READ_ANT_INFO):
le_df_read_ant_inf(cmd, evt);
break;
#if IS_ENABLED(CONFIG_BT_CTLR_DF_CONN_CTE_RSP)
case BT_OCF(BT_HCI_OP_LE_SET_CONN_CTE_TX_PARAMS):
le_df_set_conn_cte_tx_params(cmd, evt);
break;
#endif /* CONFIG_BT_CTLR_DF_CONN_CTE_RSP) */
#endif /* CONFIG_BT_CTLR_DF */
#if defined(CONFIG_BT_CTLR_DTM_HCI)

View file

@ -262,6 +262,11 @@ uint32_t ll_radio_state_is_idle(void);
/* Direction Finding */
/* Provides information about antennae switching and sampling settings */
uint8_t ll_df_set_conn_cte_tx_params(uint16_t handle, uint8_t cte_types,
uint8_t switching_patterns_len,
uint8_t *ant_id);
/* Sets CTE transmission parameters for a connection */
void ll_df_read_ant_inf(uint8_t *switch_sample_rates,
uint8_t *num_ant,
uint8_t *max_switch_pattern_len,

View file

@ -12,6 +12,37 @@
#define LOG_MODULE_NAME bt_ctlr_ull_df
#include "common/log.h"
/* @brief Function sets CTE transmission parameters for a connection.
*
* @param[in]handle Connection handle.
* @param[in]cte_types Bitfield holding information about
* allowed CTE types.
* @param[in]switch_pattern_len Number of antenna ids in switch pattern.
* @param[in]ant_id Array of antenna identifiers.
*
* @return Status of command completion.
*/
uint8_t ll_df_set_conn_cte_tx_params(uint16_t handle, uint8_t cte_types,
uint8_t switch_pattern_len,
uint8_t *ant_id)
{
if (cte_types & BT_HCI_LE_AOD_CTE_RSP_1US ||
cte_types & BT_HCI_LE_AOD_CTE_RSP_2US) {
if (!IS_ENABLED(CONFIG_BT_CTLR_DF_ANT_SWITCH_TX)) {
return BT_HCI_ERR_UNSUPP_FEATURE_PARAM_VAL;
}
if (switch_pattern_len < BT_HCI_LE_SWITCH_PATTERN_LEN_MIN ||
switch_pattern_len > BT_HCI_LE_SWITCH_PATTERN_LEN_MAX ||
!ant_id) {
return BT_HCI_ERR_UNSUPP_FEATURE_PARAM_VAL;
}
}
return BT_HCI_ERR_CMD_DISALLOWED;
}
/* @brief Function provides information about Direction Finding
* antennae switching and sampling related settings.
*

View file

@ -13,7 +13,7 @@
* - Angle of arrival 1us switching-sampling for reception.
*
* @note Pay attention that both types AoD and AoA
* support 2US swiching-sampling as mandatory.
* support 2US switching-sampling as mandatory.
*/
enum df_switch_sample_support {
DF_AOD_1US_TX = BIT(0),