Bluetooth: host: direction: Add public API to set CTE TX params for adv.
Add publicly accessible function to set Constant Tone Extension parameters for CTE transmission with periodic advertising. Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
This commit is contained in:
parent
098f767298
commit
1c493b4a77
3 changed files with 69 additions and 42 deletions
40
include/bluetooth/direction.h
Normal file
40
include/bluetooth/direction.h
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020 Nordic Semiconductor ASA
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef ZEPHYR_INCLUDE_BLUETOOTH_DF_H_
|
||||||
|
#define ZEPHYR_INCLUDE_BLUETOOTH_DF_H_
|
||||||
|
|
||||||
|
/** @brief Constant Tone Extension parameters for connectionless
|
||||||
|
* transmission.
|
||||||
|
*
|
||||||
|
* The structure holds information required to setup CTE transmission
|
||||||
|
* in periodic advertising.
|
||||||
|
*/
|
||||||
|
struct bt_df_adv_cte_tx_param {
|
||||||
|
/** Length of CTE in 8us units */
|
||||||
|
uint8_t cte_len;
|
||||||
|
/** CTE Type: AoA, AoD 1us slots, AoD 2us slots */
|
||||||
|
uint8_t cte_type;
|
||||||
|
/** Number of CTE to transmit in each periodic adv interval */
|
||||||
|
uint8_t cte_count;
|
||||||
|
/** Number of Antenna IDs in the switch pattern */
|
||||||
|
uint8_t num_ant_ids;
|
||||||
|
/** List of antenna IDs in the pattern */
|
||||||
|
uint8_t *ant_ids;
|
||||||
|
};
|
||||||
|
|
||||||
|
/** @brief Set or update the Constant Tone Extension parameters for periodic
|
||||||
|
* advertising set.
|
||||||
|
*
|
||||||
|
* @param[in] adv Advertising set object.
|
||||||
|
* @param[in] params Constant Tone Extension parameters.
|
||||||
|
*
|
||||||
|
* @return Zero on success or (negative) error code otherwise.
|
||||||
|
*/
|
||||||
|
int bt_df_set_adv_cte_tx_param(struct bt_le_ext_adv *adv,
|
||||||
|
const struct bt_df_adv_cte_tx_param *params);
|
||||||
|
|
||||||
|
#endif /* ZEPHYR_INCLUDE_BLUETOOTH_DF_H_ */
|
|
@ -9,11 +9,11 @@
|
||||||
#include <bluetooth/hci.h>
|
#include <bluetooth/hci.h>
|
||||||
#include <bluetooth/l2cap.h>
|
#include <bluetooth/l2cap.h>
|
||||||
#include <bluetooth/conn.h>
|
#include <bluetooth/conn.h>
|
||||||
|
#include <bluetooth/direction.h>
|
||||||
#include <sys/byteorder.h>
|
#include <sys/byteorder.h>
|
||||||
|
|
||||||
#include "hci_core.h"
|
#include "hci_core.h"
|
||||||
#include "conn_internal.h"
|
#include "conn_internal.h"
|
||||||
#include "direction.h"
|
|
||||||
#include "direction_internal.h"
|
#include "direction_internal.h"
|
||||||
|
|
||||||
#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_DF)
|
#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_DF)
|
||||||
|
@ -44,7 +44,7 @@ static struct bt_le_df_ant_info df_ant_info;
|
||||||
BT_HCI_LE_1US_AOA_RX))
|
BT_HCI_LE_1US_AOA_RX))
|
||||||
|
|
||||||
static int hci_df_set_cl_cte_tx_params(const struct bt_le_ext_adv *adv,
|
static int hci_df_set_cl_cte_tx_params(const struct bt_le_ext_adv *adv,
|
||||||
const struct bt_le_df_adv_cte_tx_params *params)
|
const struct bt_df_adv_cte_tx_param *params)
|
||||||
{
|
{
|
||||||
struct bt_hci_cp_le_set_cl_cte_tx_params *cp;
|
struct bt_hci_cp_le_set_cl_cte_tx_params *cp;
|
||||||
struct net_buf *buf;
|
struct net_buf *buf;
|
||||||
|
@ -250,3 +250,30 @@ int le_df_init(void)
|
||||||
BT_DBG("DF initialized.");
|
BT_DBG("DF initialized.");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int bt_df_set_adv_cte_tx_param(struct bt_le_ext_adv *adv,
|
||||||
|
const struct bt_df_adv_cte_tx_param *params)
|
||||||
|
{
|
||||||
|
__ASSERT_NO_MSG(adv);
|
||||||
|
__ASSERT_NO_MSG(params);
|
||||||
|
|
||||||
|
int err;
|
||||||
|
|
||||||
|
if (!BT_FEAT_LE_CONNECTIONLESS_CTE_TX(bt_dev.le.features)) {
|
||||||
|
return -ENOTSUP;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check if BT_ADV_PARAMS_SET is set, because it implies the set
|
||||||
|
* has already been created.
|
||||||
|
*/
|
||||||
|
if (!atomic_test_bit(adv->flags, BT_ADV_PARAMS_SET)) {
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
err = hci_df_set_cl_cte_tx_params(adv, params);
|
||||||
|
if (err) {
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
|
@ -1,40 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2020 Nordic Semiconductor ASA
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef ZEPHYR_SUBSYS_BLUETOOTH_HOST_DF_H_
|
|
||||||
#define ZEPHYR_SUBSYS_BLUETOOTH_HOST_DF_H_
|
|
||||||
|
|
||||||
/* @brief Optional switching and sampling rates for Angle of Departure
|
|
||||||
* and Angle or Arrival modes.
|
|
||||||
*/
|
|
||||||
enum bt_df_opt_swich_sample_rates {
|
|
||||||
/* Support Angle of Departure 1us switching TX */
|
|
||||||
DF_AOD_1US_SWITCH_TX_SUPP = BIT(0),
|
|
||||||
/* Support Angle of departure 1us sampling RX */
|
|
||||||
DF_AOD_1US_SAMPL_RX_SUPP = BIT(1),
|
|
||||||
/* Support Angle of Arrival 1us switching and sampling RX */
|
|
||||||
DF_AOA_1US_SWITCH_SAMPL_RX_SUPP = BIT(2),
|
|
||||||
};
|
|
||||||
|
|
||||||
/* @brief Constant Tone Extension parameters for connectionless
|
|
||||||
* transmission.
|
|
||||||
*
|
|
||||||
* The structure holds information required to setup CTE transmission
|
|
||||||
* in periodic advertising.
|
|
||||||
*/
|
|
||||||
struct bt_le_df_adv_cte_tx_params {
|
|
||||||
/* Length of CTE in 8us units */
|
|
||||||
uint8_t cte_len;
|
|
||||||
/* CTE Type: AoA, AoD 1us slots, AoD 2us slots */
|
|
||||||
uint8_t cte_type;
|
|
||||||
/* Number of CTE to transmit in each periodic adv interval */
|
|
||||||
uint8_t cte_count;
|
|
||||||
/* Number of Antenna IDs in the switch pattern */
|
|
||||||
uint8_t num_ant_ids;
|
|
||||||
/* List of antenna IDs in the pattern */
|
|
||||||
uint8_t *ant_ids;
|
|
||||||
};
|
|
||||||
#endif /* ZEPHYR_SUBSYS_BLUETOOTH_HOST_DF_H_ */
|
|
Loading…
Add table
Add a link
Reference in a new issue