-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bluetooth: host: Add support for CS set default settings
Added support for a new API for setting default channel sounding settings, this is mainly a wrapper around the HCI command. For this add a new module for channel sounding, where new channel sounding APIs will go. Signed-off-by: Sean Madigan <sean.madigan@nordicsemi.no>
- Loading branch information
1 parent
319e283
commit 3a9e144
Showing
4 changed files
with
158 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/** @file | ||
* @brief Bluetooth Channel Sounding handling | ||
*/ | ||
|
||
/* | ||
* Copyright (c) 2015-2016 Intel Corporation | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
#ifndef ZEPHYR_INCLUDE_BLUETOOTH_CS_H_ | ||
#define ZEPHYR_INCLUDE_BLUETOOTH_CS_H_ | ||
|
||
/** | ||
* @brief Channel Sounding (CS) | ||
* @defgroup bt_cs Channel Sounding (CS) | ||
* @ingroup bluetooth | ||
* @{ | ||
*/ | ||
|
||
#include <stdint.h> | ||
#include <stdbool.h> | ||
|
||
#include <zephyr/bluetooth/hci_types.h> | ||
#include <zephyr/bluetooth/conn.h> | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
enum bt_cs_sync_antenna_selection_opt { | ||
/** Use antenna identifier 1 for CS_SYNC packets. */ | ||
BT_CS_ANTENNA_SELECTION_OPT_ONE = BT_HCI_OP_LE_CS_ANTENNA_SEL_ONE, | ||
/** Use antenna identifier 2 for CS_SYNC packets. */ | ||
BT_CS_ANTENNA_SELECTION_OPT_TWO = BT_HCI_OP_LE_CS_ANTENNA_SEL_TWO, | ||
/** Use antenna identifier 3 for CS_SYNC packets. */ | ||
BT_CS_ANTENNA_SELECTION_OPT_THREE = BT_HCI_OP_LE_CS_ANTENNA_SEL_THREE, | ||
/** Use antenna identifier 4 for CS_SYNC packets. */ | ||
BT_CS_ANTENNA_SELECTION_OPT_FOUR = BT_HCI_OP_LE_CS_ANTENNA_SEL_FOUR, | ||
/** Use antennas in repetitive order from 1 to 4 for CS_SYNC packets. */ | ||
BT_CS_ANTENNA_SELECTION_OPT_REPETITIVE = BT_HCI_OP_LE_CS_ANTENNA_SEL_REP, | ||
/** No recommendation for local controller antenna selection. */ | ||
BT_CS_ANTENNA_SELECTION_OPT_NO_RECOMMENDATION = BT_HCI_OP_LE_CS_ANTENNA_SEL_NONE, | ||
}; | ||
|
||
/** Connection subrating parameters for LE connections */ | ||
struct bt_cs_set_default_settings_param { | ||
/** Enable CS initiator role. */ | ||
bool enable_initiator_role; | ||
/** Enable CS reflector role. */ | ||
bool enable_reflector_role; | ||
/** Antenna identifier to be used for CS_SYNC packets by the local controller. | ||
*/ | ||
enum bt_cs_sync_antenna_selection_opt cs_sync_antenna_selection; | ||
/** Maximum output power (Effective Isotropic Radiated Power) to be used | ||
* for all CS transmissions. | ||
* | ||
* Value range is @ref BT_HCI_OP_LE_CS_MIN_MAX_TX_POWER to | ||
* @ref BT_HCI_OP_LE_CS_MAX_MAX_TX_POWER. | ||
*/ | ||
int8_t max_tx_power; | ||
}; | ||
|
||
/** @brief Set Channel Sounding default settings. | ||
* | ||
* This command is used to set default Channel Sounding settings for this | ||
* connection. | ||
* | ||
* @note To use this API @kconfig{CONFIG_BT_CHANNEL_SOUNDING} must be set. | ||
* | ||
* @param conn Connection Object. | ||
* @param params Channel sounding default settings parameters. | ||
* | ||
* @return Zero on success or (negative) error code on failure. | ||
*/ | ||
int bt_cs_set_default_settings(struct bt_conn *conn, | ||
const struct bt_cs_set_default_settings_param *params); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
/** | ||
* @} | ||
*/ | ||
|
||
#endif /* ZEPHYR_INCLUDE_BLUETOOTH_CS_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,6 +48,7 @@ if(CONFIG_BT_HCI_HOST) | |
l2cap.c | ||
att.c | ||
gatt.c | ||
cs.c | ||
) | ||
|
||
if(CONFIG_BT_SMP) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* cs.c - Bluetooth Channel Sounding handling */ | ||
|
||
/* | ||
* Copyright (c) 2015-2016 Intel Corporation | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include <zephyr/sys/byteorder.h> | ||
#include <zephyr/bluetooth/cs.h> | ||
#include <zephyr/bluetooth/hci.h> | ||
#include <zephyr/bluetooth/hci_types.h> | ||
|
||
#include "conn_internal.h" | ||
|
||
#if defined(CONFIG_BT_CHANNEL_SOUNDING) | ||
int bt_cs_set_default_settings(struct bt_conn *conn, | ||
const struct bt_cs_set_default_settings_param *params) | ||
{ | ||
struct bt_hci_cp_le_cs_set_default_settings *cp; | ||
struct net_buf *buf; | ||
|
||
if (params->max_tx_power > BT_HCI_OP_LE_CS_MAX_MAX_TX_POWER || | ||
params->max_tx_power < BT_HCI_OP_LE_CS_MIN_MAX_TX_POWER) { | ||
return EINVAL; | ||
} | ||
|
||
buf = bt_hci_cmd_create(BT_HCI_OP_LE_CS_SET_DEFAULT_SETTINGS, sizeof(*cp)); | ||
if (!buf) { | ||
return -ENOBUFS; | ||
} | ||
|
||
cp = net_buf_add(buf, sizeof(*cp)); | ||
cp->handle = sys_cpu_to_le16(conn->handle); | ||
cp->max_tx_power = params->max_tx_power; | ||
cp->cs_sync_antenna_selection = params->cs_sync_antenna_selection; | ||
cp->role_enable = 0; | ||
|
||
if (params->enable_initiator_role) { | ||
cp->role_enable &= BT_HCI_OP_LE_CS_INITIATOR_ROLE_MASK; | ||
} | ||
|
||
if (params->enable_reflector_role) { | ||
cp->role_enable &= BT_HCI_OP_LE_CS_INITIATOR_ROLE_MASK; | ||
} | ||
|
||
return bt_hci_cmd_send_sync(BT_HCI_OP_LE_CS_SET_DEFAULT_SETTINGS, buf, NULL); | ||
} | ||
#endif /* CONFIG_BT_CHANNEL_SOUNDING */ |