Bluetooth: host: Add DF to initalization sequence
Add Direction Finding to host initialization sequence. It allows to get information about Direction finding optional CTE settings supported by controller. Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
This commit is contained in:
parent
181088600e
commit
9bfc095d4a
5 changed files with 82 additions and 1 deletions
|
@ -185,6 +185,8 @@ struct bt_hci_cmd_hdr {
|
|||
BT_LE_FEAT_BIT_EXT_ADV)
|
||||
#define BT_FEAT_LE_EXT_PER_ADV(feat) BT_LE_FEAT_TEST(feat, \
|
||||
BT_LE_FEAT_BIT_PER_ADV)
|
||||
#define BT_FEAT_LE_CONNECTIONLESS_CTE_TX(feat) BT_LE_FEAT_TEST(feat, \
|
||||
BT_LE_FEAT_BIT_CONNECTIONLESS_CTE_TX)
|
||||
#define BT_FEAT_LE_PAST_SEND(feat) BT_LE_FEAT_TEST(feat, \
|
||||
BT_LE_FEAT_BIT_PAST_SEND)
|
||||
#define BT_FEAT_LE_PAST_RECV(feat) BT_LE_FEAT_TEST(feat, \
|
||||
|
|
|
@ -608,6 +608,12 @@ config BT_DF
|
|||
It will allow to: get information about antennae, configure
|
||||
Constant Tone Extension, transmit CTE and sample incoming CTE.
|
||||
|
||||
config BT_DEBUG_DF
|
||||
bool "Bluetooth Direction Finding debug"
|
||||
depends on BT_DF
|
||||
help
|
||||
This option enables debug support for Bluetooth Direction Finding
|
||||
|
||||
endif # BT_HCI_HOST
|
||||
|
||||
config BT_ECC
|
||||
|
|
|
@ -7,15 +7,40 @@
|
|||
#include <assert.h>
|
||||
|
||||
#include <bluetooth/hci.h>
|
||||
#include <bluetooth/l2cap.h>
|
||||
#include <bluetooth/conn.h>
|
||||
#include <sys/byteorder.h>
|
||||
|
||||
#include "conn_internal.h"
|
||||
#include "direction_internal.h"
|
||||
|
||||
#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_CORE)
|
||||
#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_DF)
|
||||
#define LOG_MODULE_NAME bt_df
|
||||
#include "common/log.h"
|
||||
|
||||
/* @brief Antenna information for LE Direction Finding */
|
||||
struct bt_le_df_ant_info {
|
||||
/* Bitfield holding optional switching and sampling rates */
|
||||
uint8_t switch_sample_rates;
|
||||
/* Available antennae number */
|
||||
uint8_t num_ant;
|
||||
/* Maximum supported antennae switching pattern length */
|
||||
uint8_t max_switch_pattern_len;
|
||||
/* Maximum length of CTE in 8[us] units */
|
||||
uint8_t max_cte_len;
|
||||
};
|
||||
|
||||
static struct bt_le_df_ant_info df_ant_info;
|
||||
|
||||
#define DF_SUPP_TEST(feat, n) ((feat) & BIT((n)))
|
||||
|
||||
#define DF_AOD_TX_1US_SUPPORT(supp) (DF_SUPP_TEST(supp, \
|
||||
BT_HCI_LE_1US_AOD_TX))
|
||||
#define DF_AOD_RX_1US_SUPPORT(supp) (DF_SUPP_TEST(supp, \
|
||||
BT_HCI_LE_1US_AOD_RX))
|
||||
#define DF_AOA_RX_1US_SUPPORT(supp) (DF_SUPP_TEST(supp, \
|
||||
BT_HCI_LE_1US_AOA_RX))
|
||||
|
||||
/* @brief Function provides information about DF antennae numer and
|
||||
* controller capabilities related with Constant Tone Extension.
|
||||
*
|
||||
|
@ -131,3 +156,30 @@ static int hci_df_set_conn_cte_tx_param(struct bt_conn *conn, uint8_t cte_types,
|
|||
|
||||
return err;
|
||||
}
|
||||
|
||||
/* @brief Function initializes Direction Finding in Host
|
||||
*
|
||||
* @return Zero in case of success, other value in case of failure.
|
||||
*/
|
||||
int le_df_init(void)
|
||||
{
|
||||
uint8_t max_switch_pattern_len;
|
||||
uint8_t switch_sample_rates;
|
||||
uint8_t max_cte_len;
|
||||
uint8_t num_ant;
|
||||
int err;
|
||||
|
||||
err = hci_df_read_ant_info(&switch_sample_rates, &num_ant,
|
||||
&max_switch_pattern_len, &max_cte_len);
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
|
||||
df_ant_info.max_switch_pattern_len = max_switch_pattern_len;
|
||||
df_ant_info.switch_sample_rates = switch_sample_rates;
|
||||
df_ant_info.max_cte_len = max_cte_len;
|
||||
df_ant_info.num_ant = num_ant;
|
||||
|
||||
BT_DBG("DF initialized.");
|
||||
return 0;
|
||||
}
|
||||
|
|
8
subsys/bluetooth/host/direction_internal.h
Normal file
8
subsys/bluetooth/host/direction_internal.h
Normal file
|
@ -0,0 +1,8 @@
|
|||
/*
|
||||
* Copyright (c) 2020 Nordic Semiconductor ASA
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/* Performs initialization of Direction Finding in Host */
|
||||
int le_df_init(void);
|
|
@ -47,6 +47,10 @@
|
|||
#include "crypto.h"
|
||||
#include "settings.h"
|
||||
|
||||
#if IS_ENABLED(CONFIG_BT_DF)
|
||||
#include "direction_internal.h"
|
||||
#endif /* CONFIG_BT_DF */
|
||||
|
||||
#if !defined(CONFIG_BT_EXT_ADV_LEGACY_SUPPORT)
|
||||
#undef BT_FEAT_LE_EXT_ADV
|
||||
#define BT_FEAT_LE_EXT_ADV(feat) 1
|
||||
|
@ -5722,6 +5726,15 @@ static int le_init(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
#if IS_ENABLED(CONFIG_BT_DF)
|
||||
if (BT_FEAT_LE_CONNECTIONLESS_CTE_TX(bt_dev.le.features)) {
|
||||
err = le_df_init();
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
}
|
||||
#endif /* CONFIG_BT_DF */
|
||||
|
||||
return le_set_event_mask();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue