Bluetooth: host: Add read antenna information HCI command
Add Bluetooth 5.1 Direction Finding HCI command: HCI_LE_Read_Antenna_Information handling to Host. Add wrapper function to handle send the command and receive response from Controller. Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
This commit is contained in:
parent
24f34b1913
commit
14890c8eb6
4 changed files with 96 additions and 0 deletions
|
@ -1351,6 +1351,28 @@ struct bt_hci_cp_le_set_privacy_mode {
|
|||
uint8_t mode;
|
||||
} __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)
|
||||
|
||||
#define BT_HCI_LE_NUM_ANT_MIN 0x1
|
||||
#define BT_HCI_LE_NUM_ANT_MAX 0x4B
|
||||
|
||||
#define BT_HCI_LE_MAX_SWITCH_PATTERN_LEN_MIN 0x2
|
||||
#define BT_HCI_LE_MAX_SWITCH_PATTERN_LEN_MAX 0x4B
|
||||
|
||||
#define BT_HCI_LE_MAX_CTE_LEN_MIN 0x2
|
||||
#define BT_HCI_LE_MAX_CTE_LEN_MAX 0x14
|
||||
|
||||
#define BT_HCI_OP_LE_READ_ANT_INFO BT_OP(BT_OGF_LE, 0x0058)
|
||||
struct bt_hci_rp_le_read_ant_info {
|
||||
uint8_t status;
|
||||
uint8_t switch_sample_rates;
|
||||
uint8_t num_ant;
|
||||
uint8_t max_switch_pattern_len;
|
||||
uint8_t max_cte_len;
|
||||
};
|
||||
|
||||
#define BT_HCI_OP_LE_SET_PER_ADV_RECV_ENABLE BT_OP(BT_OGF_LE, 0x0059)
|
||||
struct bt_hci_cp_le_set_per_adv_recv_enable {
|
||||
uint16_t handle;
|
||||
|
|
|
@ -57,6 +57,12 @@ if(CONFIG_BT_HCI_HOST)
|
|||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(CONFIG_BT_DF)
|
||||
zephyr_library_sources(
|
||||
direction.c
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(CONFIG_BT_DEBUG_SMP OR CONFIG_BT_DEBUG_KEYS)
|
||||
|
|
|
@ -601,6 +601,13 @@ config BT_ID_MAX
|
|||
Maximum number of supported local identity addresses. For most
|
||||
products this is safe to leave as the default value (1).
|
||||
|
||||
config BT_DF
|
||||
bool "Enable Direction Finding support [EXPERIMENTAL]"
|
||||
help
|
||||
Enable support for Bluetooth 5.1 Direction Finding.
|
||||
It will allow to: get information about antennae, configure
|
||||
Constant Tone Extension, transmit CTE and sample incoming CTE.
|
||||
|
||||
endif # BT_HCI_HOST
|
||||
|
||||
config BT_ECC
|
||||
|
|
61
subsys/bluetooth/host/direction.c
Normal file
61
subsys/bluetooth/host/direction.c
Normal file
|
@ -0,0 +1,61 @@
|
|||
/*
|
||||
* Copyright (c) 2020 Nordic Semiconductor ASA
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#include <stdint.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <bluetooth/hci.h>
|
||||
#include <sys/byteorder.h>
|
||||
|
||||
#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_CORE)
|
||||
#define LOG_MODULE_NAME bt_df
|
||||
#include "common/log.h"
|
||||
|
||||
/* @brief Function provides information about DF antennae numer and
|
||||
* controller capabilities related with Constant Tone Extension.
|
||||
*
|
||||
* @param[out] switch_sample_rates Optional switching and sampling rates.
|
||||
* @param[out] num_ant Antennae number.
|
||||
* @param[out] max_switch_pattern_len Maximum supported antennae switching
|
||||
* paterns length.
|
||||
* @param[out] max_CTE_len Maximum length of CTE in 8[us] units.
|
||||
*
|
||||
* @return Zero in case of success, other value in case of failure.
|
||||
*/
|
||||
static int hci_df_read_ant_info(uint8_t *switch_sample_rates,
|
||||
uint8_t *num_ant,
|
||||
uint8_t *max_switch_pattern_len,
|
||||
uint8_t *max_cte_len)
|
||||
{
|
||||
__ASSERT_NO_MSG(switch_sample_rates);
|
||||
__ASSERT_NO_MSG(num_ant);
|
||||
__ASSERT_NO_MSG(max_switch_pattern_len);
|
||||
__ASSERT_NO_MSG(max_cte_len);
|
||||
|
||||
struct bt_hci_rp_le_read_ant_info *rp;
|
||||
struct net_buf *rsp;
|
||||
int err;
|
||||
|
||||
err = bt_hci_cmd_send_sync(BT_HCI_OP_LE_READ_ANT_INFO, NULL, &rsp);
|
||||
if (err) {
|
||||
BT_ERR("Failed to read antenna information");
|
||||
return err;
|
||||
}
|
||||
|
||||
rp = (void *)rsp->data;
|
||||
|
||||
BT_DBG("DF: sw. sampl rates: %x ant num: %u , max sw. pattern len: %u,"
|
||||
"max CTE len %d", rp->switch_sample_rates, rp->num_ant,
|
||||
rp->max_switch_pattern_len, rp->max_cte_len);
|
||||
|
||||
*switch_sample_rates = rp->switch_sample_rates;
|
||||
*num_ant = rp->num_ant;
|
||||
*max_switch_pattern_len = rp->max_switch_pattern_len;
|
||||
*max_cte_len = rp->max_cte_len;
|
||||
|
||||
net_buf_unref(rsp);
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue