bluetooth: host: HCI support for CS configuration

Adds following HCI support for CS configuration:
- LE CS Create Config command
- LE CS Remove Config command
- LE CS Config Complete event

Two callbacks have been added to notify the application
when a new CS configuration is created or an existing
CS configuration is removed.

Signed-off-by: Burak Gorduk <burak.gorduk@nordicsemi.no>
This commit is contained in:
Burak Gorduk 2024-09-24 10:53:43 +01:00 committed by Carles Cufí
commit 7b82214d29
10 changed files with 749 additions and 96 deletions

View file

@ -1068,6 +1068,64 @@ void print_remote_cs_fae_table(struct bt_conn *conn, struct bt_conn_le_cs_fae_ta
shell_print(ctx_shell, "Received FAE Table: ");
shell_hexdump(ctx_shell, params->remote_fae_table, 72);
}
static void le_cs_config_created(struct bt_conn *conn, struct bt_conn_le_cs_config *config)
{
const char *mode_str[5] = {"Unused", "1 (RTT)", "2 (PBR)", "3 (RTT + PBR)", "Invalid"};
const char *role_str[3] = {"Initiator", "Reflector", "Invalid"};
const char *rtt_type_str[8] = {"AA only", "32-bit sounding", "96-bit sounding",
"32-bit random", "64-bit random", "96-bit random",
"128-bit random", "Invalid"};
const char *phy_str[4] = {"Invalid", "LE 1M PHY", "LE 2M PHY", "LE 2M 2BT PHY"};
const char *chsel_type_str[3] = {"Algorithm #3b", "Algorithm #3c", "Invalid"};
const char *ch3c_shape_str[3] = {"Hat shape", "X shape", "Invalid"};
uint8_t main_mode_idx = config->main_mode_type > 0 && config->main_mode_type < 4
? config->main_mode_type
: 4;
uint8_t sub_mode_idx = config->sub_mode_type < 4 ? config->sub_mode_type : 0;
uint8_t role_idx = MIN(config->role, 2);
uint8_t rtt_type_idx = MIN(config->rtt_type, 7);
uint8_t phy_idx =
config->cs_sync_phy > 0 && config->cs_sync_phy < 4 ? config->cs_sync_phy : 0;
uint8_t chsel_type_idx = MIN(config->channel_selection_type, 2);
uint8_t ch3c_shape_idx = MIN(config->ch3c_shape, 2);
shell_print(ctx_shell,
"New CS config created:\n"
"- ID: %d\n"
"- Role: %s\n"
"- Main mode: %s\n"
"- Sub mode: %s\n"
"- RTT type: %s\n"
"- Main mode steps: %d - %d\n"
"- Main mode repetition: %d\n"
"- Mode 0 steps: %d\n"
"- CS sync PHY: %s\n"
"- T_IP1 time: %d\n"
"- T_IP2 time: %d\n"
"- T_FCS time: %d\n"
"- T_PM time: %d\n"
"- Channel map: 0x%08X%08X%04X\n"
"- Channel map repetition: %d\n"
"- Channel selection type: %s\n"
"- Ch3c shape: %s\n"
"- Ch3c jump: %d\n",
config->id, role_str[role_idx], mode_str[main_mode_idx], mode_str[sub_mode_idx],
rtt_type_str[rtt_type_idx], config->min_main_mode_steps,
config->max_main_mode_steps, config->main_mode_repetition, config->mode_0_steps,
phy_str[phy_idx], config->t_ip1_time_us, config->t_ip2_time_us,
config->t_fcs_time_us, config->t_pm_time_us,
sys_get_le32(&config->channel_map[6]), sys_get_le32(&config->channel_map[2]),
sys_get_le16(&config->channel_map[0]), config->channel_map_repetition,
chsel_type_str[chsel_type_idx], ch3c_shape_str[ch3c_shape_idx],
config->ch3c_jump);
}
static void le_cs_config_removed(struct bt_conn *conn, uint8_t config_id)
{
shell_print(ctx_shell, "CS config %d is removed", config_id);
}
#endif
static struct bt_conn_cb conn_callbacks = {
@ -1102,6 +1160,8 @@ static struct bt_conn_cb conn_callbacks = {
#if defined(CONFIG_BT_CHANNEL_SOUNDING)
.remote_cs_capabilities_available = print_remote_cs_capabilities,
.remote_cs_fae_table_available = print_remote_cs_fae_table,
.le_cs_config_created = le_cs_config_created,
.le_cs_config_removed = le_cs_config_removed,
#endif
};
#endif /* CONFIG_BT_CONN */