Skip to content

Commit de8e21c

Browse files
adamfc2000olivier-le-sage
authored andcommitted
[nrf fromtree] bluetooth: host: CS support for various HCI commands
Adds HCI support for: - LE CS Security Enable - LE CS Procedure Enable - LE CS Set Procedure Parameters - LE CS Set Channel Classification - LE CS Read Local Supported Capabilities - LE CS Write Cached Remote Supported Capabilities - LE CS Write Cached Remote FAE Table Signed-off-by: Adam Cavender <[email protected]> (cherry picked from commit 18f5081)
1 parent ebb8236 commit de8e21c

File tree

9 files changed

+1127
-81
lines changed

9 files changed

+1127
-81
lines changed

include/zephyr/bluetooth/conn.h

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1518,6 +1518,86 @@ enum bt_security_err {
15181518
BT_SECURITY_ERR_UNSPECIFIED,
15191519
};
15201520

1521+
enum bt_conn_le_cs_procedure_enable_state {
1522+
BT_CONN_LE_CS_PROCEDURES_DISABLED = BT_HCI_OP_LE_CS_PROCEDURES_DISABLED,
1523+
BT_CONN_LE_CS_PROCEDURES_ENABLED = BT_HCI_OP_LE_CS_PROCEDURES_ENABLED,
1524+
};
1525+
1526+
/** CS Test Tone Antennna Config Selection.
1527+
*
1528+
* These enum values are indices in the following table, where N_AP is the maximum
1529+
* number of antenna paths (in the range [1, 4]).
1530+
*
1531+
* +--------------+-------------+-------------------+-------------------+--------+
1532+
* | Config Index | Total Paths | Dev A: # Antennas | Dev B: # Antennas | Config |
1533+
* +--------------+-------------+-------------------+-------------------+--------+
1534+
* | 0 | 1 | 1 | 1 | 1:1 |
1535+
* | 1 | 2 | 2 | 1 | N_AP:1 |
1536+
* | 2 | 3 | 3 | 1 | N_AP:1 |
1537+
* | 3 | 4 | 4 | 1 | N_AP:1 |
1538+
* | 4 | 2 | 1 | 2 | 1:N_AP |
1539+
* | 5 | 3 | 1 | 3 | 1:N_AP |
1540+
* | 6 | 4 | 1 | 4 | 1:N_AP |
1541+
* | 7 | 4 | 2 | 2 | 2:2 |
1542+
* +--------------+-------------+-------------------+-------------------+--------+
1543+
*
1544+
* There are therefore four groups of possible antenna configurations:
1545+
*
1546+
* - 1:1 configuration, where both A and B support 1 antenna each
1547+
* - 1:N_AP configuration, where A supports 1 antenna, B supports N_AP antennas, and
1548+
* N_AP is a value in the range [2, 4]
1549+
* - N_AP:1 configuration, where A supports N_AP antennas, B supports 1 antenna, and
1550+
* N_AP is a value in the range [2, 4]
1551+
* - 2:2 configuration, where both A and B support 2 antennas and N_AP = 4
1552+
*/
1553+
enum bt_conn_le_cs_tone_antenna_config_selection {
1554+
BT_LE_CS_TONE_ANTENNA_CONFIGURATION_INDEX_ONE = BT_HCI_OP_LE_CS_ACI_0,
1555+
BT_LE_CS_TONE_ANTENNA_CONFIGURATION_INDEX_TWO = BT_HCI_OP_LE_CS_ACI_1,
1556+
BT_LE_CS_TONE_ANTENNA_CONFIGURATION_INDEX_THREE = BT_HCI_OP_LE_CS_ACI_2,
1557+
BT_LE_CS_TONE_ANTENNA_CONFIGURATION_INDEX_FOUR = BT_HCI_OP_LE_CS_ACI_3,
1558+
BT_LE_CS_TONE_ANTENNA_CONFIGURATION_INDEX_FIVE = BT_HCI_OP_LE_CS_ACI_4,
1559+
BT_LE_CS_TONE_ANTENNA_CONFIGURATION_INDEX_SIX = BT_HCI_OP_LE_CS_ACI_5,
1560+
BT_LE_CS_TONE_ANTENNA_CONFIGURATION_INDEX_SEVEN = BT_HCI_OP_LE_CS_ACI_6,
1561+
BT_LE_CS_TONE_ANTENNA_CONFIGURATION_INDEX_EIGHT = BT_HCI_OP_LE_CS_ACI_7,
1562+
};
1563+
1564+
struct bt_conn_le_cs_procedure_enable_complete {
1565+
/* The ID associated with the desired configuration (0 to 3) */
1566+
uint8_t config_id;
1567+
1568+
/* State of the CS procedure */
1569+
enum bt_conn_le_cs_procedure_enable_state state;
1570+
1571+
/* Antenna configuration index */
1572+
enum bt_conn_le_cs_tone_antenna_config_selection tone_antenna_config_selection;
1573+
1574+
/* Transmit power level used for CS procedures (-127 to 20 dB; 0x7F if unavailable) */
1575+
int8_t selected_tx_power;
1576+
1577+
/* Duration of each CS subevent in microseconds (1250 us to 4 s) */
1578+
uint32_t subevent_len;
1579+
1580+
/* Number of CS subevents anchored off the same ACL connection event (0x01 to 0x20) */
1581+
uint8_t subevents_per_event;
1582+
1583+
/* Time between consecutive CS subevents anchored off the same ACL connection event in
1584+
* units of 0.625 ms
1585+
*/
1586+
uint16_t subevent_interval;
1587+
1588+
/* Number of ACL connection events between consecutive CS event anchor points */
1589+
uint16_t event_interval;
1590+
1591+
/* Number of ACL connection events between consecutive CS procedure anchor points */
1592+
uint16_t procedure_interval;
1593+
1594+
/* Number of CS procedures to be scheduled (0 if procedures to continue until disabled) */
1595+
uint16_t procedure_count;
1596+
1597+
/* Maximum duration for each procedure in units of 0.625 ms (0x0001 to 0xFFFF) */
1598+
uint16_t max_procedure_len;
1599+
};
1600+
15211601
/** @brief Connection callback structure.
15221602
*
15231603
* This structure is used for tracking the state of a connection.
@@ -1810,6 +1890,27 @@ struct bt_conn_cb {
18101890
*/
18111891
void (*le_cs_subevent_data_available)(struct bt_conn *conn,
18121892
struct bt_conn_le_cs_subevent_result *result);
1893+
1894+
/** @brief LE CS Security Enabled.
1895+
*
1896+
* This callback notifies the application that a Channel Sounding
1897+
* Security Enable procedure has completed
1898+
*
1899+
* @param conn Connection object.
1900+
*/
1901+
void (*le_cs_security_enabled)(struct bt_conn *conn);
1902+
1903+
/** @brief LE CS Procedure Enabled.
1904+
*
1905+
* This callback notifies the application that a Channel Sounding
1906+
* Procedure Enable procedure has completed
1907+
*
1908+
* @param conn Connection object.
1909+
* @param params CS Procedure Enable parameters
1910+
*/
1911+
void (*le_cs_procedure_enabled)(
1912+
struct bt_conn *conn, struct bt_conn_le_cs_procedure_enable_complete *params);
1913+
18131914
#endif
18141915

18151916
/** @internal Internally used field for list handling */

include/zephyr/bluetooth/cs.h

Lines changed: 189 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -88,62 +88,24 @@ enum bt_le_cs_test_cs_sync_antenna_selection {
8888
BT_LE_CS_TEST_CS_SYNC_ANTENNA_SELECTION_FOUR = BT_HCI_OP_LE_CS_ANTENNA_SEL_FOUR,
8989
};
9090

91-
/** CS Test Tone Antennna Config Selection.
92-
*
93-
* These enum values are indices in the following table, where N_AP is the maximum
94-
* number of antenna paths (in the range [1, 4]).
95-
*
96-
* +--------------+-------------+-------------------+-------------------+--------+
97-
* | Config Index | Total Paths | Dev A: # Antennas | Dev B: # Antennas | Config |
98-
* +--------------+-------------+-------------------+-------------------+--------+
99-
* | 0 | 1 | 1 | 1 | 1:1 |
100-
* | 1 | 2 | 2 | 1 | N_AP:1 |
101-
* | 2 | 3 | 3 | 1 | N_AP:1 |
102-
* | 3 | 4 | 4 | 1 | N_AP:1 |
103-
* | 4 | 2 | 1 | 2 | 1:N_AP |
104-
* | 5 | 3 | 1 | 3 | 1:N_AP |
105-
* | 6 | 4 | 1 | 4 | 1:N_AP |
106-
* | 7 | 4 | 2 | 2 | 2:2 |
107-
* +--------------+-------------+-------------------+-------------------+--------+
108-
*
109-
* There are therefore four groups of possible antenna configurations:
110-
*
111-
* - 1:1 configuration, where both A and B support 1 antenna each
112-
* - 1:N_AP configuration, where A supports 1 antenna, B supports N_AP antennas, and
113-
* N_AP is a value in the range [2, 4]
114-
* - N_AP:1 configuration, where A supports N_AP antennas, B supports 1 antenna, and
115-
* N_AP is a value in the range [2, 4]
116-
* - 2:2 configuration, where both A and B support 2 antennas and N_AP = 4
117-
*/
118-
enum bt_le_cs_test_tone_antenna_config_selection {
119-
BT_LE_CS_TEST_TONE_ANTENNA_CONFIGURATION_INDEX_ONE = BT_HCI_OP_LE_CS_TEST_ACI_0,
120-
BT_LE_CS_TEST_TONE_ANTENNA_CONFIGURATION_INDEX_TWO = BT_HCI_OP_LE_CS_TEST_ACI_1,
121-
BT_LE_CS_TEST_TONE_ANTENNA_CONFIGURATION_INDEX_THREE = BT_HCI_OP_LE_CS_TEST_ACI_2,
122-
BT_LE_CS_TEST_TONE_ANTENNA_CONFIGURATION_INDEX_FOUR = BT_HCI_OP_LE_CS_TEST_ACI_3,
123-
BT_LE_CS_TEST_TONE_ANTENNA_CONFIGURATION_INDEX_FIVE = BT_HCI_OP_LE_CS_TEST_ACI_4,
124-
BT_LE_CS_TEST_TONE_ANTENNA_CONFIGURATION_INDEX_SIX = BT_HCI_OP_LE_CS_TEST_ACI_5,
125-
BT_LE_CS_TEST_TONE_ANTENNA_CONFIGURATION_INDEX_SEVEN = BT_HCI_OP_LE_CS_TEST_ACI_6,
126-
BT_LE_CS_TEST_TONE_ANTENNA_CONFIGURATION_INDEX_EIGHT = BT_HCI_OP_LE_CS_TEST_ACI_7,
127-
};
128-
12991
/** CS Test Initiator SNR control options */
130-
enum bt_le_cs_test_initiator_snr_control {
131-
BT_LE_CS_TEST_INITIATOR_SNR_CONTROL_18dB = BT_HCI_OP_LE_CS_TEST_INITIATOR_SNR_18,
132-
BT_LE_CS_TEST_INITIATOR_SNR_CONTROL_21dB = BT_HCI_OP_LE_CS_TEST_INITIATOR_SNR_21,
133-
BT_LE_CS_TEST_INITIATOR_SNR_CONTROL_24dB = BT_HCI_OP_LE_CS_TEST_INITIATOR_SNR_24,
134-
BT_LE_CS_TEST_INITIATOR_SNR_CONTROL_27dB = BT_HCI_OP_LE_CS_TEST_INITIATOR_SNR_27,
135-
BT_LE_CS_TEST_INITIATOR_SNR_CONTROL_30dB = BT_HCI_OP_LE_CS_TEST_INITIATOR_SNR_30,
136-
BT_LE_CS_TEST_INITIATOR_SNR_CONTROL_NOT_USED = BT_HCI_OP_LE_CS_TEST_INITIATOR_SNR_NOT_USED,
92+
enum bt_le_cs_initiator_snr_control {
93+
BT_LE_CS_INITIATOR_SNR_CONTROL_18dB = BT_HCI_OP_LE_CS_INITIATOR_SNR_18,
94+
BT_LE_CS_INITIATOR_SNR_CONTROL_21dB = BT_HCI_OP_LE_CS_INITIATOR_SNR_21,
95+
BT_LE_CS_INITIATOR_SNR_CONTROL_24dB = BT_HCI_OP_LE_CS_INITIATOR_SNR_24,
96+
BT_LE_CS_INITIATOR_SNR_CONTROL_27dB = BT_HCI_OP_LE_CS_INITIATOR_SNR_27,
97+
BT_LE_CS_INITIATOR_SNR_CONTROL_30dB = BT_HCI_OP_LE_CS_INITIATOR_SNR_30,
98+
BT_LE_CS_INITIATOR_SNR_CONTROL_NOT_USED = BT_HCI_OP_LE_CS_INITIATOR_SNR_NOT_USED,
13799
};
138100

139101
/** CS Test Reflector SNR control options */
140-
enum bt_le_cs_test_reflector_snr_control {
141-
BT_LE_CS_TEST_REFLECTOR_SNR_CONTROL_18dB = BT_HCI_OP_LE_CS_TEST_REFLECTOR_SNR_18,
142-
BT_LE_CS_TEST_REFLECTOR_SNR_CONTROL_21dB = BT_HCI_OP_LE_CS_TEST_REFLECTOR_SNR_21,
143-
BT_LE_CS_TEST_REFLECTOR_SNR_CONTROL_24dB = BT_HCI_OP_LE_CS_TEST_REFLECTOR_SNR_24,
144-
BT_LE_CS_TEST_REFLECTOR_SNR_CONTROL_27dB = BT_HCI_OP_LE_CS_TEST_REFLECTOR_SNR_27,
145-
BT_LE_CS_TEST_REFLECTOR_SNR_CONTROL_30dB = BT_HCI_OP_LE_CS_TEST_REFLECTOR_SNR_30,
146-
BT_LE_CS_TEST_REFLECTOR_SNR_CONTROL_NOT_USED = BT_HCI_OP_LE_CS_TEST_REFLECTOR_SNR_NOT_USED,
102+
enum bt_le_cs_reflector_snr_control {
103+
BT_LE_CS_REFLECTOR_SNR_CONTROL_18dB = BT_HCI_OP_LE_CS_REFLECTOR_SNR_18,
104+
BT_LE_CS_REFLECTOR_SNR_CONTROL_21dB = BT_HCI_OP_LE_CS_REFLECTOR_SNR_21,
105+
BT_LE_CS_REFLECTOR_SNR_CONTROL_24dB = BT_HCI_OP_LE_CS_REFLECTOR_SNR_24,
106+
BT_LE_CS_REFLECTOR_SNR_CONTROL_27dB = BT_HCI_OP_LE_CS_REFLECTOR_SNR_27,
107+
BT_LE_CS_REFLECTOR_SNR_CONTROL_30dB = BT_HCI_OP_LE_CS_REFLECTOR_SNR_30,
108+
BT_LE_CS_REFLECTOR_SNR_CONTROL_NOT_USED = BT_HCI_OP_LE_CS_REFLECTOR_SNR_NOT_USED,
147109
};
148110

149111
/** CS Test Override 3 T_PM Tone Extension */
@@ -400,11 +362,11 @@ struct bt_le_cs_test_param {
400362
/** Antenna Configuration Index used during antenna switching during
401363
* the tone phases of CS steps.
402364
*/
403-
enum bt_le_cs_test_tone_antenna_config_selection tone_antenna_config_selection;
365+
enum bt_conn_le_cs_tone_antenna_config_selection tone_antenna_config_selection;
404366
/** Initiator SNR control options */
405-
enum bt_le_cs_test_initiator_snr_control initiator_snr_control;
367+
enum bt_le_cs_initiator_snr_control initiator_snr_control;
406368
/** Reflector SNR control options */
407-
enum bt_le_cs_test_reflector_snr_control reflector_snr_control;
369+
enum bt_le_cs_reflector_snr_control reflector_snr_control;
408370
/** Determines octets 14 and 15 of the initial value of the DRBG nonce. */
409371
uint16_t drbg_nonce;
410372

@@ -736,6 +698,178 @@ void bt_le_cs_step_data_parse(struct net_buf_simple *step_data_buf,
736698
bool (*func)(struct bt_le_cs_subevent_step *step, void *user_data),
737699
void *user_data);
738700

701+
/** @brief CS Security Enable
702+
*
703+
* This commmand is used to start or restart the Channel Sounding Security
704+
* Start procedure in the local Controller for the ACL connection identified
705+
* in the conn parameter.
706+
*
707+
* @note To use this API @kconfig{CONFIG_BT_CHANNEL_SOUNDING} must be set.
708+
*
709+
* @param conn Connection Object.
710+
*
711+
* @return Zero on success or (negative) error code on failure.
712+
*/
713+
int bt_le_cs_security_enable(struct bt_conn *conn);
714+
715+
struct bt_le_cs_procedure_enable_param {
716+
uint8_t config_id;
717+
enum bt_conn_le_cs_procedure_enable_state enable;
718+
};
719+
720+
/** @brief CS Procedure Enable
721+
*
722+
* This command is used to enable or disable the scheduling of CS procedures
723+
* by the local Controller, with the remote device identified in the conn
724+
* parameter.
725+
*
726+
* @note To use this API @kconfig{CONFIG_BT_CHANNEL_SOUNDING} must be set.
727+
*
728+
* @param conn Connection Object.
729+
* @param params Parameters for the CS Procedure Enable command.
730+
*
731+
* @return Zero on success or (negative) error code on failure.
732+
*/
733+
int bt_le_cs_procedure_enable(struct bt_conn *conn,
734+
const struct bt_le_cs_procedure_enable_param *params);
735+
736+
enum bt_le_cs_procedure_phy {
737+
BT_LE_CS_PROCEDURE_PHY_1M = BT_HCI_OP_LE_CS_PROCEDURE_PHY_1M,
738+
BT_LE_CS_PROCEUDRE_PHY_2M = BT_HCI_OP_LE_CS_PROCEDURE_PHY_2M,
739+
BT_LE_CS_PROCEDURE_PHY_CODED_S8 = BT_HCI_OP_LE_CS_PROCEDURE_PHY_CODED_S8,
740+
BT_LE_CS_PROCEDURE_PHY_CODED_S2 = BT_HCI_OP_LE_CS_PROCEDURE_PHY_CODED_S2,
741+
};
742+
743+
#define BT_LE_CS_PROCEDURE_PREFERRED_PEER_ANTENNA_1 BIT(0)
744+
#define BT_LE_CS_PROCEDURE_PREFERRED_PEER_ANTENNA_2 BIT(1)
745+
#define BT_LE_CS_PROCEDURE_PREFERRED_PEER_ANTENNA_3 BIT(2)
746+
#define BT_LE_CS_PROCEDURE_PREFERRED_PEER_ANTENNA_4 BIT(3)
747+
748+
struct bt_le_cs_set_procedure_parameters_param {
749+
/* The ID associated with the desired configuration (0 to 3) */
750+
uint8_t config_id;
751+
752+
/* Max. duration for each CS procedure, where T = N * 0.625 ms (0x0001 to 0xFFFF) */
753+
uint16_t max_procedure_len;
754+
755+
/* Min. number of connection events between consecutive CS procedures (0x0001 to 0xFFFF) */
756+
uint16_t min_procedure_interval;
757+
758+
/* Max. number of connection events between consecutive CS procedures (0x0001 to 0xFFFF) */
759+
uint16_t max_procedure_interval;
760+
761+
/* Max. number of procedures to be scheduled (0x0000 for no limit; otherwise 0x0001
762+
* to 0xFFFF)
763+
*/
764+
uint16_t max_procedure_count;
765+
766+
/* Min. suggested duration for each CS subevent in microseconds (1250 us to 4 s) */
767+
uint32_t min_subevent_len;
768+
769+
/* Max. suggested duration for each CS subevent in microseconds (1250 us to 4 s) */
770+
uint32_t max_subevent_len;
771+
772+
/* Antenna configuration index */
773+
enum bt_conn_le_cs_tone_antenna_config_selection tone_antenna_config_selection;
774+
775+
/* Phy */
776+
enum bt_le_cs_procedure_phy phy;
777+
778+
/* Transmit power delta, in signed dB, to indicate the recommended difference between the
779+
* remote device's power level for the CS tones and RTT packets and the existing power
780+
* level for the Phy indicated by the Phy parameter (0x80 for no recommendation)
781+
*/
782+
int8_t tx_power_delta;
783+
784+
/* Preferred peer antenna (Bitmask of BT_LE_CS_PROCEDURE_PREFERRED_PEER_ANTENNA_*) */
785+
uint8_t preferred_peer_antenna;
786+
787+
/* Initiator SNR control adjustment */
788+
enum bt_le_cs_initiator_snr_control snr_control_initiator;
789+
790+
/* Reflector SNR control adjustment */
791+
enum bt_le_cs_reflector_snr_control snr_control_reflector;
792+
};
793+
794+
/** @brief CS Set Procedure Parameters
795+
*
796+
* This command is used to set the parameters for the scheduling of one
797+
* or more CS procedures by the local controller.
798+
*
799+
* @note To use this API @kconfig{CONFIG_BT_CHANNEL_SOUNDING} must be set.
800+
*
801+
* @param conn Connection Object.
802+
* @param params Parameters for the CS Set Procedure Parameters command.
803+
*
804+
* @return Zero on success or (negative) error code on failure.
805+
*/
806+
int bt_le_cs_set_procedure_parameters(struct bt_conn *conn,
807+
const struct bt_le_cs_set_procedure_parameters_param *params);
808+
809+
/** @brief CS Set Channel Classification
810+
*
811+
* This command is used to update the channel classification based on
812+
* its local information.
813+
*
814+
* The nth bitfield (in the range 0 to 78) contains the value for the CS
815+
* channel index n. Channel Enabled = 1; Channel Disabled = 0.
816+
*
817+
* Channels n = 0, 1, 23, 24, 25, 77, and 78 shall be reserved for future
818+
* use and shall be set to zero. At least 15 channels shall be enabled.
819+
*
820+
* The most significant bit (bit 79) is reserved for future use.
821+
*
822+
* @note To use this API, @kconfig{CONFIG_BT_CHANNEL_SOUNDING} must be set.
823+
*
824+
* @param channel_classification Bit fields
825+
*
826+
* @return Zero on success or (negative) error code on failure.
827+
*/
828+
int bt_le_cs_set_channel_classification(uint8_t channel_classification[10]);
829+
830+
/** @brief CS Read Local Supported Capabilities
831+
*
832+
* This command is used to read the CS capabilities that are supported
833+
* by the local Controller.
834+
*
835+
* @note To use this API @kconfig{CONFIG_BT_CHANNEL_SOUNDING} must be set.
836+
*
837+
* @param ret Return values for the CS Procedure Enable command.
838+
*
839+
* @return Zero on success or (negative) error code on failure.
840+
*/
841+
int bt_le_cs_read_local_supported_capabilities(struct bt_conn_le_cs_capabilities *ret);
842+
843+
/** @brief CS Write Cached Remote Supported Capabilities
844+
*
845+
* This command is used to write the cached copy of the CS capabilities
846+
* that are supported by the remote Controller for the connection
847+
* identified.
848+
*
849+
* @note To use this API @kconfig{CONFIG_BT_CHANNEL_SOUNDING} must be set.
850+
*
851+
* @param conn Connection Object.
852+
* @param params Parameters for the CS Write Cached Remote Supported Capabilities command.
853+
*
854+
* @return Zero on success or (negative) error code on failure.
855+
*/
856+
int bt_le_cs_write_cached_remote_supported_capabilities(
857+
struct bt_conn *conn, const struct bt_conn_le_cs_capabilities *params);
858+
859+
/** @brief CS Write Cached Remote FAE Table
860+
*
861+
* This command is used to write a cached copy of the per-channel mode-0
862+
* Frequency Actuation Error table of the remote device in the local Controller.
863+
*
864+
* @note To use this API @kconfig{CONFIG_BT_CHANNEL_SOUNDING} must be set.
865+
*
866+
* @param conn Connection Object.
867+
* @param remote_fae_table Per-channel mode-0 FAE table of the local Controller
868+
*
869+
* @return Zero on success or (negative) error code on failure.
870+
*/
871+
int bt_le_cs_write_cached_remote_fae_table(struct bt_conn *conn, uint8_t remote_fae_table[72]);
872+
739873
#ifdef __cplusplus
740874
}
741875
#endif

0 commit comments

Comments
 (0)