|
12 | 12 | #include <stdlib.h>
|
13 | 13 | #include <zephyr/kernel.h>
|
14 | 14 | #include <zephyr/types.h>
|
| 15 | +#include <zephyr/sys/byteorder.h> |
15 | 16 | #include <zephyr/sys/reboot.h>
|
16 | 17 | #include <zephyr/bluetooth/cs.h>
|
17 | 18 | #include <zephyr/bluetooth/gatt.h>
|
@@ -396,15 +397,67 @@ static void remote_capabilities_cb(struct bt_conn *conn,
|
396 | 397 | }
|
397 | 398 | }
|
398 | 399 |
|
399 |
| -static void config_create_cb(struct bt_conn *conn, |
400 |
| - uint8_t status, |
| 400 | +static void config_create_cb(struct bt_conn *conn, uint8_t status, |
401 | 401 | struct bt_conn_le_cs_config *config)
|
402 | 402 | {
|
403 | 403 | ARG_UNUSED(conn);
|
404 | 404 |
|
405 | 405 | if (status == BT_HCI_ERR_SUCCESS) {
|
406 | 406 | cs_config = *config;
|
407 |
| - LOG_INF("CS config creation complete. ID: %d", config->id); |
| 407 | + |
| 408 | + const char *mode_str[5] = {"Unused", "1 (RTT)", "2 (PBR)", "3 (RTT + PBR)", |
| 409 | + "Invalid"}; |
| 410 | + const char *role_str[3] = {"Initiator", "Reflector", "Invalid"}; |
| 411 | + const char *rtt_type_str[8] = { |
| 412 | + "AA only", "32-bit sounding", "96-bit sounding", "32-bit random", |
| 413 | + "64-bit random", "96-bit random", "128-bit random", "Invalid"}; |
| 414 | + const char *phy_str[4] = {"Invalid", "LE 1M PHY", "LE 2M PHY", "LE 2M 2BT PHY"}; |
| 415 | + const char *chsel_type_str[3] = {"Algorithm #3b", "Algorithm #3c", "Invalid"}; |
| 416 | + const char *ch3c_shape_str[3] = {"Hat shape", "X shape", "Invalid"}; |
| 417 | + |
| 418 | + uint8_t main_mode_idx = config->main_mode_type > 0 && config->main_mode_type < 4 |
| 419 | + ? config->main_mode_type |
| 420 | + : 4; |
| 421 | + uint8_t sub_mode_idx = config->sub_mode_type < 4 ? config->sub_mode_type : 0; |
| 422 | + uint8_t role_idx = MIN(config->role, 2); |
| 423 | + uint8_t rtt_type_idx = MIN(config->rtt_type, 7); |
| 424 | + uint8_t phy_idx = config->cs_sync_phy > 0 && config->cs_sync_phy < 4 |
| 425 | + ? config->cs_sync_phy |
| 426 | + : 0; |
| 427 | + uint8_t chsel_type_idx = MIN(config->channel_selection_type, 2); |
| 428 | + uint8_t ch3c_shape_idx = MIN(config->ch3c_shape, 2); |
| 429 | + |
| 430 | + LOG_INF("CS config creation complete.\n" |
| 431 | + " - id: %u\n" |
| 432 | + " - main_mode_type: %s\n" |
| 433 | + " - sub_mode_type: %s\n" |
| 434 | + " - min_main_mode_steps: %u\n" |
| 435 | + " - max_main_mode_steps: %u\n" |
| 436 | + " - main_mode_repetition: %u\n" |
| 437 | + " - mode_0_steps: %u\n" |
| 438 | + " - role: %s\n" |
| 439 | + " - rtt_type: %s\n" |
| 440 | + " - cs_sync_phy: %s\n" |
| 441 | + " - channel_map_repetition: %u\n" |
| 442 | + " - channel_selection_type: %s\n" |
| 443 | + " - ch3c_shape: %s\n" |
| 444 | + " - ch3c_jump: %u\n" |
| 445 | + " - t_ip1_time_us: %u\n" |
| 446 | + " - t_ip2_time_us: %u\n" |
| 447 | + " - t_fcs_time_us: %u\n" |
| 448 | + " - t_pm_time_us: %u\n" |
| 449 | + " - channel_map: 0x%08X%08X%04X\n", |
| 450 | + config->id, mode_str[main_mode_idx], mode_str[sub_mode_idx], |
| 451 | + config->min_main_mode_steps, config->max_main_mode_steps, |
| 452 | + config->main_mode_repetition, config->mode_0_steps, role_str[role_idx], |
| 453 | + rtt_type_str[rtt_type_idx], phy_str[phy_idx], |
| 454 | + config->channel_map_repetition, chsel_type_str[chsel_type_idx], |
| 455 | + ch3c_shape_str[ch3c_shape_idx], config->ch3c_jump, config->t_ip1_time_us, |
| 456 | + config->t_ip2_time_us, config->t_fcs_time_us, config->t_pm_time_us, |
| 457 | + sys_get_le32(&config->channel_map[6]), |
| 458 | + sys_get_le32(&config->channel_map[2]), |
| 459 | + sys_get_le16(&config->channel_map[0])); |
| 460 | + |
408 | 461 | k_sem_give(&sem_config_created);
|
409 | 462 | } else {
|
410 | 463 | LOG_WRN("CS config creation failed. (HCI status 0x%02x)", status);
|
@@ -731,8 +784,8 @@ int main(void)
|
731 | 784 | ap, (double)distance_on_ap.ifft,
|
732 | 785 | (double)distance_on_ap.phase_slope,
|
733 | 786 | (double)distance_on_ap.rtt);
|
734 |
| - } |
735 | 787 | }
|
| 788 | + } |
736 | 789 | }
|
737 | 790 |
|
738 | 791 | return 0;
|
|
0 commit comments