andrzej-kaczmarek commented on code in PR #1682:
URL: https://github.com/apache/mynewt-nimble/pull/1682#discussion_r1504661009
##########
nimble/controller/src/ble_ll.c:
##########
@@ -1930,6 +1930,12 @@ ble_ll_init(void)
features |= BLE_LL_FEAT_CONN_SUBRATING;
#endif
+#if MYNEWT_VAL(BLE_LL_CHANNEL_SOUNDING)
+ features |= BLE_LL_FEAT_CS;
+ features |= BLE_LL_FEAT_CS_HOST_SUPPORT;
Review Comment:
this bit is set by host, see `ble_ll_set_host_feat`
##########
nimble/host/include/host/ble_cs.h:
##########
@@ -0,0 +1,352 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef H_BLE_CS_
+#define H_BLE_CS_
+#include "syscfg/syscfg.h"
+
+struct ble_cs_rd_loc_supp_cap_rp {
Review Comment:
seems like duplicate of hci_common.h - keep it there
##########
nimble/controller/syscfg.yml:
##########
@@ -515,6 +515,14 @@ syscfg.defs:
value: 0
experimental: 1
+ BLE_LL_CHANNEL_SOUNDING:
+ description: >
+ Enable support for Channel Sounding feature.
+ restrictions:
+ - (BLE_VERSION >= 55) if 1
Review Comment:
draft spec says it's update for 5.4 so make it 5.4 here
if new spec is release with cs, we'll update to proper version
##########
nimble/host/include/host/ble_cs.h:
##########
@@ -0,0 +1,352 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef H_BLE_CS_
+#define H_BLE_CS_
+#include "syscfg/syscfg.h"
+
+struct ble_cs_rd_loc_supp_cap_rp {
+ uint8_t status;
+ uint8_t num_config_supported;
+ uint16_t max_consecutive_procedures_supported;
+ uint8_t num_antennas_supported;
+ uint8_t max_antenna_paths_supported;
+ uint8_t roles_supported;
+ uint8_t optional_modes_supported;
+ uint8_t rtt_capability;
+ uint8_t rtt_aa_only_n;
+ uint8_t rtt_sounding_n;
+ uint8_t rtt_random_payload_n;
+ uint16_t optional_nadm_sounding_capability;
+ uint16_t optional_nadm_random_capability;
+ uint8_t optional_cs_sync_phys_supported;
+ uint16_t optional_subfeatures_supported;
+ uint16_t optional_t_ip1_times_supported;
+ uint16_t optional_t_ip2_times_supported;
+ uint16_t optional_t_fcs_times_supported;
+ uint16_t optional_t_pm_times_supported;
+ uint8_t t_sw_time_supported;
+} __attribute__((packed));
+
+struct ble_cs_rd_rem_supp_cap_cp {
+ uint16_t conn_handle;
+} __attribute__((packed));
+struct ble_cs_rem_supp_cap_complete {
+ uint8_t status;
+ uint16_t conn_handle;
+ uint8_t num_config_supported;
+ uint16_t max_consecutive_procedures_supported;
+ uint8_t num_antennas_supported;
+ uint8_t max_antenna_paths_supported;
+ uint8_t roles_supported;
+ uint8_t optional_modes_supported;
+ uint8_t rtt_capability;
+ uint8_t rtt_aa_only_n;
+ uint8_t rtt_sounding_n;
+ uint8_t rtt_random_payload_n;
+ uint16_t optional_nadm_sounding_capability;
+ uint16_t optional_nadm_random_capability;
+ uint8_t optional_cs_sync_phys_supported;
+ uint16_t optional_subfeatures_supported;
+ uint16_t optional_t_ip1_times_supported;
+ uint16_t optional_t_ip2_times_supported;
+ uint16_t optional_t_fcs_times_supported;
+ uint16_t optional_t_pm_times_supported;
+ uint8_t t_sw_time_supported;
+} __attribute__((packed));
+
+struct ble_cs_wr_cached_rem_supp_cap_cp {
+ uint16_t conn_handle;
+ uint8_t num_config_supported;
+ uint16_t max_consecutive_procedures_supported;
+ uint8_t num_antennas_supported;
+ uint8_t max_antenna_paths_supported;
+ uint8_t roles_supported;
+ uint8_t optional_modes_supported;
+ uint8_t rtt_capability;
+ uint8_t rtt_aa_only_n;
+ uint8_t rtt_sounding_n;
+ uint8_t rtt_random_payload_n;
+ uint16_t optional_nadm_sounding_capability;
+ uint16_t optional_nadm_random_capability;
+ uint8_t optional_cs_sync_phys_supported;
+ uint16_t optional_subfeatures_supported;
+ uint16_t optional_t_ip1_times_supported;
+ uint16_t optional_t_ip2_times_supported;
+ uint16_t optional_t_fcs_times_supported;
+ uint16_t optional_t_pm_times_supported;
+ uint8_t t_sw_time_supported;
+} __attribute__((packed));
+struct ble_cs_wr_cached_rem_supp_cap_rp {
+ uint8_t status;
+ uint16_t conn_handle;
+} __attribute__((packed));
+
+struct ble_cs_sec_enable_cp {
+ uint16_t conn_handle;
+} __attribute__((packed));
+struct ble_cs_sec_enable_complete {
+ uint8_t status;
+ uint16_t conn_handle;
+} __attribute__((packed));
+
+struct ble_cs_set_def_settings_cp {
+ uint16_t conn_handle;
+ uint8_t role_enable;
+ uint8_t cs_sync_antenna_selection;
+ uint8_t max_tx_power;
+} __attribute__((packed));
+struct ble_cs_set_def_settings_rp {
+ uint8_t status;
+ uint16_t conn_handle;
+} __attribute__((packed));
+
+struct ble_cs_rd_rem_fae_cp {
+ uint16_t conn_handle;
+} __attribute__((packed));
+struct ble_cs_rd_rem_fae_complete {
+ uint8_t status;
+ uint16_t conn_handle;
+ uint8_t remote_fae_table[72];
+} __attribute__((packed));
+
+struct ble_cs_wr_cached_rem_fae_cp {
+ uint16_t conn_handle;
+ uint8_t remote_fae_table[72];
+} __attribute__((packed));
+struct ble_cs_wr_cached_rem_fae_rp {
+ uint8_t status;
+ uint16_t conn_handle;
+} __attribute__((packed));
+
+struct ble_cs_create_config_cp {
+ uint16_t conn_handle;
+ uint8_t config_id;
+ /* If the config should be created on the remote controller too */
+ uint8_t create_context;
+ /* The main mode to be used in the CS procedures */
+ uint8_t main_mode_type;
+ /* The sub mode to be used in the CS procedures */
+ uint8_t sub_mode_type;
+ /* Minimum/maximum number of CS main mode steps to be executed before
+ * a submode step.
+ */
+ uint8_t min_main_mode_steps;
+ uint8_t max_main_mode_steps;
+ /* The number of main mode steps taken from the end of the last
+ * CS subevent to be repeated at the beginning of the current CS subevent
+ * directly after the last mode 0 step of that event
+ */
+ uint8_t main_mode_repetition;
+ uint8_t mode_0_steps;
+ uint8_t role;
+ uint8_t rtt_type;
+ uint8_t cs_sync_phy;
+ uint8_t channel_map[10];
+ uint8_t channel_map_repetition;
+ uint8_t channel_selection_type;
+ uint8_t ch3c_shape;
+ uint8_t ch3c_jump;
+ uint8_t companion_signal_enable;
+} __attribute__((packed));
+struct ble_cs_config_complete {
+ uint8_t status;
+ uint16_t conn_handle;
+ uint8_t config_id;
+ uint8_t action;
+ uint8_t main_mode_type;
+ uint8_t sub_mode_type;
+ uint8_t min_main_mode_steps;
+ uint8_t max_main_mode_steps;
+ uint8_t main_mode_repetition;
+ uint8_t mode_0_steps;
+ uint8_t role;
+ uint8_t rtt_type;
+ uint8_t cs_sync_phy;
+ uint8_t channel_map[10];
+ uint8_t channel_map_repetition;
+ uint8_t channel_selection_type;
+ uint8_t ch3c_shape;
+ uint8_t ch3c_jump;
+ uint8_t companion_signal_enable;
+ uint8_t t_ip1_time;
+ uint8_t t_ip2_time;
+ uint8_t t_fcs_time;
+ uint8_t t_pm_time;
+} __attribute__((packed));
+
+struct ble_cs_remove_config_cp {
+ uint16_t conn_handle;
+ uint8_t config_id;
+} __attribute__((packed));
+
+struct ble_cs_set_chan_class_cp {
+ uint8_t channel_classification[10];
+} __attribute__((packed));
+struct ble_cs_set_chan_class_rp {
+ uint8_t status;
+} __attribute__((packed));
+
+struct ble_cs_set_proc_params_cp {
+ uint16_t conn_handle;
+ uint8_t config_id;
+ /* The maximum duration of each CS procedure (time = N × 0.625 ms) */
+ uint16_t max_procedure_len;
+ /* The minimum and maximum number of connection events between
+ * consecutive CS procedures. Ignored if only one CS procedure. */
+ uint16_t min_procedure_interval;
+ uint16_t max_procedure_interval;
+ /* The maximum number of consecutive CS procedures to be scheduled */
+ uint16_t max_procedure_count;
+ /* Minimum/maximum suggested durations for each CS subevent in
microseconds.
+ * Only 3 bytes meaningful. */
+ uint32_t min_subevent_len;
+ uint32_t max_subevent_len;
+ /* Antenna Configuration Index (ACI) for swithing during phase measuement
*/
+ uint8_t tone_antenna_config_selection;
+ /* The remote device’s Tx PHY. A 4 bits bitmap. */
+ uint8_t phy;
+ /* How many more or fewer of transmit power levels should the remote
device’s
+ * Tx PHY use during the CS tones and RTT transmission */
+ uint8_t tx_power_delta;
+ /* Preferred peer-ordered antenna elements to be used by the peer for
+ * the selected antenna configuration (ACI). A 4 bits bitmap. */
+ uint8_t preferred_peer_antenna;
+ /* SNR Output Index (SOI) for SNR control adjustment. */
+ uint8_t snr_control_initiator;
+ uint8_t snr_control_reflector;
+} __attribute__((packed));
+struct ble_cs_set_proc_params_rp {
+ uint8_t status;
+ uint16_t conn_handle;
+} __attribute__((packed));
+
+struct ble_cs_proc_enable_cp {
+ uint16_t conn_handle;
+ uint8_t config_id;
+ uint8_t enable;
+} __attribute__((packed));
+struct ble_cs_proc_enable_complete {
+ uint8_t status;
+ uint16_t conn_handle;
+ uint8_t config_id;
+ uint8_t state;
+ uint8_t tone_antenna_config_selection;
+ uint8_t selected_tx_power;
+ uint8_t subevent_len[3];
+ uint8_t subevents_per_event;
+ uint16_t subevent_interval;
+ uint16_t event_interval;
+ uint16_t procedure_interval;
+ uint16_t procedure_count;
+} __attribute__((packed));
+struct ble_cs_subevent_result {
+ uint16_t conn_handle;
+ uint8_t config_id;
+ uint16_t start_acl_conn_event_counter;
+ uint16_t procedure_counter;
+ uint16_t frequency_compensation;
+ uint8_t reference_power_level;
+ uint8_t procedure_done_status;
+ uint8_t subevent_done_status;
+ uint8_t abort_reason;
+ uint8_t num_antenna_paths;
+ uint8_t num_steps_reported;
+ uint8_t steps[];
+} __attribute__((packed));
+struct ble_cs_subevent_result_continue {
+ uint16_t conn_handle;
+ uint8_t config_id;
+ uint8_t procedure_done_status;
+ uint8_t subevent_done_status;
+ uint8_t abort_reason;
+ uint8_t num_antenna_paths;
+ uint8_t num_steps_reported;
+ uint8_t steps[];
+} __attribute__((packed));
+
+struct ble_cs_test_cp {
+ uint8_t main_mode_type;
+ uint8_t sub_mode_type;
+ uint8_t main_mode_repetition;
+ uint8_t mode_0_steps;
+ uint8_t role;
+ uint8_t rtt_type;
+ uint8_t cs_sync_phy;
+ uint8_t cs_sync_antenna_selection;
+ uint8_t subevent_len[3];
+ uint16_t subevent_interval;
+ uint8_t transmit_power_level;
+ uint8_t t_ip1_time;
+ uint8_t t_ip2_time;
+ uint8_t t_fcs_time;
+ uint8_t t_pm_time;
+ uint8_t t_sw_time;
+ uint8_t tone_antenna_config_selection;
+ uint8_t companion_signal_enable;
+ uint16_t drbg_nonce;
+ uint16_t override_config;
+ uint8_t override_parameters_length;
+ uint8_t override_parameters_data[];
+} __attribute__((packed));
+struct ble_cs_test_rp {
+ uint8_t status;
+} __attribute__((packed));
+
+/**
+ * CS event callbacks.
+ */
+struct ble_cs_callbacks {
+ void (*rd_rem_supp_cap_cb)(struct ble_cs_rem_supp_cap_complete *ev);
+ void (*rd_rem_fae_cb)(struct ble_cs_rd_rem_fae_complete *ev);
+ void (*sec_enable_cb)(struct ble_cs_sec_enable_complete *ev);
+ void (*config_cb)(struct ble_cs_config_complete *ev);
+ void (*proc_enable_cb)(struct ble_cs_proc_enable_complete *evt);
+ void (*subevent_result_cb)(struct ble_cs_subevent_result *evt);
+ void (*subevent_result_continue_cb)(struct ble_cs_subevent_result_continue
*evt);
+ void (*test_end_cb)(int status);
+};
+
+void ble_cs_register_callbacks(struct ble_cs_callbacks *cbs);
+
+int ble_cs_rd_loc_supp_cap(struct ble_cs_rd_loc_supp_cap_rp *rsp);
+int ble_cs_rd_rem_supp_cap(const struct ble_cs_rd_rem_supp_cap_cp *cmd);
+int ble_cs_wr_cached_rem_supp_cap(const struct
ble_cs_wr_cached_rem_supp_cap_cp *cmd,
+ struct ble_cs_wr_cached_rem_supp_cap_rp
*rsp);
+int ble_cs_sec_enable(const struct ble_cs_sec_enable_cp *cmd);
+int ble_cs_set_def_settings(const struct ble_cs_set_def_settings_cp *cmd,
struct ble_cs_set_def_settings_rp *rsp);
+int ble_cs_rd_rem_fae(const struct ble_cs_rd_rem_fae_cp *cmd);
+int ble_cs_wr_cached_rem_fae(const struct ble_cs_wr_cached_rem_fae_cp *cmd,
struct ble_cs_wr_cached_rem_fae_rp *rsp);
+int ble_cs_create_config(const struct ble_cs_create_config_cp *cmd);
+int ble_cs_remove_config(const struct ble_cs_remove_config_cp *cmd);
+int ble_cs_set_chan_class(const struct ble_cs_set_chan_class_cp *cmd, struct
ble_cs_set_chan_class_rp *rsp);
+int ble_cs_set_proc_params(const struct ble_cs_set_proc_params_cp *cmd, struct
ble_cs_set_proc_params_rp *rsp);
+int ble_cs_proc_enable(const struct ble_cs_proc_enable_cp *cmd);
+int ble_cs_test(const struct ble_cs_test_cp *cmd, struct ble_cs_test_rp *rsp);
+int ble_cs_test_end(void);
+
+int ble_hs_hci_evt_le_cs_rd_rem_supp_cap_complete(uint8_t subevent, const void
*data, unsigned int len);
+int ble_hs_hci_evt_le_cs_rd_rem_fae_complete(uint8_t subevent, const void
*data, unsigned int len);
+int ble_hs_hci_evt_le_cs_sec_enable_complete(uint8_t subevent, const void
*data, unsigned int len);
+int ble_hs_hci_evt_le_cs_config_complete(uint8_t subevent, const void *data,
unsigned int len);
+int ble_hs_hci_evt_le_cs_proc_enable_complete(uint8_t subevent, const void
*data, unsigned int len);
+int ble_hs_hci_evt_le_cs_subevent_result(uint8_t subevent, const void *data,
unsigned int len);
+int ble_hs_hci_evt_le_cs_subevent_result_continue(uint8_t subevent, const void
*data, unsigned int len);
+int ble_hs_hci_evt_le_cs_test_end_complete(uint8_t subevent, const void *data,
unsigned int len);
Review Comment:
this will be a public API so move internal prototypes to ble_cs_priv.h in
src/
##########
nimble/include/nimble/hci_common.h:
##########
@@ -1993,6 +2178,140 @@ struct ble_hci_ev_le_subev_subrate_change {
uint16_t supervision_tmo;
} __attribute__((packed));
+#define BLE_HCI_LE_SUBEV_CS_RD_REM_SUPP_CAP_COMPLETE (0x2C)
+struct ble_hci_ev_le_subev_cs_rd_rem_supp_cap_complete {
+ uint8_t subev_code;
+ uint8_t status;
+ uint16_t conn_handle;
+ uint8_t num_config_supported;
+ uint16_t max_consecutive_procedures_supported;
+ uint8_t num_antennas_supported;
+ uint8_t max_antenna_paths_supported;
+ uint8_t roles_supported;
+ uint8_t optional_modes_supported;
+ uint8_t rtt_capability;
+ uint8_t rtt_aa_only_n;
+ uint8_t rtt_sounding_n;
+ uint8_t rtt_random_payload_n;
+ uint16_t optional_nadm_sounding_capability;
+ uint16_t optional_nadm_random_capability;
+ uint8_t optional_cs_sync_phys_supported;
+ uint16_t optional_subfeatures_supported;
+ uint16_t optional_t_ip1_times_supported;
+ uint16_t optional_t_ip2_times_supported;
+ uint16_t optional_t_fcs_times_supported;
+ uint16_t optional_t_pm_times_supported;
+ uint8_t t_sw_time_supported;
+} __attribute__((packed));
+
+#define BLE_HCI_LE_SUBEV_CS_RD_REM_FAE_COMPLETE (0x2D)
+struct ble_hci_ev_le_subev_cs_rd_rem_fae_complete {
+ uint8_t subev_code;
+ uint8_t status;
+ uint16_t conn_handle;
+ uint8_t remote_fae_table[72];
+} __attribute__((packed));
+
+#define BLE_HCI_LE_SUBEV_CS_SEC_ENABLE_COMPLETE (0x2E)
+struct ble_hci_ev_le_subev_cs_sec_enable_complete {
+ uint8_t subev_code;
+ uint8_t status;
+ uint16_t conn_handle;
+} __attribute__((packed));
+
+#define BLE_HCI_LE_SUBEV_CS_CONFIG_COMPLETE (0x2F)
+struct ble_hci_ev_le_subev_cs_config_complete {
+ uint8_t subev_code;
+ uint8_t status;
+ uint16_t conn_handle;
+ uint8_t config_id;
+ uint8_t action;
+ uint8_t main_mode_type;
+ uint8_t sub_mode_type;
+ uint8_t min_main_mode_steps;
+ uint8_t max_main_mode_steps;
+ uint8_t main_mode_repetition;
+ uint8_t mode_0_steps;
+ uint8_t role;
+ uint8_t rtt_type;
+ uint8_t cs_sync_phy;
+ uint8_t channel_map[10];
+ uint8_t channel_map_repetition;
+ uint8_t channel_selection_type;
+ uint8_t ch3c_shape;
+ uint8_t ch3c_jump;
+ uint8_t companion_signal_enable;
+ uint8_t t_ip1_time;
+ uint8_t t_ip2_time;
+ uint8_t t_fcs_time;
+ uint8_t t_pm_time;
+} __attribute__((packed));
+
+#define BLE_HCI_LE_SUBEV_CS_PROC_ENABLE_COMPLETE (0x30)
+struct ble_hci_ev_le_subev_cs_proc_enable_complete {
+ uint8_t subev_code;
+ uint8_t status;
+ uint16_t conn_handle;
+ uint8_t config_id;
+ uint8_t state;
+ uint8_t tone_antenna_config_selection;
+ uint8_t selected_tx_power;
+ uint8_t subevent_len[3];
+ uint8_t subevents_per_event;
+ uint16_t subevent_interval;
+ uint16_t event_interval;
+ uint16_t procedure_interval;
+ uint16_t procedure_count;
+} __attribute__((packed));
+
+#define BLE_HCI_LE_SUBEV_CS_SUBEVENT_RESULT (0x31)
+struct ble_hci_ev_le_subev_cs_subevent_result {
+ uint8_t subev_code;
+ uint16_t conn_handle;
+ uint8_t config_id;
+ uint16_t start_acl_conn_event_counter;
+ uint16_t procedure_counter;
+ uint16_t frequency_compensation;
+ uint8_t reference_power_level;
+ uint8_t procedure_done_status;
+ uint8_t subevent_done_status;
+ uint8_t abort_reason;
+ uint8_t num_antenna_paths;
+ uint8_t num_steps_reported;
+ uint8_t steps[];
+/* TODO:
+ * step_mode[i];
+ * step_channel[i];
+ * step_data_length[i];
+ * step_data[i];
+ */
Review Comment:
add this as separate struct and use above in variable length array, see
`ble_hci_vs_subev_iso_hci_feedback`
##########
nimble/syscfg.yml:
##########
@@ -87,7 +87,7 @@ syscfg.defs:
This allows to configure supported Bluetooth Core version. Some
features may not be available if version is too low. Version is
integer for easy comparison.
- range: 50, 51, 52, 53, 54
+ range: 50, 51, 52, 53, 54, 55
Review Comment:
do not add 5.5, there's no such spec version as for now
##########
nimble/include/nimble/hci_common.h:
##########
@@ -1149,6 +1149,191 @@ struct ble_hci_le_subrate_req_cp {
uint16_t supervision_tmo;
} __attribute__((packed));
+#define BLE_HCI_OCF_LE_CS_RD_LOC_SUPP_CAP (0x0089)
+struct ble_hci_le_cs_rd_loc_supp_cap_rp {
+ uint8_t status;
+ uint8_t num_config_supported;
+ uint16_t max_consecutive_procedures_supported;
+ uint8_t num_antennas_supported;
+ uint8_t max_antenna_paths_supported;
+ uint8_t roles_supported;
+ uint8_t optional_modes_supported;
+ uint8_t rtt_capability;
+ uint8_t rtt_aa_only_n;
+ uint8_t rtt_sounding_n;
+ uint8_t rtt_random_payload_n;
+ uint16_t optional_nadm_sounding_capability;
+ uint16_t optional_nadm_random_capability;
+ uint8_t optional_cs_sync_phys_supported;
+ uint16_t optional_subfeatures_supported;
+ uint16_t optional_t_ip1_times_supported;
+ uint16_t optional_t_ip2_times_supported;
+ uint16_t optional_t_fcs_times_supported;
+ uint16_t optional_t_pm_times_supported;
+ uint8_t t_sw_time_supported;
+} __attribute__((packed));
+
+#define BLE_HCI_OCF_LE_CS_RD_REM_SUPP_CAP (0x008A)
+struct ble_hci_le_cs_rd_rem_supp_cap_cp {
+ uint16_t conn_handle;
+} __attribute__((packed));
+
+#define BLE_HCI_OCF_LE_CS_WR_CACHED_REM_SUPP_CAP (0x008B)
+struct ble_hci_le_cs_wr_cached_rem_supp_cap_cp {
+ uint16_t conn_handle;
+ uint8_t num_config_supported;
+ uint16_t max_consecutive_procedures_supported;
+ uint8_t num_antennas_supported;
+ uint8_t max_antenna_paths_supported;
+ uint8_t roles_supported;
+ uint8_t optional_modes_supported;
+ uint8_t rtt_capability;
+ uint8_t rtt_aa_only_n;
+ uint8_t rtt_sounding_n;
+ uint8_t rtt_random_payload_n;
+ uint16_t optional_nadm_sounding_capability;
+ uint16_t optional_nadm_random_capability;
+ uint8_t optional_cs_sync_phys_supported;
+ uint16_t optional_subfeatures_supported;
+ uint16_t optional_t_ip1_times_supported;
+ uint16_t optional_t_ip2_times_supported;
+ uint16_t optional_t_fcs_times_supported;
+ uint16_t optional_t_pm_times_supported;
+ uint8_t t_sw_time_supported;
+} __attribute__((packed));
+struct ble_hci_le_cs_wr_cached_rem_supp_cap_rp {
+ uint8_t status;
+ uint16_t conn_handle;
+} __attribute__((packed));
+
+#define BLE_HCI_OCF_LE_CS_SEC_ENABLE (0x008C)
+struct ble_hci_le_cs_sec_enable_cp {
+ uint16_t conn_handle;
+} __attribute__((packed));
+
+#define BLE_HCI_OCF_LE_CS_SET_DEF_SETTINGS (0x008D)
+struct ble_hci_le_cs_set_def_settings_cp {
+ uint16_t conn_handle;
+ uint8_t role_enable;
+ uint8_t cs_sync_antenna_selection;
+ uint8_t max_tx_power;
+} __attribute__((packed));
+struct ble_hci_le_cs_set_def_settings_rp {
+ uint8_t status;
+ uint16_t conn_handle;
+} __attribute__((packed));
+
+#define BLE_HCI_OCF_LE_CS_RD_REM_FAE (0x008E)
+struct ble_hci_le_cs_rd_rem_fae_cp {
+ uint16_t conn_handle;
+} __attribute__((packed));
+
+#define BLE_HCI_OCF_LE_CS_WR_CACHED_REM_FAE (0x008F)
+struct ble_hci_le_cs_wr_cached_rem_fae_cp {
+ uint16_t conn_handle;
+ uint8_t remote_fae_table[72];
+} __attribute__((packed));
+struct ble_hci_le_cs_wr_cached_rem_fae_rp {
+ uint8_t status;
+ uint16_t conn_handle;
+} __attribute__((packed));
+
+#define BLE_HCI_OCF_LE_CS_CREATE_CONFIG (0x0090)
+struct ble_hci_le_cs_create_config_cp {
+ uint16_t conn_handle;
+ uint8_t config_id;
+ uint8_t create_context;
+ uint8_t main_mode_type;
+ uint8_t sub_mode_type;
+ uint8_t min_main_mode_steps;
+ uint8_t max_main_mode_steps;
+ uint8_t main_mode_repetition;
+ uint8_t mode_0_steps;
+ uint8_t role;
+ uint8_t rtt_type;
+ uint8_t cs_sync_phy;
+ uint8_t channel_map[10];
+ uint8_t channel_map_repetition;
+ uint8_t channel_selection_type;
+ uint8_t ch3c_shape;
+ uint8_t ch3c_jump;
+ uint8_t companion_signal_enable;
+} __attribute__((packed));
+
+#define BLE_HCI_OCF_LE_CS_REMOVE_CONFIG (0x0091)
+struct ble_hci_le_cs_remove_config_cp {
+ uint16_t conn_handle;
+ uint8_t config_id;
+} __attribute__((packed));
+
+#define BLE_HCI_OCF_LE_CS_SET_CHAN_CLASS (0x0092)
+struct ble_hci_le_cs_set_chan_class_cp {
+ uint8_t channel_classification[10];
+} __attribute__((packed));
+struct ble_hci_le_cs_set_chan_class_rp {
+ uint8_t status;
Review Comment:
no need for struct if only status is returned
##########
nimble/controller/src/ble_ll_cs.c:
##########
@@ -0,0 +1,164 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <syscfg/syscfg.h>
+#if MYNEWT_VAL(BLE_LL_CHANNEL_SOUNDING)
+#include <stdint.h>
+#include "nimble/hci_common.h"
+#include "controller/ble_ll_utils.h"
+#include "controller/ble_ll.h"
+#include "controller/ble_ll_conn.h"
+#include "controller/ble_ll_hci.h"
+#include "controller/ble_ll_cs.h"
+
+/*
+ * Host asked for local CS capabilities.
+ */
Review Comment:
remove these comments from .c
##########
nimble/host/include/host/ble_cs.h:
##########
@@ -0,0 +1,352 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef H_BLE_CS_
+#define H_BLE_CS_
+#include "syscfg/syscfg.h"
+
+struct ble_cs_rd_loc_supp_cap_rp {
+ uint8_t status;
+ uint8_t num_config_supported;
+ uint16_t max_consecutive_procedures_supported;
+ uint8_t num_antennas_supported;
+ uint8_t max_antenna_paths_supported;
+ uint8_t roles_supported;
+ uint8_t optional_modes_supported;
+ uint8_t rtt_capability;
+ uint8_t rtt_aa_only_n;
+ uint8_t rtt_sounding_n;
+ uint8_t rtt_random_payload_n;
+ uint16_t optional_nadm_sounding_capability;
+ uint16_t optional_nadm_random_capability;
+ uint8_t optional_cs_sync_phys_supported;
+ uint16_t optional_subfeatures_supported;
+ uint16_t optional_t_ip1_times_supported;
+ uint16_t optional_t_ip2_times_supported;
+ uint16_t optional_t_fcs_times_supported;
+ uint16_t optional_t_pm_times_supported;
+ uint8_t t_sw_time_supported;
+} __attribute__((packed));
+
+struct ble_cs_rd_rem_supp_cap_cp {
+ uint16_t conn_handle;
+} __attribute__((packed));
+struct ble_cs_rem_supp_cap_complete {
+ uint8_t status;
+ uint16_t conn_handle;
+ uint8_t num_config_supported;
+ uint16_t max_consecutive_procedures_supported;
+ uint8_t num_antennas_supported;
+ uint8_t max_antenna_paths_supported;
+ uint8_t roles_supported;
+ uint8_t optional_modes_supported;
+ uint8_t rtt_capability;
+ uint8_t rtt_aa_only_n;
+ uint8_t rtt_sounding_n;
+ uint8_t rtt_random_payload_n;
+ uint16_t optional_nadm_sounding_capability;
+ uint16_t optional_nadm_random_capability;
+ uint8_t optional_cs_sync_phys_supported;
+ uint16_t optional_subfeatures_supported;
+ uint16_t optional_t_ip1_times_supported;
+ uint16_t optional_t_ip2_times_supported;
+ uint16_t optional_t_fcs_times_supported;
+ uint16_t optional_t_pm_times_supported;
+ uint8_t t_sw_time_supported;
+} __attribute__((packed));
+
+struct ble_cs_wr_cached_rem_supp_cap_cp {
+ uint16_t conn_handle;
+ uint8_t num_config_supported;
+ uint16_t max_consecutive_procedures_supported;
+ uint8_t num_antennas_supported;
+ uint8_t max_antenna_paths_supported;
+ uint8_t roles_supported;
+ uint8_t optional_modes_supported;
+ uint8_t rtt_capability;
+ uint8_t rtt_aa_only_n;
+ uint8_t rtt_sounding_n;
+ uint8_t rtt_random_payload_n;
+ uint16_t optional_nadm_sounding_capability;
+ uint16_t optional_nadm_random_capability;
+ uint8_t optional_cs_sync_phys_supported;
+ uint16_t optional_subfeatures_supported;
+ uint16_t optional_t_ip1_times_supported;
+ uint16_t optional_t_ip2_times_supported;
+ uint16_t optional_t_fcs_times_supported;
+ uint16_t optional_t_pm_times_supported;
+ uint8_t t_sw_time_supported;
+} __attribute__((packed));
+struct ble_cs_wr_cached_rem_supp_cap_rp {
+ uint8_t status;
+ uint16_t conn_handle;
+} __attribute__((packed));
+
+struct ble_cs_sec_enable_cp {
+ uint16_t conn_handle;
+} __attribute__((packed));
+struct ble_cs_sec_enable_complete {
+ uint8_t status;
+ uint16_t conn_handle;
+} __attribute__((packed));
+
+struct ble_cs_set_def_settings_cp {
+ uint16_t conn_handle;
+ uint8_t role_enable;
+ uint8_t cs_sync_antenna_selection;
+ uint8_t max_tx_power;
+} __attribute__((packed));
+struct ble_cs_set_def_settings_rp {
+ uint8_t status;
+ uint16_t conn_handle;
+} __attribute__((packed));
+
+struct ble_cs_rd_rem_fae_cp {
+ uint16_t conn_handle;
+} __attribute__((packed));
+struct ble_cs_rd_rem_fae_complete {
+ uint8_t status;
+ uint16_t conn_handle;
+ uint8_t remote_fae_table[72];
+} __attribute__((packed));
+
+struct ble_cs_wr_cached_rem_fae_cp {
+ uint16_t conn_handle;
+ uint8_t remote_fae_table[72];
+} __attribute__((packed));
+struct ble_cs_wr_cached_rem_fae_rp {
+ uint8_t status;
+ uint16_t conn_handle;
+} __attribute__((packed));
+
+struct ble_cs_create_config_cp {
+ uint16_t conn_handle;
+ uint8_t config_id;
+ /* If the config should be created on the remote controller too */
+ uint8_t create_context;
+ /* The main mode to be used in the CS procedures */
+ uint8_t main_mode_type;
+ /* The sub mode to be used in the CS procedures */
+ uint8_t sub_mode_type;
+ /* Minimum/maximum number of CS main mode steps to be executed before
+ * a submode step.
+ */
+ uint8_t min_main_mode_steps;
+ uint8_t max_main_mode_steps;
+ /* The number of main mode steps taken from the end of the last
+ * CS subevent to be repeated at the beginning of the current CS subevent
+ * directly after the last mode 0 step of that event
+ */
+ uint8_t main_mode_repetition;
+ uint8_t mode_0_steps;
+ uint8_t role;
+ uint8_t rtt_type;
+ uint8_t cs_sync_phy;
+ uint8_t channel_map[10];
+ uint8_t channel_map_repetition;
+ uint8_t channel_selection_type;
+ uint8_t ch3c_shape;
+ uint8_t ch3c_jump;
+ uint8_t companion_signal_enable;
+} __attribute__((packed));
+struct ble_cs_config_complete {
+ uint8_t status;
+ uint16_t conn_handle;
+ uint8_t config_id;
+ uint8_t action;
+ uint8_t main_mode_type;
+ uint8_t sub_mode_type;
+ uint8_t min_main_mode_steps;
+ uint8_t max_main_mode_steps;
+ uint8_t main_mode_repetition;
+ uint8_t mode_0_steps;
+ uint8_t role;
+ uint8_t rtt_type;
+ uint8_t cs_sync_phy;
+ uint8_t channel_map[10];
+ uint8_t channel_map_repetition;
+ uint8_t channel_selection_type;
+ uint8_t ch3c_shape;
+ uint8_t ch3c_jump;
+ uint8_t companion_signal_enable;
+ uint8_t t_ip1_time;
+ uint8_t t_ip2_time;
+ uint8_t t_fcs_time;
+ uint8_t t_pm_time;
+} __attribute__((packed));
+
+struct ble_cs_remove_config_cp {
+ uint16_t conn_handle;
+ uint8_t config_id;
+} __attribute__((packed));
+
+struct ble_cs_set_chan_class_cp {
+ uint8_t channel_classification[10];
+} __attribute__((packed));
+struct ble_cs_set_chan_class_rp {
+ uint8_t status;
+} __attribute__((packed));
+
+struct ble_cs_set_proc_params_cp {
+ uint16_t conn_handle;
+ uint8_t config_id;
+ /* The maximum duration of each CS procedure (time = N × 0.625 ms) */
+ uint16_t max_procedure_len;
+ /* The minimum and maximum number of connection events between
+ * consecutive CS procedures. Ignored if only one CS procedure. */
+ uint16_t min_procedure_interval;
+ uint16_t max_procedure_interval;
+ /* The maximum number of consecutive CS procedures to be scheduled */
+ uint16_t max_procedure_count;
+ /* Minimum/maximum suggested durations for each CS subevent in
microseconds.
+ * Only 3 bytes meaningful. */
+ uint32_t min_subevent_len;
+ uint32_t max_subevent_len;
+ /* Antenna Configuration Index (ACI) for swithing during phase measuement
*/
+ uint8_t tone_antenna_config_selection;
+ /* The remote device’s Tx PHY. A 4 bits bitmap. */
+ uint8_t phy;
+ /* How many more or fewer of transmit power levels should the remote
device’s
+ * Tx PHY use during the CS tones and RTT transmission */
+ uint8_t tx_power_delta;
+ /* Preferred peer-ordered antenna elements to be used by the peer for
+ * the selected antenna configuration (ACI). A 4 bits bitmap. */
+ uint8_t preferred_peer_antenna;
+ /* SNR Output Index (SOI) for SNR control adjustment. */
+ uint8_t snr_control_initiator;
+ uint8_t snr_control_reflector;
+} __attribute__((packed));
+struct ble_cs_set_proc_params_rp {
+ uint8_t status;
+ uint16_t conn_handle;
+} __attribute__((packed));
+
+struct ble_cs_proc_enable_cp {
+ uint16_t conn_handle;
+ uint8_t config_id;
+ uint8_t enable;
+} __attribute__((packed));
+struct ble_cs_proc_enable_complete {
+ uint8_t status;
+ uint16_t conn_handle;
+ uint8_t config_id;
+ uint8_t state;
+ uint8_t tone_antenna_config_selection;
+ uint8_t selected_tx_power;
+ uint8_t subevent_len[3];
+ uint8_t subevents_per_event;
+ uint16_t subevent_interval;
+ uint16_t event_interval;
+ uint16_t procedure_interval;
+ uint16_t procedure_count;
+} __attribute__((packed));
+struct ble_cs_subevent_result {
+ uint16_t conn_handle;
+ uint8_t config_id;
+ uint16_t start_acl_conn_event_counter;
+ uint16_t procedure_counter;
+ uint16_t frequency_compensation;
+ uint8_t reference_power_level;
+ uint8_t procedure_done_status;
+ uint8_t subevent_done_status;
+ uint8_t abort_reason;
+ uint8_t num_antenna_paths;
+ uint8_t num_steps_reported;
+ uint8_t steps[];
+} __attribute__((packed));
+struct ble_cs_subevent_result_continue {
+ uint16_t conn_handle;
+ uint8_t config_id;
+ uint8_t procedure_done_status;
+ uint8_t subevent_done_status;
+ uint8_t abort_reason;
+ uint8_t num_antenna_paths;
+ uint8_t num_steps_reported;
+ uint8_t steps[];
+} __attribute__((packed));
+
+struct ble_cs_test_cp {
+ uint8_t main_mode_type;
+ uint8_t sub_mode_type;
+ uint8_t main_mode_repetition;
+ uint8_t mode_0_steps;
+ uint8_t role;
+ uint8_t rtt_type;
+ uint8_t cs_sync_phy;
+ uint8_t cs_sync_antenna_selection;
+ uint8_t subevent_len[3];
+ uint16_t subevent_interval;
+ uint8_t transmit_power_level;
+ uint8_t t_ip1_time;
+ uint8_t t_ip2_time;
+ uint8_t t_fcs_time;
+ uint8_t t_pm_time;
+ uint8_t t_sw_time;
+ uint8_t tone_antenna_config_selection;
+ uint8_t companion_signal_enable;
+ uint16_t drbg_nonce;
+ uint16_t override_config;
+ uint8_t override_parameters_length;
+ uint8_t override_parameters_data[];
+} __attribute__((packed));
+struct ble_cs_test_rp {
+ uint8_t status;
+} __attribute__((packed));
+
+/**
+ * CS event callbacks.
+ */
+struct ble_cs_callbacks {
+ void (*rd_rem_supp_cap_cb)(struct ble_cs_rem_supp_cap_complete *ev);
+ void (*rd_rem_fae_cb)(struct ble_cs_rd_rem_fae_complete *ev);
+ void (*sec_enable_cb)(struct ble_cs_sec_enable_complete *ev);
+ void (*config_cb)(struct ble_cs_config_complete *ev);
+ void (*proc_enable_cb)(struct ble_cs_proc_enable_complete *evt);
+ void (*subevent_result_cb)(struct ble_cs_subevent_result *evt);
+ void (*subevent_result_continue_cb)(struct ble_cs_subevent_result_continue
*evt);
+ void (*test_end_cb)(int status);
+};
+
+void ble_cs_register_callbacks(struct ble_cs_callbacks *cbs);
Review Comment:
for consistency we should better use similar handling of events as we have
for e.g. GAP, i.e. add handler to the function that starts procedure and use
event struct to pass different events
##########
nimble/include/nimble/hci_common.h:
##########
@@ -1149,6 +1149,191 @@ struct ble_hci_le_subrate_req_cp {
uint16_t supervision_tmo;
} __attribute__((packed));
+#define BLE_HCI_OCF_LE_CS_RD_LOC_SUPP_CAP (0x0089)
+struct ble_hci_le_cs_rd_loc_supp_cap_rp {
+ uint8_t status;
+ uint8_t num_config_supported;
+ uint16_t max_consecutive_procedures_supported;
+ uint8_t num_antennas_supported;
+ uint8_t max_antenna_paths_supported;
+ uint8_t roles_supported;
+ uint8_t optional_modes_supported;
+ uint8_t rtt_capability;
+ uint8_t rtt_aa_only_n;
+ uint8_t rtt_sounding_n;
+ uint8_t rtt_random_payload_n;
+ uint16_t optional_nadm_sounding_capability;
+ uint16_t optional_nadm_random_capability;
+ uint8_t optional_cs_sync_phys_supported;
+ uint16_t optional_subfeatures_supported;
+ uint16_t optional_t_ip1_times_supported;
+ uint16_t optional_t_ip2_times_supported;
+ uint16_t optional_t_fcs_times_supported;
+ uint16_t optional_t_pm_times_supported;
+ uint8_t t_sw_time_supported;
+} __attribute__((packed));
+
+#define BLE_HCI_OCF_LE_CS_RD_REM_SUPP_CAP (0x008A)
+struct ble_hci_le_cs_rd_rem_supp_cap_cp {
+ uint16_t conn_handle;
+} __attribute__((packed));
+
+#define BLE_HCI_OCF_LE_CS_WR_CACHED_REM_SUPP_CAP (0x008B)
+struct ble_hci_le_cs_wr_cached_rem_supp_cap_cp {
+ uint16_t conn_handle;
+ uint8_t num_config_supported;
+ uint16_t max_consecutive_procedures_supported;
+ uint8_t num_antennas_supported;
+ uint8_t max_antenna_paths_supported;
+ uint8_t roles_supported;
+ uint8_t optional_modes_supported;
+ uint8_t rtt_capability;
+ uint8_t rtt_aa_only_n;
+ uint8_t rtt_sounding_n;
+ uint8_t rtt_random_payload_n;
+ uint16_t optional_nadm_sounding_capability;
+ uint16_t optional_nadm_random_capability;
+ uint8_t optional_cs_sync_phys_supported;
+ uint16_t optional_subfeatures_supported;
+ uint16_t optional_t_ip1_times_supported;
+ uint16_t optional_t_ip2_times_supported;
+ uint16_t optional_t_fcs_times_supported;
+ uint16_t optional_t_pm_times_supported;
+ uint8_t t_sw_time_supported;
+} __attribute__((packed));
+struct ble_hci_le_cs_wr_cached_rem_supp_cap_rp {
+ uint8_t status;
+ uint16_t conn_handle;
+} __attribute__((packed));
+
+#define BLE_HCI_OCF_LE_CS_SEC_ENABLE (0x008C)
+struct ble_hci_le_cs_sec_enable_cp {
+ uint16_t conn_handle;
+} __attribute__((packed));
+
+#define BLE_HCI_OCF_LE_CS_SET_DEF_SETTINGS (0x008D)
+struct ble_hci_le_cs_set_def_settings_cp {
+ uint16_t conn_handle;
+ uint8_t role_enable;
+ uint8_t cs_sync_antenna_selection;
+ uint8_t max_tx_power;
+} __attribute__((packed));
+struct ble_hci_le_cs_set_def_settings_rp {
+ uint8_t status;
+ uint16_t conn_handle;
+} __attribute__((packed));
+
+#define BLE_HCI_OCF_LE_CS_RD_REM_FAE (0x008E)
+struct ble_hci_le_cs_rd_rem_fae_cp {
+ uint16_t conn_handle;
+} __attribute__((packed));
+
+#define BLE_HCI_OCF_LE_CS_WR_CACHED_REM_FAE (0x008F)
+struct ble_hci_le_cs_wr_cached_rem_fae_cp {
+ uint16_t conn_handle;
+ uint8_t remote_fae_table[72];
+} __attribute__((packed));
+struct ble_hci_le_cs_wr_cached_rem_fae_rp {
+ uint8_t status;
Review Comment:
status is omitted in rp structs
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]