diff --git a/components/bt/esp_ble_mesh/core/bluedroid_host/adapter.c b/components/bt/esp_ble_mesh/core/bluedroid_host/adapter.c index e31d4186e7..a322c0ab86 100644 --- a/components/bt/esp_ble_mesh/core/bluedroid_host/adapter.c +++ b/components/bt/esp_ble_mesh/core/bluedroid_host/adapter.c @@ -1874,6 +1874,7 @@ int bt_mesh_gattc_conn_create(const bt_mesh_addr_t *addr, uint16_t service_uuid) BTA_GATTC_Enh_Open(bt_mesh_gattc_if, bt_mesh_gattc_info[i].addr.val, bt_mesh_gattc_info[i].addr.type, true, BTA_GATT_TRANSPORT_LE, TRUE, BLE_ADDR_UNKNOWN_TYPE, + false, 0xFF, 0xFF, BTA_BLE_PHY_1M_MASK, &conn_1m_param, NULL, NULL); #else /* CONFIG_BLE_MESH_USE_BLE_50 */ /* Min_interval: 15ms @@ -1889,6 +1890,7 @@ int bt_mesh_gattc_conn_create(const bt_mesh_addr_t *addr, uint16_t service_uuid) BTA_GATTC_Enh_Open(bt_mesh_gattc_if, bt_mesh_gattc_info[i].addr.val, bt_mesh_gattc_info[i].addr.type, true, BTA_GATT_TRANSPORT_LE, FALSE, BLE_ADDR_UNKNOWN_TYPE, + false, 0xFF, 0xFF, BTA_BLE_PHY_1M_MASK, &conn_1m_param, NULL, NULL); #endif /* CONFIG_BLE_MESH_USE_BLE_50 */ diff --git a/components/bt/host/bluedroid/Kconfig.in b/components/bt/host/bluedroid/Kconfig.in index edf146769c..929e539919 100644 --- a/components/bt/host/bluedroid/Kconfig.in +++ b/components/bt/host/bluedroid/Kconfig.in @@ -377,6 +377,13 @@ config BT_GATTS_APPEARANCE_WRITABLE help Enabling this option allows remote GATT clients to write appearance +config BT_GATTS_SECURITY_LEVELS_CHAR + bool "Enable LE GATT Security Levels Characteristic" + depends on BT_GATTS_ENABLE + default n + help + Enable LE GATT Security Levels Characteristic + menuconfig BT_GATTC_ENABLE bool "Include GATT client module(GATTC)" depends on BT_BLE_ENABLED @@ -1302,7 +1309,7 @@ config BT_BLE_RPA_TIMEOUT Default is 900 s (15 minutes). Range is 1 s to 1 hour (3600 s). menuconfig BT_BLE_50_FEATURES_SUPPORTED - bool "Enable BLE 5.0 features(please disable BLE 4.2 if enable BLE 5.0)" + bool "Enable BLE 5.0 and above features(please disable BLE 4.2 if enable BLE 5.0)" depends on (BT_BLE_ENABLED && ((BT_CONTROLLER_ENABLED && SOC_BLE_50_SUPPORTED) || BT_CONTROLLER_DISABLED)) default y help @@ -1366,37 +1373,6 @@ config BT_BLE_FEAT_CREATE_SYNC_ENH help Enable the create sync enhancements -menuconfig BT_BLE_42_FEATURES_SUPPORTED - bool "Enable BLE 4.2 features(please disable BLE 5.0 if enable BLE 4.2)" - depends on BT_BLE_ENABLED - default y if IDF_TARGET_ESP32 - default n - help - This enables BLE 4.2 features. - This option is universally supported by all ESP chips with BLE capabilities. - BLE 4.2 and BLE 5.0 cannot be used simultaneously. - -config BT_BLE_42_DTM_TEST_EN - bool "Enable BLE 4.2 DTM test" - depends on BT_BLE_42_FEATURES_SUPPORTED - default y - help - This enables BLE 4.2 direct test mode - -config BT_BLE_42_ADV_EN - bool "Enable BLE 4.2 advertising" - depends on BT_BLE_42_FEATURES_SUPPORTED - default y - help - This enables BLE v4.2 advertising - -config BT_BLE_42_SCAN_EN - bool "Enable BLE 4.2 scan" - depends on BT_BLE_42_FEATURES_SUPPORTED - default y - help - This enables BLE v4.2 scan - menuconfig BT_BLE_FEAT_ISO_EN bool "Enable BLE 5.2 iso feature" depends on (BT_BLE_50_FEATURES_SUPPORTED && ((BT_CONTROLLER_ENABLED && SOC_BLE_AUDIO_SUPPORTED) || BT_CONTROLLER_DISABLED)) # NOERROR @@ -1509,6 +1485,58 @@ config BT_BLE_FEAT_CONN_SUBRATING help Enable BLE connection subrating feature +config BT_BLE_FEAT_PAWR_EN + bool "Enable Periodic Advertisement with Response(PAwR)" + depends on (BT_BLE_50_FEATURES_SUPPORTED && ((BT_CONTROLLER_ENABLED && SOC_BLE_PAWR_SUPPORTED) || BT_CONTROLLER_DISABLED)) # NOERROR + default n + help + Enable BLE Periodic Advertisement with Response(PAwR) feature + +config BT_BLE_FEAT_ADV_CODING_SELECTION + bool "Enable Advertising Coding Selection" + depends on (BT_BLE_50_FEATURES_SUPPORTED && ((BT_CONTROLLER_ENABLED && SOC_BLE_ADV_CODING_SELECT_SUPPORTED) || BT_CONTROLLER_DISABLED)) # NOERROR + default n + help + Enable Advertising Coding Selection + +config BT_BLE_FEAT_CHANNEL_SOUNDING + bool "Enable BLE channel sounding" + depends on (BT_BLE_50_FEATURES_SUPPORTED && ((BT_CONTROLLER_ENABLED && SOC_BLE_CHANNEL_SOUNDING_SUPPORTED) || BT_CONTROLLER_DISABLED)) # NOERROR + default n + help + Enable BLE channel sounding + +menuconfig BT_BLE_42_FEATURES_SUPPORTED + bool "Enable BLE 4.2 features(please disable BLE 5.0 if enable BLE 4.2)" + depends on BT_BLE_ENABLED + default y if IDF_TARGET_ESP32 + default n + help + This enables BLE 4.2 features. + This option is universally supported by all ESP chips with BLE capabilities. + BLE 4.2 and BLE 5.0 cannot be used simultaneously. + +config BT_BLE_42_DTM_TEST_EN + bool "Enable BLE 4.2 DTM test" + depends on BT_BLE_42_FEATURES_SUPPORTED + default y + help + This enables BLE 4.2 direct test mode + +config BT_BLE_42_ADV_EN + bool "Enable BLE 4.2 advertising" + depends on BT_BLE_42_FEATURES_SUPPORTED + default y + help + This enables BLE v4.2 advertising + +config BT_BLE_42_SCAN_EN + bool "Enable BLE 4.2 scan" + depends on BT_BLE_42_FEATURES_SUPPORTED + default y + help + This enables BLE v4.2 scan + config BT_BLE_VENDOR_HCI_EN bool "Enable BLE Vendor HCI command and event" depends on BT_BLE_ENABLED diff --git a/components/bt/host/bluedroid/api/esp_gap_ble_api.c b/components/bt/host/bluedroid/api/esp_gap_ble_api.c index d592b6b77f..906e1280ba 100644 --- a/components/bt/host/bluedroid/api/esp_gap_ble_api.c +++ b/components/bt/host/bluedroid/api/esp_gap_ble_api.c @@ -2082,3 +2082,437 @@ esp_err_t esp_ble_gap_set_host_feature(uint16_t bit_num, uint8_t bit_val) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL); } #endif //#if (BLE_50_FEATURE_SUPPORT == TRUE) + +#if (BT_BLE_FEAT_PAWR_EN == TRUE) +esp_err_t esp_ble_gap_set_periodic_adv_subevent_data(esp_ble_per_adv_subevent_data_params *subevent_data_params) +{ + btc_msg_t msg = {0}; + btc_ble_5_gap_args_t arg; + + if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) { + return ESP_ERR_INVALID_STATE; + } + + if ((!subevent_data_params) || (!subevent_data_params->subevent_params)) { + return ESP_ERR_NOT_ALLOWED; + } + + if ((subevent_data_params->num_subevents_with_data > 0x0F) || (!subevent_data_params->num_subevents_with_data)) { + return ESP_ERR_NOT_ALLOWED; + } + + for (uint8_t i = 0; i < subevent_data_params->num_subevents_with_data; i++) + { + if (subevent_data_params->subevent_params[i].subevent_data_len && (subevent_data_params->subevent_params[i].subevent_data == NULL)) { + return ESP_ERR_NOT_ALLOWED; + } + } + + + msg.sig = BTC_SIG_API_CALL; + msg.pid = BTC_PID_GAP_BLE; + msg.act = BTC_GAP_BLE_SET_PA_SUBEVT_DATA; + + arg.per_adv_subevent_data_params.adv_handle = subevent_data_params->adv_handle; + arg.per_adv_subevent_data_params.num_subevents_with_data = subevent_data_params->num_subevents_with_data; + arg.per_adv_subevent_data_params.subevent_params = subevent_data_params->subevent_params; + + return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), btc_gap_ble_arg_deep_copy, btc_gap_ble_arg_deep_free) + == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL); +} + +esp_err_t esp_ble_gap_set_periodic_adv_response_data(esp_ble_per_adv_response_data_params *rsp_data_params) +{ + btc_msg_t msg = {0}; + btc_ble_5_gap_args_t arg; + + if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) { + return ESP_ERR_INVALID_STATE; + } + + if (!rsp_data_params) { + return ESP_ERR_NOT_ALLOWED; + } + + if ((rsp_data_params->response_data == NULL) && rsp_data_params->response_data_len) { + return ESP_ERR_NOT_ALLOWED; + } + + msg.sig = BTC_SIG_API_CALL; + msg.pid = BTC_PID_GAP_BLE; + msg.act = BTC_GAP_BLE_SET_PA_RSP_DATA; + + arg.per_adv_response_data_params.sync_handle = rsp_data_params->sync_handle; + arg.per_adv_response_data_params.request_event = rsp_data_params->request_event; + arg.per_adv_response_data_params.request_subevent = rsp_data_params->request_subevent; + arg.per_adv_response_data_params.response_subevent = rsp_data_params->response_subevent; + arg.per_adv_response_data_params.response_slot = rsp_data_params->response_slot; + arg.per_adv_response_data_params.response_data_len = rsp_data_params->response_data_len; + arg.per_adv_response_data_params.response_data = rsp_data_params->response_data; + + return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), btc_gap_ble_arg_deep_copy, btc_gap_ble_arg_deep_free) + == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL); +} + +esp_err_t esp_ble_gap_set_periodic_sync_subevent(esp_ble_per_sync_subevent_params *sync_subevent_params) +{ + btc_msg_t msg = {0}; + btc_ble_5_gap_args_t arg; + + if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) { + return ESP_ERR_INVALID_STATE; + } + + if (!sync_subevent_params) { + return ESP_ERR_NOT_ALLOWED; + } + + if ((sync_subevent_params->subevent == NULL) && sync_subevent_params->num_subevents_to_sync) { + return ESP_ERR_NOT_ALLOWED; + } + + msg.sig = BTC_SIG_API_CALL; + msg.pid = BTC_PID_GAP_BLE; + msg.act = BTC_GAP_BLE_SET_PA_SYNC_SUBEVT; + + arg.per_sync_subevent_params.sync_handle = sync_subevent_params->sync_handle; + arg.per_sync_subevent_params.periodic_adv_properties = sync_subevent_params->periodic_adv_properties; + arg.per_sync_subevent_params.num_subevents_to_sync = sync_subevent_params->num_subevents_to_sync; + arg.per_sync_subevent_params.subevent = sync_subevent_params->subevent; + + return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), btc_gap_ble_arg_deep_copy, btc_gap_ble_arg_deep_free) + == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL); +} +#endif // #if (BT_BLE_FEAT_PAWR_EN == TRUE) + +#if (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE) +esp_err_t esp_ble_cs_read_local_supported_capabilities(void) +{ + btc_msg_t msg = {0}; + + if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) { + return ESP_ERR_INVALID_STATE; + } + + msg.sig = BTC_SIG_API_CALL; + msg.pid = BTC_PID_GAP_BLE; + msg.act = BTC_GAP_BLE_CS_READ_LOCAL_SUPPORTED_CAPS; + + return (btc_transfer_context(&msg, NULL, 0, NULL, NULL) + == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL); +} + +esp_err_t esp_ble_cs_read_remote_supported_capabilities(uint16_t conn_handle) +{ + btc_msg_t msg = {0}; + btc_ble_5_gap_args_t arg; + + if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) { + return ESP_ERR_INVALID_STATE; + } + + msg.sig = BTC_SIG_API_CALL; + msg.pid = BTC_PID_GAP_BLE; + msg.act = BTC_GAP_BLE_CS_READ_REMOTE_SUPPORTED_CAPS; + + arg.cs_read_remote_supp_caps.conn_handle = conn_handle; + + return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_5_gap_args_t), NULL, NULL) + == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL); +} + +esp_err_t esp_ble_cs_write_cached_remote_supported_capabilities(esp_ble_cs_write_cached_remote_supp_caps_params *cached_remote_supp_caps_params) +{ + btc_msg_t msg = {0}; + btc_ble_5_gap_args_t arg = {0}; + + if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) { + return ESP_ERR_INVALID_STATE; + } + + if (!cached_remote_supp_caps_params) { + return ESP_ERR_NOT_ALLOWED; + } + + msg.sig = BTC_SIG_API_CALL; + msg.pid = BTC_PID_GAP_BLE; + msg.act = BTC_GAP_BLE_CS_WRITE_CACHED_REMOTE_SUPPORTED_CAPS; + + arg.cs_write_cached_remote_supp_caps.conn_handle = cached_remote_supp_caps_params->conn_handle; + arg.cs_write_cached_remote_supp_caps.num_config_supported = cached_remote_supp_caps_params->num_config_supported; + arg.cs_write_cached_remote_supp_caps.max_consecutive_proc_supported = cached_remote_supp_caps_params->max_consecutive_proc_supported; + arg.cs_write_cached_remote_supp_caps.num_ant_supported = cached_remote_supp_caps_params->num_ant_supported; + arg.cs_write_cached_remote_supp_caps.max_ant_paths_supported = cached_remote_supp_caps_params->max_ant_paths_supported; + arg.cs_write_cached_remote_supp_caps.modes_supported = cached_remote_supp_caps_params->modes_supported; + arg.cs_write_cached_remote_supp_caps.rtt_capability = cached_remote_supp_caps_params->rtt_capability; + arg.cs_write_cached_remote_supp_caps.rtt_aa_only_n = cached_remote_supp_caps_params->rtt_aa_only_n; + arg.cs_write_cached_remote_supp_caps.rtt_sounding_n = cached_remote_supp_caps_params->rtt_sounding_n; + arg.cs_write_cached_remote_supp_caps.rtt_random_payload_n = cached_remote_supp_caps_params->rtt_random_payload_n; + arg.cs_write_cached_remote_supp_caps.NADM_sounding_capability = cached_remote_supp_caps_params->NADM_sounding_capability; + arg.cs_write_cached_remote_supp_caps.NADM_random_capability = cached_remote_supp_caps_params->NADM_random_capability; + arg.cs_write_cached_remote_supp_caps.subfeatures_supported = cached_remote_supp_caps_params->subfeatures_supported; + arg.cs_write_cached_remote_supp_caps.T_IP1_times_supported = cached_remote_supp_caps_params->T_IP1_times_supported; + arg.cs_write_cached_remote_supp_caps.T_IP2_times_supported = cached_remote_supp_caps_params->T_IP2_times_supported; + arg.cs_write_cached_remote_supp_caps.T_FCS_times_supported = cached_remote_supp_caps_params->T_FCS_times_supported; + arg.cs_write_cached_remote_supp_caps.T_PM_times_supported = cached_remote_supp_caps_params->T_PM_times_supported; + arg.cs_write_cached_remote_supp_caps.T_SW_times_supported = cached_remote_supp_caps_params->T_SW_times_supported; + arg.cs_write_cached_remote_supp_caps.TX_SNR_capability = cached_remote_supp_caps_params->TX_SNR_capability; + if (cached_remote_supp_caps_params->initiator_role_supported) { + arg.cs_write_cached_remote_supp_caps.roles_supported |= ESP_BLE_CS_INITIATOR_ROLE_SUPPORTED; + } + if (cached_remote_supp_caps_params->reflector_role_supported) { + arg.cs_write_cached_remote_supp_caps.roles_supported |= ESP_BLE_CS_REFLECTOR_ROLE_SUPPORTED; + } + if (cached_remote_supp_caps_params->cs_sync_2m_phy_supported) { + arg.cs_write_cached_remote_supp_caps.cs_sync_phys_supported |= ESP_BLE_CS_SYNC_PHYS_2M_SUPPORTED; + } + if (cached_remote_supp_caps_params->cs_sync_2m_2bt_phy_supported) { + arg.cs_write_cached_remote_supp_caps.cs_sync_phys_supported |= ESP_BLE_CS_SYNC_PHYS_2M_2BT_SUPPORTED; + } + + return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_5_gap_args_t), NULL, NULL) + == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL); +} + +esp_err_t esp_ble_cs_security_enable(uint16_t conn_handle) +{ + btc_msg_t msg = {0}; + btc_ble_5_gap_args_t arg; + + if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) { + return ESP_ERR_INVALID_STATE; + } + + msg.sig = BTC_SIG_API_CALL; + msg.pid = BTC_PID_GAP_BLE; + msg.act = BTC_GAP_BLE_CS_SECURITY_ENABLE; + + arg.cs_security_enable.conn_handle = conn_handle; + + return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_5_gap_args_t), NULL, NULL) + == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL); +} + +esp_err_t esp_ble_cs_set_default_settings(esp_ble_cs_set_default_settings_params *default_setting_params) +{ + btc_msg_t msg = {0}; + btc_ble_5_gap_args_t arg = {0}; + + if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) { + return ESP_ERR_INVALID_STATE; + } + + if (!default_setting_params) { + return ESP_ERR_NOT_ALLOWED; + } + + msg.sig = BTC_SIG_API_CALL; + msg.pid = BTC_PID_GAP_BLE; + msg.act = BTC_GAP_BLE_CS_SET_DEFAULT_SETTINGS; + + arg.cs_set_default_settings_params.conn_handle = default_setting_params->conn_handle; + arg.cs_set_default_settings_params.cs_sync_ant_selection = default_setting_params->cs_sync_ant_selection; + arg.cs_set_default_settings_params.max_tx_power = default_setting_params->max_tx_power; + if (default_setting_params->initiator_role_enable) { + arg.cs_set_default_settings_params.role_enable |= ESP_BLE_CS_INITIATOR_ROLE_ENABLED; + } + if (default_setting_params->reflector_role_enable) { + arg.cs_set_default_settings_params.role_enable |= ESP_BLE_CS_REFLECTOR_ROLE_ENABLED; + } + + return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_5_gap_args_t), NULL, NULL) + == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL); +} + +esp_err_t esp_ble_cs_read_remote_fae_table(uint16_t conn_handle) +{ + btc_msg_t msg = {0}; + btc_ble_5_gap_args_t arg; + + if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) { + return ESP_ERR_INVALID_STATE; + } + + msg.sig = BTC_SIG_API_CALL; + msg.pid = BTC_PID_GAP_BLE; + msg.act = BTC_GAP_BLE_CS_READ_REMOTE_FAE_TABLE; + + arg.cs_read_remote_tab.conn_handle = conn_handle; + + return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_5_gap_args_t), NULL, NULL) + == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL); +} + +esp_err_t esp_ble_cs_write_cached_remote_fae_table(esp_ble_cs_write_cached_remote_fae_table_params *write_cached_remote_fae_tab_params) +{ + btc_msg_t msg = {0}; + btc_ble_5_gap_args_t arg = {0}; + + if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) { + return ESP_ERR_INVALID_STATE; + } + + if (!write_cached_remote_fae_tab_params) { + return ESP_ERR_NOT_ALLOWED; + } + + msg.sig = BTC_SIG_API_CALL; + msg.pid = BTC_PID_GAP_BLE; + msg.act = BTC_GAP_BLE_CS_WRITE_CACHED_REMOTE_FAE_TABLE; + + arg.cs_write_cached_remote_fae_table_params.conn_handle = write_cached_remote_fae_tab_params->conn_handle; + memcpy(arg.cs_write_cached_remote_fae_table_params.remote_fae_table, write_cached_remote_fae_tab_params->remote_fae_table, sizeof(arg.cs_write_cached_remote_fae_table_params.remote_fae_table)); + + return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_5_gap_args_t), NULL, NULL) + == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL); +} + +esp_err_t esp_ble_cs_create_config(esp_ble_cs_create_config_params *create_config_params) +{ + btc_msg_t msg = {0}; + btc_ble_5_gap_args_t arg = {0}; + + if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) { + return ESP_ERR_INVALID_STATE; + } + + if (!create_config_params) { + return ESP_ERR_NOT_ALLOWED; + } + + arg.cs_create_config_params.conn_handle = create_config_params->conn_handle; + arg.cs_create_config_params.config_id = create_config_params->config_id; + arg.cs_create_config_params.create_context = create_config_params->create_context; + arg.cs_create_config_params.main_mode_type = create_config_params->main_mode_type; + arg.cs_create_config_params.sub_mode_type = create_config_params->sub_mode_type; + arg.cs_create_config_params.min_main_mode_steps = create_config_params->min_main_mode_steps; + arg.cs_create_config_params.max_main_mode_steps = create_config_params->max_main_mode_steps; + arg.cs_create_config_params.main_mode_repetition = create_config_params->main_mode_repetition; + arg.cs_create_config_params.mode_0_steps = create_config_params->mode_0_steps; + arg.cs_create_config_params.role = create_config_params->role; + arg.cs_create_config_params.rtt_type = create_config_params->rtt_type; + arg.cs_create_config_params.cs_sync_phy = create_config_params->cs_sync_phy; + memcpy(arg.cs_create_config_params.channel_map, create_config_params->channel_map, sizeof(arg.cs_create_config_params.channel_map)); + arg.cs_create_config_params.channel_map_repetition = create_config_params->channel_map_repetition; + arg.cs_create_config_params.channel_selection_type = create_config_params->channel_selection_type; + arg.cs_create_config_params.ch3c_shape = create_config_params->ch3c_shape; + arg.cs_create_config_params.ch3c_jump = create_config_params->ch3c_jump; + arg.cs_create_config_params.reserved = create_config_params->reserved; + + msg.sig = BTC_SIG_API_CALL; + msg.pid = BTC_PID_GAP_BLE; + msg.act = BTC_GAP_BLE_CS_CREATE_CONFIG; + + return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_5_gap_args_t), NULL, NULL) + == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL); +} + +esp_err_t esp_ble_cs_remove_config(esp_ble_cs_remove_config_params *remove_config_params) +{ + btc_msg_t msg = {0}; + btc_ble_5_gap_args_t arg; + + if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) { + return ESP_ERR_INVALID_STATE; + } + + if (!remove_config_params) { + return ESP_ERR_NOT_ALLOWED; + } + + msg.sig = BTC_SIG_API_CALL; + msg.pid = BTC_PID_GAP_BLE; + msg.act = BTC_GAP_BLE_CS_REMOVE_CONFIG; + + arg.cs_remove_config_params.conn_handle = remove_config_params->conn_handle; + arg.cs_remove_config_params.config_id = remove_config_params->config_id; + + return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_5_gap_args_t), NULL, NULL) + == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL); +} + +esp_err_t esp_ble_cs_set_channel_classification(esp_ble_cs_set_channel_class_params *channel_class_params) +{ + btc_msg_t msg = {0}; + btc_ble_5_gap_args_t arg; + + if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) { + return ESP_ERR_INVALID_STATE; + } + + if (!channel_class_params) { + return ESP_ERR_NOT_ALLOWED; + } + + msg.sig = BTC_SIG_API_CALL; + msg.pid = BTC_PID_GAP_BLE; + msg.act = BTC_GAP_BLE_CS_SET_CAHNNEL_CLASSIFICATION; + + memcpy(arg.cs_set_channel_class_params.channel_class, channel_class_params->channel_class, sizeof(arg.cs_set_channel_class_params)); + + return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_5_gap_args_t), NULL, NULL) + == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL); +} + +esp_err_t esp_ble_cs_set_procedure_params(esp_ble_cs_set_proc_params *procedure_params) +{ + btc_msg_t msg = {0}; + btc_ble_5_gap_args_t arg; + + if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) { + return ESP_ERR_INVALID_STATE; + } + + if (!procedure_params) { + return ESP_ERR_NOT_ALLOWED; + } + + msg.sig = BTC_SIG_API_CALL; + msg.pid = BTC_PID_GAP_BLE; + msg.act = BTC_GAP_BLE_CS_SET_PROCEDURE_PARAMS; + + arg.cs_set_procedure_params.conn_handle = procedure_params->conn_handle; + arg.cs_set_procedure_params.config_id = procedure_params->config_id; + arg.cs_set_procedure_params.max_procedure_len = procedure_params->max_procedure_len; + arg.cs_set_procedure_params.min_procedure_interval = procedure_params->min_procedure_interval; + arg.cs_set_procedure_params.max_procedure_interval = procedure_params->max_procedure_interval; + arg.cs_set_procedure_params.max_procedure_count = procedure_params->max_procedure_count; + arg.cs_set_procedure_params.min_subevent_len = (procedure_params->min_subevent_len & 0x00FFFFFF); + arg.cs_set_procedure_params.max_subevent_len = (procedure_params->max_subevent_len & 0x00FFFFFF); + arg.cs_set_procedure_params.tone_ant_config_selection = procedure_params->tone_ant_config_selection; + arg.cs_set_procedure_params.phy = procedure_params->phy; + arg.cs_set_procedure_params.tx_power_delta = procedure_params->tx_power_delta; + arg.cs_set_procedure_params.preferred_peer_antenna = procedure_params->preferred_peer_antenna; + arg.cs_set_procedure_params.SNR_control_initiator = procedure_params->SNR_control_initiator; + arg.cs_set_procedure_params.SNR_control_reflector = procedure_params->SNR_control_reflector; + + return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_5_gap_args_t), NULL, NULL) + == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL); +} + +esp_err_t esp_ble_cs_procedure_enable(esp_ble_cs_procedure_enable_params *procedure_enable_params) +{ + btc_msg_t msg = {0}; + btc_ble_5_gap_args_t arg; + + if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) { + return ESP_ERR_INVALID_STATE; + } + + if (!procedure_enable_params) { + return ESP_ERR_NOT_ALLOWED; + } + + msg.sig = BTC_SIG_API_CALL; + msg.pid = BTC_PID_GAP_BLE; + msg.act = BTC_GAP_BLE_CS_PROCEDURE_ENABLE; + + arg.cs_procedure_enable_params.conn_handle = procedure_enable_params->conn_handle; + arg.cs_procedure_enable_params.config_id = procedure_enable_params->config_id; + arg.cs_procedure_enable_params.enable = procedure_enable_params->enable; + + return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_5_gap_args_t), NULL, NULL) + == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL); +} + +#endif diff --git a/components/bt/host/bluedroid/api/esp_gattc_api.c b/components/bt/host/bluedroid/api/esp_gattc_api.c index 00c6a96e0b..f54deb8ea2 100644 --- a/components/bt/host/bluedroid/api/esp_gattc_api.c +++ b/components/bt/host/bluedroid/api/esp_gattc_api.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -88,6 +88,11 @@ esp_err_t esp_ble_gattc_enh_open(esp_gatt_if_t gattc_if, esp_ble_gatt_creat_conn arg.open.remote_addr_type = creat_conn_params->remote_addr_type; arg.open.is_direct = creat_conn_params->is_direct; arg.open.is_aux= creat_conn_params->is_aux; +#if (BT_BLE_FEAT_PAWR_EN == TRUE) + arg.open.is_pawr_synced = false; + arg.open.adv_handle = 0xFF; + arg.open.subevent = 0xFF; +#endif // (BT_BLE_FEAT_PAWR_EN == TRUE) arg.open.own_addr_type = creat_conn_params->own_addr_type; arg.open.phy_mask = creat_conn_params->phy_mask; @@ -206,6 +211,106 @@ esp_err_t esp_ble_gattc_aux_open(esp_gatt_if_t gattc_if, esp_bd_addr_t remote_bd } #endif // #if (BLE_50_FEATURE_SUPPORT == TRUE) +#if (BT_BLE_FEAT_PAWR_EN == TRUE) +esp_err_t esp_ble_gattc_aux_open_with_pawr_synced(esp_gatt_if_t gattc_if, esp_ble_gatt_pawr_conn_params_t *pawr_conn_params) +{ + btc_msg_t msg = {0}; + btc_ble_gattc_args_t arg; + const esp_ble_conn_params_t *conn_params; + + ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED); + + if (!pawr_conn_params) { + return ESP_ERR_INVALID_ARG; + } + + msg.sig = BTC_SIG_API_CALL; + msg.pid = BTC_PID_GATTC; + msg.act = BTC_GATTC_ACT_OPEN; + arg.open.gattc_if = gattc_if; + memcpy(arg.open.remote_bda, pawr_conn_params->remote_bda, ESP_BD_ADDR_LEN); + arg.open.remote_addr_type = pawr_conn_params->remote_addr_type; + arg.open.is_direct = true; + arg.open.is_aux = true; + arg.open.is_pawr_synced = true; + arg.open.adv_handle = pawr_conn_params->adv_handle; + arg.open.subevent = pawr_conn_params->subevent; + arg.open.own_addr_type = pawr_conn_params->own_addr_type; + arg.open.phy_mask = pawr_conn_params->phy_mask; + + if (pawr_conn_params->phy_mask & ESP_BLE_PHY_1M_PREF_MASK) { + if (!pawr_conn_params->phy_1m_conn_params) { + return ESP_ERR_INVALID_ARG; + } + + conn_params = pawr_conn_params->phy_1m_conn_params; + if (ESP_BLE_IS_VALID_PARAM(conn_params->interval_min, ESP_BLE_CONN_INT_MIN, ESP_BLE_CONN_INT_MAX) && + ESP_BLE_IS_VALID_PARAM(conn_params->interval_max, ESP_BLE_CONN_INT_MIN, ESP_BLE_CONN_INT_MAX) && + ESP_BLE_IS_VALID_PARAM(conn_params->supervision_timeout, ESP_BLE_CONN_SUP_TOUT_MIN, ESP_BLE_CONN_SUP_TOUT_MAX) && + (conn_params->latency <= ESP_BLE_CONN_LATENCY_MAX) && + ((conn_params->supervision_timeout * 10) >= ((1 + conn_params->latency) * ((conn_params->interval_max * 5) >> 1))) && + (conn_params->interval_min <= conn_params->interval_max)) { + memcpy(&arg.open.phy_1m_conn_params, conn_params, sizeof(esp_ble_conn_params_t)); + } else { + LOG_ERROR("%s, invalid 1M PHY connection params: min_int = %d, max_int = %d, latency = %d, timeout = %d", __func__, + conn_params->interval_min, + conn_params->interval_max, + conn_params->latency, + conn_params->supervision_timeout); + return ESP_ERR_INVALID_ARG; + } + } + + if (pawr_conn_params->phy_mask & ESP_BLE_PHY_2M_PREF_MASK) { + if (!pawr_conn_params->phy_2m_conn_params) { + return ESP_ERR_INVALID_ARG; + } + + conn_params = pawr_conn_params->phy_2m_conn_params; + if (ESP_BLE_IS_VALID_PARAM(conn_params->interval_min, ESP_BLE_CONN_INT_MIN, ESP_BLE_CONN_INT_MAX) && + ESP_BLE_IS_VALID_PARAM(conn_params->interval_max, ESP_BLE_CONN_INT_MIN, ESP_BLE_CONN_INT_MAX) && + ESP_BLE_IS_VALID_PARAM(conn_params->supervision_timeout, ESP_BLE_CONN_SUP_TOUT_MIN, ESP_BLE_CONN_SUP_TOUT_MAX) && + (conn_params->latency <= ESP_BLE_CONN_LATENCY_MAX) && + ((conn_params->supervision_timeout * 10) >= ((1 + conn_params->latency) * ((conn_params->interval_max * 5) >> 1))) && + (conn_params->interval_min <= conn_params->interval_max)) { + memcpy(&arg.open.phy_2m_conn_params, conn_params, sizeof(esp_ble_conn_params_t)); + } else { + LOG_ERROR("%s, invalid 2M PHY connection params: min_int = %d, max_int = %d, latency = %d, timeout = %d", __func__, + conn_params->interval_min, + conn_params->interval_max, + conn_params->latency, + conn_params->supervision_timeout); + return ESP_ERR_INVALID_ARG; + } + } + + if (pawr_conn_params->phy_mask & ESP_BLE_PHY_CODED_PREF_MASK) { + if (!pawr_conn_params->phy_coded_conn_params) { + return ESP_ERR_INVALID_ARG; + } + + conn_params = pawr_conn_params->phy_coded_conn_params; + if (ESP_BLE_IS_VALID_PARAM(conn_params->interval_min, ESP_BLE_CONN_INT_MIN, ESP_BLE_CONN_INT_MAX) && + ESP_BLE_IS_VALID_PARAM(conn_params->interval_max, ESP_BLE_CONN_INT_MIN, ESP_BLE_CONN_INT_MAX) && + ESP_BLE_IS_VALID_PARAM(conn_params->supervision_timeout, ESP_BLE_CONN_SUP_TOUT_MIN, ESP_BLE_CONN_SUP_TOUT_MAX) && + (conn_params->latency <= ESP_BLE_CONN_LATENCY_MAX) && + ((conn_params->supervision_timeout * 10) >= ((1 + conn_params->latency) * ((conn_params->interval_max * 5) >> 1))) && + (conn_params->interval_min <= conn_params->interval_max)) { + memcpy(&arg.open.phy_coded_conn_params, conn_params, sizeof(esp_ble_conn_params_t)); + } else { + LOG_ERROR("%s, invalid Coded PHY connection params: min_int = %d, max_int = %d, latency = %d, timeout = %d", __func__, + conn_params->interval_min, + conn_params->interval_max, + conn_params->latency, + conn_params->supervision_timeout); + return ESP_ERR_INVALID_ARG; + } + } + + return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), NULL, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL); +} +#endif // #if (BT_BLE_FEAT_PAWR_EN == TRUE) + esp_err_t esp_ble_gattc_close (esp_gatt_if_t gattc_if, uint16_t conn_id) { btc_msg_t msg = {0}; diff --git a/components/bt/host/bluedroid/api/include/api/esp_gap_ble_api.h b/components/bt/host/bluedroid/api/include/api/esp_gap_ble_api.h index 89b14f7b75..102fdfd66b 100644 --- a/components/bt/host/bluedroid/api/include/api/esp_gap_ble_api.h +++ b/components/bt/host/bluedroid/api/include/api/esp_gap_ble_api.h @@ -249,6 +249,24 @@ typedef enum { ESP_GAP_BLE_SET_COMMON_FACTOR_CMPL_EVT, /*!< When set the common factor complete, the event comes */ ESP_GAP_BLE_SET_SCH_LEN_CMPL_EVT, /*!< When set the scheduling length complete, the event comes */ ESP_GAP_BLE_SET_SCAN_CHAN_MAP_CMPL_EVT, /*!< When set the channel map for scanning complete, the event comes */ + ESP_GAP_BLE_SET_PERIODIC_ADV_SUBEVT_DATA_EVT, /*!< When BLE update periodic adv subevent data complete, the event comes */ + ESP_GAP_BLE_SET_PERIODIC_ADV_RESPONSE_DATA_EVT, /*!< When BLE update periodic adv response data complete, the event comes */ + ESP_GAP_BLE_SET_PERIODIC_SYNC_SUBEVT_EVT, /*!< When BLE update periodic sync subevent complete, the event comes */ + ESP_GAP_BLE_PERIODIC_ADV_SUBEVT_DATA_REQUEST_EVT, /*!< When Controller is ready to transmit one or more subevents and is requesting the advertising data for these subevents, the event comes*/ + ESP_GAP_BLE_PERIODIC_ADV_RESPONSE_REPORT_EVT, /*!< When one or more devices have responded to a periodic advertising subevent during a PAwR train, the event comes */ + ESP_GAP_BLE_CS_READ_LOCAL_SUPP_CAPS_EVT, /*!< When CS read local supported capabilities complete, the event comes */ + ESP_GAP_BLE_CS_WRITE_CACHED_REMOTE_SUPP_CAPS_EVT, /*!< When CS write cached remote supported capabilities complete, the event comes */ + ESP_GAP_BLE_CS_SET_DEFAULT_SETTINGS_EVT, /*!< When CS set default settings complete, the event comes */ + ESP_GAP_BLE_CS_WRITE_CACHED_REMOTE_FAE_TABLE_EVT, /*!< When CS write cached remote FAE table complete, the event comes */ + ESP_GAP_BLE_CS_READ_REMOTE_SUPP_CAPS_CMPL_EVT, /*!< When CS read remote supported capabilities complete, the event comes */ + ESP_GAP_BLE_CS_SET_CHANNEL_CLASS_CMPL_EVT, /*!< When CS set channel classification complete, the event comes */ + ESP_GAP_BLE_CS_SET_PROC_PARAMS_CMPL_EVT, /*!< When CS set procedure parameters complete, the event comes */ + ESP_GAP_BLE_CS_PROC_ENABLE_CMPL_EVT, /*!< When CS procedure enable complete, the event comes */ + ESP_GAP_BLE_CS_READ_REMOTE_FAE_TABLE_CMPL_EVT, /*!< When CS read remote FAE table complete, the event comes */ + ESP_GAP_BLE_CS_SECURITY_ENABLE_CMPL_EVT, /*!< When CS security enable complete, the event comes */ + ESP_GAP_BLE_CS_CONFIG_CMPL_EVT, /*!< When CS has completed the Channel Sounding Configuration procedure, the event comes */ + ESP_GAP_BLE_CS_SUBEVENT_RESULT_EVT, /*!< When CS has results to report for a CS subevent during the CS procedure, the event comes */ + ESP_GAP_BLE_CS_SUBEVENT_RESULT_CONTINUE_EVT, /*!< When CS has completed a new CS subevent measurement, the event comes */ ESP_GAP_BLE_EVT_MAX, /*!< when maximum advertising event complete, the event comes */ } esp_gap_ble_cb_event_t; @@ -857,6 +875,12 @@ typedef uint8_t esp_ble_gap_all_phys_t; #define ESP_BLE_GAP_PRI_PHY_CODED ESP_BLE_GAP_PHY_CODED /*!< Primary Phy is LE CODED */ typedef uint8_t esp_ble_gap_pri_phy_t; // primary phy +#define ESP_BLE_GAP_RPT_PHY_1M 1 /*!< Advertiser PHY is LE 1M */ +#define ESP_BLE_GAP_RPT_PHY_2M 2 /*!< Advertiser PHY is LE 2M */ +#define ESP_BLE_GAP_RPT_PHY_S8 3 /*!< If the Advertising Coding Selection feature bit is set: Advertising PHY is LE 125K Otherwise: Advertiser PHY is LE Coded */ +#define ESP_BLE_GAP_RPT_PHY_S2 4 /*!< If the Advertising Coding Selection feature bit is set: Advertising PHY is LE 500K Otherwise: Reserved for future use */ +typedef uint8_t esp_ble_gap_rpt_phy_t; // extended Advertising report phy + #define ESP_BLE_GAP_PHY_1M_PREF_MASK (1 << 0) /*!< The Host prefers use the LE1M transmitter or receiver PHY */ #define ESP_BLE_GAP_PHY_2M_PREF_MASK (1 << 1) /*!< The Host prefers use the LE2M transmitter or receiver PHY */ #define ESP_BLE_GAP_PHY_CODED_PREF_MASK (1 << 2) /*!< The Host prefers use the LE CODED transmitter or receiver PHY */ @@ -905,6 +929,21 @@ typedef uint8_t esp_ble_gap_adv_type_t; /// max number of advertising sets to enable or disable #define EXT_ADV_NUM_SETS_MAX (10) /*!< max evt instance num */ +#if (CONFIG_BT_BLE_FEAT_ADV_CODING_SELECTION) +// The Host has no preferred or required coding when transmitting on the LE Coded PHY +#define ESP_BLE_ADV_PHY_OPTIONS_NO_PREFER_CODED (0x00) +// The Host prefers that S=2 coding be used when transmitting on the LE Coded PHY +#define ESP_BLE_ADV_PHY_OPTIONS_PREFER_CODED_S2 (0x01) +// The Host prefers that S=8 coding be used when transmitting on the LE Coded PHY +#define ESP_BLE_ADV_PHY_OPTIONS_PREFER_CODED_S8 (0x02) +// The Host requires that S=2 coding be used when transmitting on the LE Coded PHY +#define ESP_BLE_ADV_PHY_OPTIONS_REQUIRE_CODED_S2 (0x03) +// The Host requires that S=8 coding be used when transmitting on the LE Coded PHY +#define ESP_BLE_ADV_PHY_OPTIONS_REQUIRE_CODED_S8 (0x04) + +typedef uint8_t esp_ble_gap_adv_phy_options_t; +#endif //(CONFIG_BT_BLE_FEAT_ADV_CODING_SELECTION) + /** * @brief ext adv parameters */ @@ -923,6 +962,10 @@ typedef struct { esp_ble_gap_phy_t secondary_phy; /*!< ext adv secondary phy */ uint8_t sid; /*!< ext adv sid */ bool scan_req_notif; /*!< ext adv scan request event notify */ +#if (CONFIG_BT_BLE_FEAT_ADV_CODING_SELECTION) + esp_ble_gap_adv_phy_options_t primary_adv_phy_options; /*!< The Host's preference or requirement concerning coding scheme */ + esp_ble_gap_adv_phy_options_t secondary_adv_phy_options; /*!< The Host's preference or requirement concerning coding scheme(including for periodic advertising) */ +#endif // CONFIG_BT_BLE_FEAT_ADV_CODING_SELECTION } esp_ble_gap_ext_adv_params_t; /** @@ -975,7 +1018,25 @@ typedef struct { typedef struct { uint16_t interval_min; /*!< periodic advertising minimum interval */ uint16_t interval_max; /*!< periodic advertising maximum interval */ - uint8_t properties; /*!< periodic advertising properties */ + uint16_t properties; /*!< periodic advertising properties */ +#if (CONFIG_BT_BLE_FEAT_PAWR_EN) + uint8_t num_subevents; /*!< Number of subevents in the PAwR. Range: 0x00 to 0x80 + 0x00: Periodic Advertising without responses */ + uint8_t subevent_interval; /*!< Interval between subevents. + Range: 0x06 to 0xFF. + Time = N × 1.25 ms. + Time Range: 7.5 ms to 318.75 ms. */ + uint8_t rsp_slot_delay; /*!< Time between the advertising packet in a subevent and the first response slot. + Range: 0x01 to 0xFE. + Time = N × 1.25 ms. + Time Range: 1.25 ms to 317.5 ms. */ + uint8_t rsp_slot_spacing; /*!< Time between response slots. + Range: 0x02 to 0xFF. + Time = N × 0.125 ms. + Time Range: 0.25 ms to 31.875 ms */ + uint8_t num_rsp_slots; /*!< Number of subevent response slots + Range: 0x01 to 0xFF. */ +#endif // (CONFIG_BT_BLE_FEAT_PAWR_EN) } esp_ble_gap_periodic_adv_params_t; /** @@ -1017,8 +1078,28 @@ typedef struct { esp_ble_gap_adv_type_t event_type; /*!< extend advertising type */ uint8_t addr_type; /*!< extend advertising address type */ esp_bd_addr_t addr; /*!< extend advertising address */ +#if (CONFIG_BT_BLE_FEAT_PAWR_EN) + esp_ble_gap_rpt_phy_t primary_phy; /*!< extend advertising primary phy + 0x01: Advertiser PHY is LE 1M + 0x03: If the Advertising Coding Selection (Host Support) feature bit is set: Advertising PHY is LE Coded with S=8 data coding + Otherwise: Advertiser PHY is LE Coded + 0x04: If the Advertising Coding Selection (Host Support) feature bit is set: Advertising PHY is LE Coded with S=2 data coding + Otherwise: Reserved for future use + */ + + esp_ble_gap_rpt_phy_t secondary_phy; /*!< extend advertising secondary phy + 0x00: No packets on the secondary advertising physical channel + 0x01: Advertiser PHY is LE 1M + 0x02: Advertiser PHY is LE 2M + 0x03: If the Advertising Coding Selection (Host Support) feature bit is set: Advertising PHY is LE Coded with S=8 data coding + Otherwise: Advertiser PHY is LE Coded + 0x04: If the Advertising Coding Selection (Host Support) feature bit is set: Advertising PHY is LE Coded with S=2 data coding + Otherwise: Reserved for future use + */ +#else esp_ble_gap_pri_phy_t primary_phy; /*!< extend advertising primary phy */ esp_ble_gap_phy_t secondly_phy; /*!< extend advertising secondary phy */ +#endif uint8_t sid; /*!< extend advertising sid */ uint8_t tx_power; /*!< extend advertising tx power */ int8_t rssi; /*!< extend advertising rssi */ @@ -1044,6 +1125,10 @@ typedef struct { 0x02: AoD Constant Tone Extension with 2 μs slots 0xFF: No Constant Tone Extension */ #endif // BT_BLE_FEAT_CTE_EN +#if (CONFIG_BT_BLE_FEAT_PAWR_EN) + uint16_t periodic_evt_counter; /*!< The value of paEventCounter for the reported periodic advertising packet */ + uint8_t subevt; /*!< The subevent number */ +#endif // (CONFIG_BT_BLE_FEAT_PAWR_EN) esp_ble_gap_ext_adv_data_status_t data_status; /*!< periodic advertising data type*/ uint8_t data_length; /*!< periodic advertising data length */ uint8_t data[251]; /*!< periodic advertising data */ @@ -1221,6 +1306,416 @@ typedef struct { The supervision_timeout, in milliseconds, shall be greater than 2 × current connection interval × subrate_max × (max_latency + 1) */ } esp_ble_subrate_req_param_t; +/** +* @brief Periodic adv subevent parameters +*/ +typedef struct { + uint8_t subevent; /*!< The subevent index of the data contained in this command. Range: 0x00 to 0x7F */ + uint8_t response_slot_start; /*!< The first response slots to be used in this subevent */ + uint8_t response_slot_count; /*!< The number of response slots to be used */ + uint8_t subevent_data_len; /*!< The number of octets in the Subevent_Data parameter. Range: 0 to 251 */ + uint8_t *subevent_data; /*!< The advertising data to be transmitted in the subevent of the advertising set */ +} esp_ble_subevent_params; + +/** +* @brief Periodic adv subevent data parameters +*/ +typedef struct { + uint8_t adv_handle; /*!< Used to identify a periodic advertising train */ + uint8_t num_subevents_with_data; /*!< Number of subevent data in the command. Range: 0x0001 to 0x0F */ + esp_ble_subevent_params *subevent_params; /*!< Periodic adv subevent parameters */ +} esp_ble_per_adv_subevent_data_params; + +/** +* @brief Periodic adv response data parameters +*/ +typedef struct { + uint16_t sync_handle; /*!< Sync_Handle identifying the PAwR train */ + uint16_t request_event; /*!< The value of eventCounter for the periodic advertising packet that the Host is responding to */ + uint8_t request_subevent; /*!< The subevent for the periodic advertising packet that the Host is responding to */ + uint8_t response_subevent; /*!< Used to identify the subevent of the PAwR train. Range: 0x00 to 0x7F */ + uint8_t response_slot; /*!< Used to identify the response slot of the PAwR train. Range: 0x00 to 0xFF */ + uint8_t response_data_len; /*!< The number of octets in the Response_Data parameter. Range: 0 to 251 */ + uint8_t *response_data; /*!< Response data */ +} esp_ble_per_adv_response_data_params; + +/** +* @brief Periodic sync subevent parameters +*/ +typedef struct { + uint16_t sync_handle; /*!< Sync_Handle identifying the PAwR train */ + uint16_t periodic_adv_properties; /*!< Include TxPower in the advertising PDU */ + uint8_t num_subevents_to_sync; /*!< Number of subevents. Range: 0x01 to 0x80 */ + uint8_t *subevent; /*!< The subevent to synchronize with. Range 0x00 to 0x7F */ +} esp_ble_per_sync_subevent_params; + +/** +* @brief Periodic response information +*/ +typedef struct { + int8_t tx_power; /*!< Range: -127 to +20, Units: dBm + 0x7F: Tx Power information not available*/ + int8_t rssi; /*!< Range: -127 to +20. Units: dBm + 0x7F: RSSI is not available */ + uint8_t cte_type; /*!< cte type + 0x00: AoA Constant Tone Extension + 0x01: AoD Constant Tone Extension with 1 µs slots + 0x02: AoD Constant Tone Extension with 2 µs slots + 0xFF: No Constant Tone Extension*/ + uint8_t rsp_slot; /*!< The response slot the data was received in. */ + uint8_t data_status; /*!< Data status + 0x00: Data complete + 0x01: Data incomplete, more data to come + 0xFF: Failed to receive or listen for an AUX_SYNC_SUBEVENT_RSP PDU*/ + uint8_t data_len; /*!< Length of the Data field */ + uint8_t *data; /*!< Periodic advertising response data formatted as defined in [Vol 3] Part C, Section 11*/ +} esp_ble_pa_rsp_info; + +/** Initiator role that are supported by the remote Controller */ +#define ESP_BLE_CS_INITIATOR_ROLE_SUPPORTED (1 << 0) +/** Reflector role that are supported by the remote Controller */ +#define ESP_BLE_CS_REFLECTOR_ROLE_SUPPORTED (1 << 1) + +/** The RTT_AA_Only_N field refers to the 150 ns time-of-flight precision requirement */ +#define ESP_BLE_CS_RTT_CAPABILITY_RTT_AA_ONLY_N_150NS (0 << 0) +/** The RTT_AA_Only_N field refers to the 10 ns time-of-flight precision requirement */ +#define ESP_BLE_CS_RTT_CAPABILITY_RTT_AA_ONLY_N_10NS (1 << 0) +/** The RTT_Sounding_N field refers to the 150 ns time-of-flight precision requirement */ +#define ESP_BLE_CS_RTT_CAPABILITY_RTT_SOUNDING_N_150NS (0 << 1) +/** The RTT_Sounding_N field refers to the 10 ns time-of-flight precision requirement */ +#define ESP_BLE_CS_RTT_CAPABILITY_RTT_SOUNDING_N_10NS (1 << 1) +/** The RTT_Random_Payload_N field refers to the 150 ns time-of-flight precision requirement */ +#define ESP_BLE_CS_RTT_CAPABILITY_RTT_RANDOM_PAYLOAD_N_150NS (0 << 2) +/** The RTT_Random_Payload_N field refers to the 10 ns time-of-flight precision requirement */ +#define ESP_BLE_CS_RTT_CAPABILITY_RTT_RANDOM_PAYLOAD_N_10NS (1 << 2) +typedef uint8_t esp_ble_cs_rtt_caps_opt_t; + +/** CS_SYNC 2M phy supported */ +#define ESP_BLE_CS_SYNC_PHYS_2M_SUPPORTED (1 << 1) +/** CS_SYNC 2M 2BT phy supported */ +#define ESP_BLE_CS_SYNC_PHYS_2M_2BT_SUPPORTED (1 << 2) + +/**The length of Channel Sounding channel map */ +#define ESP_BLE_CS_CHAN_MAP_LEN 10 + +/** +* @brief CS write cached remote supported capabilities parameters +*/ +typedef struct { + uint16_t conn_handle; /*!< Connection_Handle */ + uint8_t num_config_supported; /*!< The number of CS configurations that are supported by the remote Controller. Range: 0x01 to 0x04 */ + uint16_t max_consecutive_proc_supported;/*!< 0x0000: Support for both a fixed number of consecutive CS procedures and for an indefinite number of CS procedures until termination + 0x0001 to 0xFFFF: The Maximum number of consecutive CS procedures supported */ + uint8_t num_ant_supported; /*!< Number of antennas supported. Range: 0x01 to 0x04 */ + uint8_t max_ant_paths_supported; /*!< Maximum number of antenna paths supported. Range: 0x01 to 0x04 */ + bool initiator_role_supported; /*!< Initiator role that are supported by the remote Controller */ + bool reflector_role_supported; /*!< Reflector role that are supported by the remote Controller */ + uint8_t modes_supported; /*!< The optional CS modes that are supported by the remote Controller + bit 0: Mode-3 */ + esp_ble_cs_rtt_caps_opt_t rtt_capability; /*!< time-of-flight precision requirement */ + uint8_t rtt_aa_only_n; /*!< 0x00: RTT AA-only not supported. + 0x01 to 0xff: Number of CS_SYNC exchanges needed to satisfy the precision requirements */ + uint8_t rtt_sounding_n; /*!< 0x00: RTT Sounding not supported + 0x01 to 0xFF: Number of CS_SYNC exchanges needed to satisfy the precision requirements */ + uint8_t rtt_random_payload_n; /*!< 0x00: RTT Random Payload not supported + 0x01 to 0xff: Number of CS_SYNC exchanges needed to satisfy the time-of-flight precision requirements */ + uint16_t NADM_sounding_capability; /*!< Support for Phase-based Normalized Attack Detector Metric when a CS_SYNC with sounding sequence is received */ + uint16_t NADM_random_capability; /*!< Support for Phase-based Normalized Attack Detector Metric when a CS_SYNC with random sequence is received */ + bool cs_sync_2m_phy_supported; /*!< CS_SYNC 2M phy supported */ + bool cs_sync_2m_2bt_phy_supported; /*!< CS_SYNC 2M 2BT phy supported */ + uint16_t subfeatures_supported; /*!< bit 1: CS with a Frequency Actuation Error of zero relative to mode-0 transmissions in the reflector role + bit 2: CS Channel Selection Algorithm #3c + bit 3: CS phase-based ranging from an RTT sounding sequence */ + uint16_t T_IP1_times_supported; /*!< bit 0: 10 μs supported + bit 1: 20 μs supported + bit 2: 30 μs supported + bit 3: 40 μs supported + bit 4: 50 μs supported + bit 5: 60 μs supported + bit 6: 80 μs supported + */ + uint16_t T_IP2_times_supported; /*!< bit 0: 10 μs supported + bit 1: 20 μs supported + bit 2: 30 μs supported + bit 3: 40 μs supported + bit 4: 50 μs supported + bit 5: 60 μs supported + bit 6: 80 μs supported + */ + uint16_t T_FCS_times_supported; /*!< bit 0: 15 μs supported + bit 1: 20 μs supported + bit 2: 30 μs supported + bit 3: 40 μs supported + bit 4: 50 μs supported + bit 5: 60 μs supported + bit 6: 80 μs supported + bit 7: 100 μs supported + bit 8: 120 μs supported + */ + uint16_t T_PM_times_supported; /*!< bit 0: 10 μs supported + bit 1: 20 μs supported + */ + uint8_t T_SW_times_supported; /*!< Time in microseconds for the antenna switch period of the CS tones. Range: 0x00 to 0x04 or 0x0A */ + uint8_t TX_SNR_capability; /*!< bit 0: 18 dB supported + bit 1: 21 dB supported + bit 2: 24 dB supported + bit 3: 27 dB supported + bit 4: 30 dB supported + */ +} esp_ble_cs_write_cached_remote_supp_caps_params; + +/** +* @brief CS sync antenna selection options +*/ +typedef enum { + /** Use antenna identifier 1 for CS_SYNC packets by the local Controller */ + ESP_BLE_CS_ANT_SELECTION_OPT_ONE = 0x01, + /** Use antenna identifier 2 for CS_SYNC packets by the local Controller */ + ESP_BLE_CS_ANT_SELECTION_OPT_TWO = 0x02, + /** Use antenna identifier 3 for CS_SYNC packets by the local Controller */ + ESP_BLE_CS_ANT_SELECTION_OPT_THREE = 0x03, + /** Use antenna identifier 4 for CS_SYNC packets by the local Controller */ + ESP_BLE_CS_ANT_SELECTION_OPT_FOUR = 0x04, + /** Use antennas in repetitive order from 1 to 4 for CS_SYNC packets by the local Controller */ + ESP_BLE_CS_ANT_SELECTION_OPT_REPETITIVE = 0xFE, + /** No recommendation for local controller antenna selection by the local Controller */ + ESP_BLE_CS_ANT_SELECTION_OPT_NO_RECOMMENDATION = 0xFF, +} esp_ble_cs_sync_ant_selection_opt_t; + +/** Initiator role is enabled */ +#define ESP_BLE_CS_INITIATOR_ROLE_ENABLED (1 << 0) +/** Reflector role is enabled */ +#define ESP_BLE_CS_REFLECTOR_ROLE_ENABLED (1 << 1) + +/** +* @brief CS set default settings parameters +*/ +typedef struct { + uint16_t conn_handle; /*!< Connection_Handle */ + bool initiator_role_enable; /*!< Initiator role is enabled */ + bool reflector_role_enable; /*!< Reflector role is enabled */ + esp_ble_cs_sync_ant_selection_opt_t cs_sync_ant_selection; /*!< 0x01 to 0x04: Antenna identifier to be used for CS_SYNC packets by the local Controller + 0xFE: Antennas to be used, in repetitive order from 0x01 to 0x04, for CS_SYNC packets by the local Controller + 0xFF: Host does not have a recommendation + */ + int8_t max_tx_power; /*!< The maximum transmit power level to be used for all CS transmissions. Range: -127 to 20. Units: dBm */ +} esp_ble_cs_set_default_settings_params; + +/** +* @brief CS write cached remote Frequency Actuation Error table parameters +*/ +typedef struct { + uint16_t conn_handle; /*!< Connection_Handle */ + uint8_t remote_fae_table[72]; /*!< Per-channel mode-0 Frequency Actuation Error table of the local Controller */ +} esp_ble_cs_write_cached_remote_fae_table_params; + +#define ESP_BLE_CS_SYNC_PHY_1M (0x01) +#define ESP_BLE_CS_SYNC_PHY_2M (0x02) +#define ESP_BLE_CS_SYNC_PHY_2M_2BT (0x03) +typedef uint8_t esp_ble_cs_sync_phy_opt_t; + +#define ESP_BLE_CS_RTT_TYPE_RTT_AA_ONLY (0X00) +#define ESP_BLE_CS_RTT_TYPE_RTT_WITH_32BIT_SOUNDING_SEQUENCE (0X01) +#define ESP_BLE_CS_RTT_TYPE_RTT_WITH_96BIT_SOUNDING_SEQUENCE (0X02) +#define ESP_BLE_CS_RTT_TYPE_RTT_WITH_32BIT_RANDOM_SEQUENCE (0X03) +#define ESP_BLE_CS_RTT_TYPE_RTT_WITH_64BIT_RANDOM_SEQUENCE (0X04) +#define ESP_BLE_CS_RTT_TYPE_RTT_WITH_96BIT_RANDOM_SEQUENCE (0X05) +#define ESP_BLE_CS_RTT_TYPE_RTT_WITH_128BIT_RANDOM_SEQUENCE (0X06) +typedef uint8_t esp_ble_cs_rtt_type_opt_t; + +#define ESP_BLE_CS_ROLE_INITIATOR (0x00) +#define ESP_BLE_CS_ROLE_REFLECTOR (0x01) +typedef uint8_t esp_ble_cs_role_opt_t; + +#define ESP_BLE_CS_MAIN_MODE_TYPE_MODE_1 (0x01) +#define ESP_BLE_CS_MAIN_MODE_TYPE_MODE_2 (0x02) +#define ESP_BLE_CS_MAIN_MODE_TYPE_MODE_3 (0x03) +typedef uint8_t esp_ble_cs_main_mode_opt_t; + +#define ESP_BLE_CS_SUB_MODE_TYPE_MODE_1 (0x01) +#define ESP_BLE_CS_SUB_MODE_TYPE_MODE_2 (0x02) +#define ESP_BLE_CS_SUB_MODE_TYPE_MODE_3 (0x03) +#define ESP_BLE_CS_SUB_MODE_TYPE_UNUSED (0xFF) +typedef uint8_t esp_ble_cs_sub_mode_opt_t; + +#define ESP_BLE_CS_CREAT_CONTEXT_IN_LOCAL_CONTROLLER (0x00) +#define ESP_BLE_CS_CREAT_CONTEXT_IN_LOCAL_AND_REMOTE_CONTROLLER (0x01) +typedef uint8_t esp_ble_cs_create_context_opt_t; + +#define ESP_BLE_CS_CAHNNEL_SELECT_TYPE_ALGORITHM_3b (0x00) +#define ESP_BLE_CS_CAHNNEL_SELECT_TYPE_ALGORITHM_3C (0x01) +typedef uint8_t esp_ble_cs_channel_select_type_opt_t; + +#define ESP_BLE_CS_CH3C_USE_HAT_SHAPE (0x00) +#define ESP_BLE_CS_CH3C_USE_X_SHAPE (0x01) +typedef uint8_t esp_ble_cs_ch3c_shape_opt_t; + +/** +* @brief CS create configuration parameters +*/ +typedef struct { + uint16_t conn_handle; /*!< Connection_Handle */ + uint8_t config_id; /*!< CS configuration identifier. Range: 0 to 3 */ + esp_ble_cs_create_context_opt_t create_context; /*!< 0x00: Write CS configuration in local Controller only + 0x01: Write CS configuration in both local and remote Controller using Channel Sounding Configuration procedure + */ + esp_ble_cs_main_mode_opt_t main_mode_type; /*!< 0x01: Mode-1 + 0x02: Mode-2 + 0x03: Mode-3 + */ + esp_ble_cs_sub_mode_opt_t sub_mode_type; /*!< 0x01: Mode-1 + 0x02: Mode-2 + 0x03: Mode-3 + 0xFF: Unused + */ + uint8_t min_main_mode_steps; /*!< Minimum number of CS main mode steps to be executed before a submode step is executed. Range: 0x02 to 0xFF */ + uint8_t max_main_mode_steps; /*!< Maximum number of CS main mode steps to be executed before a submode step is executed. Range: 0x02 to 0xFF */ + uint8_t main_mode_repetition; /*!< 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. Range: 0x00 to 0x03 */ + uint8_t mode_0_steps; /*!< Number of CS mode-0 steps to be included at the beginning of each CS subevent. Range: 0x01 to 0x03 */ + esp_ble_cs_role_opt_t role; /*!< 0x00: Initiator + 0x01: Reflector + */ + esp_ble_cs_rtt_type_opt_t rtt_type; /*!< 0x00: RTT AA-only + 0x01: RTT with 32-bit sounding sequence + 0x02: RTT with 96-bit sounding sequence + 0x03: RTT with 32-bit random sequence + 0x04: RTT with 64-bit random sequence + 0x05: RTT with 96-bit random sequence + 0x06: RTT with 128-bit random sequence + */ + esp_ble_cs_sync_phy_opt_t cs_sync_phy; /*!< 0x01: LE 1M PHY + 0x02: LE 2M PHY + 0x03: LE 2M 2BT PHY + */ + uint8_t channel_map[ESP_BLE_CS_CHAN_MAP_LEN]; /*!< This parameter contains 80 1-bit fields. + The nth such field (in the range 0 to 78) contains the value for the CS channel index n. + Channel n is enabled for CS procedure = 1 + Channel n is disabled for CS procedure = 0 + Channels n = 0, 1, 23, 24, 25, 77, and 78 shall be ignored and shall be set to zero. At least 15 channels shall be enabled. + The most significant bit (bit 79) is reserved for future use + */ + uint8_t channel_map_repetition; /*!< The number of times the map represented by the Channel_Map field is to be cycled through for non-mode-0 steps within a CS procedure. Range: 0x01 to 0xFF */ + esp_ble_cs_channel_select_type_opt_t channel_selection_type;/*!< 0x00: Use Channel Selection Algorithm #3b for non-mode-0 CS steps + 0x01: Use Channel Selection Algorithm #3c for non-mode-0 CS steps + */ + esp_ble_cs_ch3c_shape_opt_t ch3c_shape; /*!< 0x00: Use Hat shape for user-specified channel sequence + 0x01: Use X shape for user-specified channel sequence + */ + uint8_t ch3c_jump; /*!< Number of channels skipped in each rising and falling sequence. Range: 0x02 to 0x08 */ + uint8_t reserved; /*!< Reserved, shall be set to 0x00 */ +} esp_ble_cs_create_config_params; + +/** +* @brief CS remove configuration parameters +*/ +typedef struct { + uint16_t conn_handle; /*!< Connection_Handle */ + uint8_t config_id; /*!< CS configuration identifier. Range: 0 to 3 */ +} esp_ble_cs_remove_config_params; + +/** +* @brief CS set channel class parameters +*/ +typedef struct { + uint8_t channel_class[10]; /*!< This parameter contains 80 1-bit fields. + The nth such field (in the range 0 to 78) contains the value for the CS channel index n. + Channel n is enabled for CS procedure = 1 + Channel n is disabled for CS procedure = 0 + Channels n = 0, 1, 23, 24, 25, 77, and 78 shall be reserved for future use and shall be set to zero. At least 15 channels shall be enabled. + The most significant bit (bit 79) is reserved for future use. + */ +} esp_ble_cs_set_channel_class_params; + +#define ESP_BLE_CS_PHY_1M (0x01) +#define ESP_BLE_CS_PHY_2M (0x02) +#define ESP_BLE_CS_PHY_S8 (0x03) +#define ESP_BLE_CS_PHY_S2 (0x04) +typedef uint8_t esp_ble_cs_phy_opt_t; + +#define ESP_BLE_CS_PREFERRED_FIRST_ORDER_ANT (1 << 0) +#define ESP_BLE_CS_PREFERRED_SECOND_ORDER_ANT (1 << 1) +#define ESP_BLE_CS_PREFERRED_THIRD_ORDER_ANT (1 << 2) +#define ESP_BLE_CS_PREFERRED_FOURTH_ORDER_ANT (1 << 3) +typedef uint8_t esp_ble_cs_preferred_peer_ant_t; + +#define ESP_BLE_CS_SNR_CONTROL_ADIJUSTMENT_18DB (0x00) +#define ESP_BLE_CS_SNR_CONTROL_ADIJUSTMENT_21DB (0x01) +#define ESP_BLE_CS_SNR_CONTROL_ADIJUSTMENT_24DB (0x02) +#define ESP_BLE_CS_SNR_CONTROL_ADIJUSTMENT_27DB (0x03) +#define ESP_BLE_CS_SNR_CONTROL_ADIJUSTMENT_30DB (0x04) +#define ESP_BLE_CS_SNR_CONTROL_NOT_APPLIED (0xFF) +typedef uint8_t esp_ble_cs_snr_control_adjustment_t; + +/** +* @brief CS set procedure parameters +*/ +typedef struct { + uint16_t conn_handle; /*!< Connection_Handle */ + uint8_t config_id; /*!< CS configuration identifier. Range: 0 to 3 */ + uint16_t max_procedure_len; /*!< Maximum duration for each CS procedure. Range: 0x0001 to 0xFFFF. Time = N × 0.625 ms */ + uint16_t min_procedure_interval; /*!< Minimum number of connection events between consecutive CS procedures. Range: 0x0001 to 0xFFFF */ + uint16_t max_procedure_interval; /*!< Maximum number of connection events between consecutive CS procedures. Range: 0x0001 to 0xFFFF */ + uint16_t max_procedure_count; /*!< 0x0000:CS procedures to continue until disabled + 0xxxxx: Maximum number of CS procedures to be scheduled + */ + uint32_t min_subevent_len; /*!< Minimum suggested duration for each CS subevent in microseconds. Range: 1250 μs to 4 s */ + uint32_t max_subevent_len; /*!< Maximum suggested duration for each CS subevent in microseconds. Range: 1250 μs to 4 s */ + uint8_t tone_ant_config_selection; /*!< Antenna Configuration Index. Range: 0x00 to 0x07 */ + esp_ble_cs_phy_opt_t phy; /*!< 0x01: LE 1M PHY + 0x02: LE 2M PHY + 0x03: LE Coded PHY with S=8 data coding + 0x04: LE Coded PHY with S=2 data coding + */ + uint8_t tx_power_delta; /*!< 0xxx: Transmit power delta, in signed dB, to indicate the recommended difference between the remote device’s power level + for the CS tones and RTT packets and the existing power level for the PHY indicated by the PHY parameter + 0x80: Host does not have a recommendation for transmit power delta + */ + esp_ble_cs_preferred_peer_ant_t preferred_peer_antenna; /*!< bit 0: Use first ordered antenna element + bit 1: Use second ordered antenna element + bit 2: Use third ordered antenna element + bit 3: Use fourth ordered antenna element + */ + esp_ble_cs_snr_control_adjustment_t SNR_control_initiator; /*!< 0x00: SNR control adjustment of 18 dB. + 0x01: SNR control adjustment of 21 dB. + 0x02: SNR control adjustment of 24 dB. + 0x03: SNR control adjustment of 27 dB. + 0x04: SNR control adjustment of 30 dB. + 0xFF: SNR control is not to be applied + */ + esp_ble_cs_snr_control_adjustment_t SNR_control_reflector; /*!< 0x00: SNR control adjustment of 18 dB. + 0x01: SNR control adjustment of 21 dB. + 0x02: SNR control adjustment of 24 dB. + 0x03: SNR control adjustment of 27 dB. + 0x04: SNR control adjustment of 30 dB. + 0xFF: SNR control is not to be applied. + */ +} esp_ble_cs_set_proc_params; + +#define ESP_BLE_CS_PROCEDURES_DISABLE (0x00) +#define ESP_BLE_CS_PROCEDURES_ENABLE (0x01) +typedef uint8_t esp_ble_cs_procedures_action_t; + +/** +* @brief CS procedure enable parameters +*/ +typedef struct { + uint16_t conn_handle; /*!< Connection_Handle */ + uint8_t config_id; /*!< CS configuration identifier. Range: 0 to 3 */ + esp_ble_cs_procedures_action_t enable; /*!< 0x00: CS procedures are to be disabled + 0x01: CS procedures are to be enabled + */ +} esp_ble_cs_procedure_enable_params; + +/** +* @brief CS step information +*/ +typedef struct { + uint8_t step_mode; /*!< 0x00 to 0x03: Mode type */ + uint8_t step_channel; /*!< 0x00 to 0x4E: CS channel index */ + uint8_t step_data_len; /*!< 0x00 to 0xFF: Length of mode- and role-specific information being reported */ + uint8_t *data; /*!< Mode- and role-specific information being reported as Mode_Role_Specific_Info object */ +} esp_ble_cs_step_info; /** * @brief Gap callback parameters union @@ -1634,6 +2129,12 @@ typedef union { esp_ble_gap_phy_t adv_phy; /*!< periodic advertising phy type */ uint16_t period_adv_interval; /*!< periodic advertising interval */ uint8_t adv_clk_accuracy; /*!< periodic advertising clock accuracy */ +#if (CONFIG_BT_BLE_FEAT_PAWR_EN) + uint8_t num_subevt; /*!< Number of subevents, Range: 0x00 to 0x80 */ + uint8_t subevt_interval; /*!< Subevent interval, Time = N × 1.25 ms */ + uint8_t rsp_slot_delay; /*!< Response slot delay, Time = N × 1.25 ms */ + uint8_t rsp_slot_spacing; /*!< Response slot spacing, Time = N × 0.125 ms */ +#endif // (CONFIG_BT_BLE_FEAT_PAWR_EN) } periodic_adv_sync_estab; /*!< Event parameter of ESP_GAP_BLE_PERIODIC_ADV_SYNC_ESTAB_EVT */ /** * @brief ESP_GAP_BLE_PHY_UPDATE_COMPLETE_EVT @@ -1879,6 +2380,419 @@ typedef union { esp_bt_status_t status; /*!< Indicate host feature update success status */ } host_feature; /*!< Event parameter of ESP_GAP_BLE_SET_HOST_FEATURE_CMPL_EVT */ #endif // #if (BLE_50_FEATURE_SUPPORT == TRUE) +#if (BT_BLE_FEAT_PAWR_EN == TRUE) + /** + * @brief ESP_GAP_BLE_SET_PERIODIC_ADV_SUBEVT_DATA_EVT + */ + struct ble_pa_subevt_data_evt { + esp_bt_status_t status; /*!< Indicate periodic adv subevent data update success status */ + uint8_t adv_handle; /*!< Used to identify a periodic advertising train */ + } pa_subevt_data_evt; /*!< Event parameter of ESP_GAP_BLE_SET_PERIODIC_ADV_SUBEVT_DATA_EVT */ + /** + * @brief ESP_GAP_BLE_SET_PERIODIC_ADV_RESPONSE_DATA_EVT + */ + struct ble_pa_rsp_data_evt { + esp_bt_status_t status; /*!< Indicate periodic adv response data update success status */ + uint16_t sync_handle; /*!< identifying the periodic advertising train */ + } pa_rsp_data_evt; /*!< Event parameter of ESP_GAP_BLE_SET_PERIODIC_ADV_RESPONSE_DATA_EVT */ + /** + * @brief ESP_GAP_BLE_SET_PERIODIC_SYNC_SUBEVT_EVT + */ + struct ble_pa_sync_subevt_evt { + esp_bt_status_t status; /*!< Indicate periodic sync subevent update success status */ + uint16_t sync_handle; /*!< identifying the periodic advertising train */ + } pa_sync_subevt_evt; /*!< Event parameter of ESP_GAP_BLE_SET_PERIODIC_SYNC_SUBEVT_EVT */ + /** + * @brief ESP_GAP_BLE_PERIODIC_ADV_SUBEVT_DATA_REQUEST_EVT + */ + struct ble_pa_subevt_data_req_evt { + uint8_t adv_handle; /*!< Used to identify a periodic advertising train */ + uint8_t subevt_start; /*!< The first subevent that data is requested for.*/ + uint8_t subevt_data_count; /*!< The number of subevents that data is requested for.*/ + } pa_subevt_data_req_evt; /*!< Event parameter of ESP_GAP_BLE_PERIODIC_ADV_SUBEVT_DATA_REQUEST_EVT */ + /** + * @brief ESP_GAP_BLE_PERIODIC_ADV_RESPONSE_REPORT_EVT + */ + struct ble_pa_rsp_rpt_evt { + uint8_t adv_handle; /*!< Used to identify a periodic advertising train */ + uint8_t subevt; /*!< The subevent number */ + uint8_t tx_status; /*!< + 0x00 AUX_SYNC_SUBEVENT_IND packet was transmitted. + 0x01 AUX_SYNC_SUBEVENT_IND packet was not transmitted.*/ + uint8_t num_rsp; /*!< Number of responses in event */ + esp_ble_pa_rsp_info *pa_rsp_info; /*!< response information */ + } pa_rsp_rpt_evt; /*!< Event parameter of ESP_GAP_BLE_PERIODIC_ADV_RESPONSE_REPORT_EVT */ +#endif // #if (CONFIG_BT_BLE_FEAT_PAWR_EN == TRUE) +#if (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE) + /** + * @brief ESP_GAP_BLE_CS_READ_LOCAL_SUPP_CAPS_EVT + */ + struct ble_cs_read_local_supp_caps_evt { + uint8_t status; /*!< Indicate channel sounding read local supported capabilities command successfully completed */ + uint16_t conn_handle; /*!< Connection Handle */ + uint8_t num_config_supported; /*!< Number of CS configurations supported per connection */ + uint16_t max_consecutive_proc_supported; /*!< 0x0000: Support for both a fixed number of consecutive CS procedures and for an indefinite number of CS procedures until termination + 0x0001 to 0xFFFF: Maximum number of consecutive CS procedures supported */ + uint8_t num_ant_supported; /*!< Number of antennas supported */ + uint8_t max_ant_paths_supported; /*!< Maximum number of antenna paths supported */ + uint8_t roles_supported; /*!< bit 0: Initiator + bit 1: Reflector + */ + uint8_t modes_supported; /*!< bit 0: Mode-3*/ + uint8_t rtt_capability; /*!< time-of-flight precision requirement */ + uint8_t rtt_aa_only_n; /*!< 0x00: RTT AA Only not supported + 0x01 to 0xFF: Number of CS steps of single packet exchanges needed to satisfy the precision requirements */ + uint8_t rtt_sounding_n; /*!< 0x00: RTT Sounding not supported + 0x01 to 0xFF: Number of CS steps of single packet exchanges needed to satisfy the precision requirements */ + uint8_t rtt_random_payload_n; /*!< 0x00: RTT Random Payload not supported + 0x01 to 0xFF: Number of CS steps of single packet exchanges needed to satisfy the precision requirements */ + uint16_t NADM_sounding_capability; /*!< bit 0: Support for Phase-based Normalized Attack Detector Metric when a CS_SYNC with sounding sequence is received */ + uint16_t NADM_random_capability; /*!< bit 0: Support for Phase-based Normalized Attack Detector Metric when a CS_SYNC with random sequence is received */ + uint8_t cs_sync_phys_supported; /*!< bit 1: LE 2M PHY + bit 2: LE 2M 2BT PHY + */ + uint16_t subfeatures_supported; /*!< bit 1: CS with no transmitter Frequency Actuation Error + bit 2: CS Channel Selection Algorithm #3c + bit 3: CS phase-based ranging from RTT sounding sequence + */ + uint16_t T_IP1_times_supported; /*!< bit 0: 10 μs supported + bit 1: 20 μs supported + bit 2: 30 μs supported + bit 3: 40 μs supported + bit 4: 50 μs supported + bit 5: 60 μs supported + bit 6: 80 μs supported + */ + uint16_t T_IP2_times_supported; /*!< bit 0: 10 μs supported + bit 1: 20 μs supported + bit 2: 30 μs supported + bit 3: 40 μs supported + bit 4: 50 μs supported + bit 5: 60 μs supported + bit 6: 80 μs supported + */ + uint16_t T_FCS_times_supported; /*!< bit 0: 15 μs supported + bit 1: 20 μs supported + bit 2: 30 μs supported + bit 3: 40 μs supported + bit 4: 50 μs supported + bit 5: 60 μs supported + bit 6: 80 μs supported + bit 7: 100 μs supported + bit 8: 120 μs supported */ + uint16_t T_PM_times_supported; /*!< bit 0: 10 μs supported + bit 1: 20 μs supported + */ + uint8_t T_SW_times_supported; /*!< 0x00, 0x01, 0x02, 0x04, or 0x0A: Time in microseconds for the antenna switch period of the CS tones */ + uint8_t TX_SNR_capability; /*!< bit 0: 18 dB supported + bit 1: 21 dB supported + bit 2: 24 dB supported + bit 3: 27 dB supported + bit 4: 30 dB supported + */ + } cs_read_local_supp_caps; /*!< Event parameter of ESP_GAP_BLE_CS_READ_LOCAL_SUPP_CAPS_EVT */ + /** + * @brief ESP_GAP_BLE_CS_READ_REMOTE_SUPP_CAPS_CMPL_EVT + */ + struct ble_cs_read_remote_supp_caps { + uint8_t status; /*!< 0x00: Channel sounding read remote supported capabilities command successfully completed + other: Channel sounding read remote supported capabilities command failed */ + uint16_t conn_handle; /*!< Connection Handle */ + uint8_t num_config_supported; /*!< Number of CS configurations supported per connection */ + uint16_t max_consecutive_proc_supported; /*!< Maximum number of consecutive CS procedures supported */ + uint8_t num_ant_supported; /*!< Number of antennas supported */ + uint8_t max_ant_paths_supported; /*!< Maximum number of antenna paths supported */ + uint8_t roles_supported; /*!< bit 0: Initiator + bit 1: Reflector */ + uint8_t modes_supported; /*!< bit 0: Mode-3 */ + uint8_t rtt_capability; /*!< Time-of-flight precision requirement */ + uint8_t rtt_aa_only_n; /*!< Number of CS steps of single packet exchanges needed to satisfy the precision requirements */ + uint8_t rtt_sounding_n; /*!< Number of CS steps of single packet exchanges needed to satisfy the precision requirements */ + uint8_t rtt_random_payload_n; /*!< Number of CS steps of single packet exchanges needed to satisfy the precision requirements */ + uint16_t NADM_sounding_capability; /*!< bit 0: Support for Phase-based Normalized Attack Detector Metric when a CS_SYNC with sounding sequence is received */ + uint16_t NADM_random_capability; /*!< bit 0: Support for Phase-based Normalized Attack Detector Metric when a CS_SYNC with random sequence is received*/ + uint8_t cs_sync_phys_supported; /*!< bit 1: LE 2M PHY + bit 2: LE 2M 2BT PHY */ + uint16_t subfeatures_supported; /*!< bit 1: CS with no transmitter Frequency Actuation Error + bit 2: CS Channel Selection Algorithm #3c + bit 3: CS phase-based ranging from RTT sounding sequence + */ + uint16_t T_IP1_times_supported; /*!< bit 0: 10 μs supported + bit 1: 20 μs supported + bit 2: 30 μs supported + bit 3: 40 μs supported + bit 4: 50 μs supported + bit 5: 60 μs supported + bit 6: 80 μs supported + */ + uint16_t T_IP2_times_supported; /*!< bit 0: 10 μs supported + bit 1: 20 μs supported + bit 2: 30 μs supported + bit 3: 40 μs supported + bit 4: 50 μs supported + bit 5: 60 μs supported + bit 6: 80 μs supported + */ + uint16_t T_FCS_times_supported; /*!< bit 0: 15 μs supported + bit 1: 20 μs supported + bit 2: 30 μs supported + bit 3: 40 μs supported + bit 4: 50 μs supported + bit 5: 60 μs supported + bit 6: 80 μs supported + bit 7: 100 μs supported + bit 8: 120 μs supported + */ + uint16_t T_PM_times_supported; /*!< bit 0: 10 μs supported + bit 1: 20 μs supported + */ + uint8_t T_SW_times_supported; /*!< 0x00, 0x01, 0x02, 0x04, or 0x0A: Time in microseconds for the antenna switch period of the CS tones */ + uint8_t TX_SNR_capability; /*!< bit 0: 18 dB supported + bit 1: 21 dB supported + bit 2: 24 dB supported + bit 3: 27 dB supported + bit 4: 30 dB supported + */ + } cs_read_remote_supp_caps; /*!< Event parameter of ESP_GAP_BLE_CS_READ_REMOTE_SUPP_CAPS_CMPL_EVT */ + /** + * @brief ESP_GAP_BLE_CS_WRITE_CACHED_REMOTE_SUPP_CAPS_EVT + */ + struct ble_cs_write_cached_remote_supp_caps { + uint8_t status; /*!< 0x00: Channel sounding write cached remote FAE table command succeeded + 0x01: Channel sounding write cached remote FAE table command failed */ + uint16_t conn_handle; /*!< Connection Handle */ + } cs_write_cached_remote_supp_caps; /*!< Event parameter of ESP_GAP_BLE_CS_WRITE_CACHED_REMOTE_SUPP_CAPS_EVT */ + /** + * @brief ESP_GAP_BLE_CS_SECURITY_ENABLE_CMPL_EVT + */ + struct ble_cs_security_enable { + uint8_t status; /*!< 0x00: Channel sounding security parameters successfully exchanged + other: Channel sounding CS security parameter exchange failed */ + uint16_t conn_handle; /*!< Connection Handle */ + } cs_security_enable; /*!< Event parameter of ESP_GAP_BLE_CS_SECURITY_ENABLE_CMPL_EVT */ + /** + * @brief ESP_GAP_BLE_CS_SET_DEFAULT_SETTINGS_EVT + */ + struct ble_cs_set_default_settings { + uint8_t status; /*!< 0x00: Channel sounding set default settings command successfully completed + other: Channel sounding set default settings command failed*/ + uint16_t conn_handle; /*!< Connection Handle */ + } cs_set_default_settings; /*!< Event parameter of ESP_GAP_BLE_CS_SET_DEFAULT_SETTINGS_EVT */ + /** + * @brief ESP_GAP_BLE_CS_READ_REMOTE_FAE_TABLE_CMPL_EVT + */ + struct ble_cs_read_remote_fae_tab { + uint8_t status; /*!< 0x00: Channel sounding read remote FAE Table command successfully completed + other: Channel sounding read remote FAE Table command failed*/ + uint16_t conn_handle; /*!< Connection Handle */ + uint8_t remote_fae_table[72]; /*!< Per-channel mode-0 Frequency Actuation Error table of the remote Controller */ + } cs_read_remote_fae_tab; /*!< Event parameter of ESP_GAP_BLE_CS_READ_REMOTE_FAE_TABLE_CMPL_EVT */ + /** + * @brief ESP_GAP_BLE_CS_WRITE_CACHED_REMOTE_FAE_TABLE_EVT + */ + struct ble_cs_write_cached_remote_fae_tab { + uint8_t status; /*!< 0x00: Channel sounding write cached remote FAE table command succeeded + other: Channel sounding write cached remote FAE table command failed */ + uint16_t conn_handle; /*!< Connection Handle */ + } cs_write_cached_remote_fae_tab; /*!< Event parameter of ESP_GAP_BLE_CS_WRITE_CACHED_REMOTE_FAE_TABLE_EVT */ + /** + * @brief ESP_GAP_BLE_CS_CONFIG_CMPL_EVT + */ + struct ble_cs_config_udpate { + uint8_t status; /*!< 0x00: Channel Sounding Configuration procedure succeeded + other: Channel Sounding Configuration procedure failed */ + uint16_t conn_handle; /*!< Connection Handle */ + uint8_t config_id; /*!< CS configuration identifier */ + uint8_t action; /*!< 0x00: CS configuration is removed + 0x01: CS configuration is created */ + uint8_t main_mode_type; /*!< 0x01: Mode-1 + 0x02: Mode-2 + 0x03: Mode-3 + */ + uint8_t sub_mode_type; /*!< 0x01: Mode-1 + 0x02: Mode-2 + 0x03: Mode-3 + 0xFF: Unused + */ + uint8_t min_main_mode_steps; /*!< Minimum number of CS main mode steps to be executed before a submode step is executed */ + uint8_t max_main_mode_steps; /*!< Maximum number of CS main mode steps to be executed before a submode step is executed */ + uint8_t main_mode_repetition; /*!< 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 mode_0_steps; /*!< Number of CS mode-0 steps to be included at the beginning of each CS subevent */ + uint8_t role; /*!< 0x00: Initiator + 0x01: Reflector + */ + uint8_t rtt_type; /*!< 0x00: RTT AA Only + 0x01: RTT with 32-bit sounding sequence + 0x02: RTT with 96-bit sounding sequence + 0x03: RTT with 32-bit random sequence + 0x04: RTT with 64-bit random sequence + 0x05: RTT with 96-bit random sequence + 0x06: RTT with 128-bit random sequence + */ + uint8_t cs_sync_phy; /*!< 0x01: LE 1M PHY + 0x02: LE 2M PHY + 0x03: LE 2M 2BT PHY + */ + uint8_t channel_map[ESP_BLE_CS_CHAN_MAP_LEN]; /*!< This parameter contains 80 1-bit fields. + The nth such field (in the range 0 to 78) contains the value for the CS channel index n. + Channel n is enabled for CS procedure = 1 + Channel n is disabled for CS procedure = 0 + Channels n = 0, 1, 23, 24, 25, 77, and 78 shall be ignored and shall be set to zero. At least 15 channels shall be enabled. + The most significant bit (bit 79) is reserved for future use. + */ + uint8_t channel_map_repetition; /*!< The number of times the Channel_Map field will be cycled through for non-mode-0 steps within a CS procedure*/ + uint8_t channel_selection_type; /*!< 0x00: Use Channel Selection Algorithm #3b for non-mode-0 CS steps + 0x01: Use Channel Selection Algorithm #3c for non-mode-0 CS steps + */ + uint8_t ch3c_shape; /*!< 0x00: Use Hat shape for user-specified channel sequence + 0x01: Use X shape for user-specified channel sequence + */ + uint8_t ch3c_jump; /*!< Number of channels skipped in each rising and falling sequence */ + uint8_t reserved; /*!< Reserved, shall be set to 0x00 */ + uint8_t t_ip1_time; /*!< 0x0A, 0x14, 0x1E, 0x28, 0x32, 0x3C, 0x50, or 0x91: Interlude time in microseconds between the RTT packets */ + uint8_t t_ip2_time; /*!< 0x0A, 0x14, 0x1E, 0x28, 0x32, 0x3C, 0x50, or 0x91: nterlude time in microseconds between the CS tones */ + uint8_t t_fcs_time; /*!< 0x0F, 0x14, 0x1E, 0x28, 0x32, 0x3C, 0x50, 0x64, 0x78, or 0x96: Time in microseconds for frequency changes */ + uint8_t t_pm_time; /*!< 0x0A, 0x14, or 0x28: Time in microseconds for the phase measurement period of the CS tones */ + } cs_config_update; /*!< Event parameter of ESP_GAP_BLE_CS_CONFIG_CMPL_EVT */ + /** + * @brief ESP_GAP_BLE_CS_SET_PROC_PARAMS_CMPL_EVT + */ + struct ble_cs_set_proc_params { + uint8_t status; /*!< 0x00: Channel sounding set procedure_Parameters command successful + other: Channel sounding set procedure_Parameters command failed */ + uint16_t conn_handle; /*!< Connection Handle */ + } cs_set_proc_params; /*!< Event parameter of ESP_GAP_BLE_CS_SET_PROC_PARAMS_CMPL_EVT */ + /** + * @brief ESP_GAP_BLE_CS_SET_CHANNEL_CLASS_CMPL_EVT + */ + struct ble_cs_set_channel_class { + uint8_t status; /*!< 0x00: Channel sounding set channel classification command successful + other: Channel sounding set channel classification command failed */ + } cs_set_channel_class; /*!< Event parameter of ESP_GAP_BLE_CS_SET_CHANNEL_CLASS_CMPL_EVT */ + /** + * @brief ESP_GAP_BLE_CS_PROC_ENABLE_CMPL_EVT + */ + struct ble_cs_proc_enable { + uint8_t status; /*!< 0x00: Channel sounding procedure enable command successful + other: Channel sounding procedure enable command failed */ + uint16_t conn_handle; /*!< Connection Handle */ + uint8_t config_id; /*!< CS configuration identifier */ + uint8_t state; /*!< 0x00: CS procedures are disabled + 0x01: CS procedures are enabled + */ + uint8_t tone_ant_config_select; /*!< Antenna Configuration Index. Range:0x00 to 0x07*/ + int8_t select_tx_power; /*!< Transmit power level used for CS procedure. Range: -127 to 20. Units: dBm */ + uint32_t subevent_Len; /*!< Duration for each CS subevent in microseconds. Range: 1250 μs to 4 s */ + uint8_t subevents_per_event; /*!< Number of CS subevents anchored off the same ACL connection event. Range: 0x01 to 0x20 */ + uint16_t subevent_interval; /*!< Time between consecutive CS subevents anchored off the same ACL connection event. Units: 0.625 ms */ + uint16_t event_interval; /*!< Number of ACL connection events between consecutive CS event anchor points */ + uint16_t procedure_interval; /*!< Number of ACL connection events between consecutive CS procedure anchor points */ + uint16_t procedure_count; /*!< 0x0000: CS procedures to continue until disabled + other: Number of CS procedures to be scheduled */ + uint16_t max_procedure_len; /*!< Maximum duration for each CS procedure. Range: 0x0001 to 0xFFFF. Time = N × 0.625 ms. Time range: 0.625 ms to 40.959375 s */ + } cs_proc_enable; /*!< Event parameter of ESP_GAP_BLE_CS_PROC_ENABLE_CMPL_EVT */ + /** + * @brief ESP_GAP_BLE_CS_SUBEVENT_RESULT_EVT + */ + struct ble_cs_subevt_result { + uint16_t conn_handle; /*!< 0x0000 to 0x0EFF: Connection Handle + 0x0FFF: CS test + */ + uint8_t config_id; /*!< CS configuration identifier. Range: 0 to 3 */ + uint16_t start_acl_conn_event_counter; /*!< Starting ACL connection event counter for the results reported in the event */ + uint16_t procedure_counter; /*!< CS procedure count since completion of the Channel Sounding Security Start procedure. Range: 0x0000 to 0xFFFF */ + int16_t frequency_compensation; /*!< 0xC000: Frequency compensation value is not available, or the role is not initiator + other: Frequency compensation value in units of 0.01 ppm (15-bit signed integer). Range: -100 ppm (0x58F0) to +100 ppm (0x2710). Units: 0.01 ppm */ + int8_t reference_power_level; /*!< 0x7F: Reference power level is not applicable + other: Reference power level. Range: -127 to 20. Units: dBm */ + uint8_t procedure_done_status; /*!< bit 0 to 3: + 0x0 = All results complete for the CS procedure + 0x1 = Partial results with more to follow for the CS procedure + 0xF = All subsequent CS procedures aborted + All other values = Reserved for future use + bit 4 to 7: + Reserved for future use + */ + uint8_t subevent_done_status; /*!< bit 0 to 3: + 0x0 = All results complete for the CS subevent + 0x1 = Partial results with more to follow for the CS subevent + 0xF = Current CS subevent aborted + All other values = Reserved for future use + bit 4 to 7: + Reserved for future use + */ + uint8_t abort_reason; /*!< bit 0 to 3: + Indicates the abort reason when Procedure_Done_Status is set to 0xF, otherwise the default value is set to zero. + 0x0 = Report with no abort + 0x1 = Abort because of local Host or remote request + 0x2 = Abort because filtered channel map has less than 15 channels + 0x3 = Abort because the channel map update instant has passed + 0xF = Abort because of unspecified reasons + All other values = Reserved for future use + bit 4 to 7: + Indicates the abort reason when Subevent_Done_Status is set to 0xF, otherwise the default value is set to zero. + 0x0 = Report with no abort + 0x1 = Abort because of local Host or remote request + 0x2 = Abort because no CS_SYNC (mode-0) received + 0x3 = Abort because of scheduling conflicts or limited resources + 0xF = Abort because of unspecified reasons + All other values = Reserved for future use + */ + uint8_t num_ant_paths; /*!< 0x00: Ignored because phase measurement does not occur during the CS step + 0x01 to 0x04: Number of antenna paths used during the phase measurement stage of the CS step */ + uint8_t num_steps_reported; /*!< 0x00 to 0xA0: Number of steps in the CS subevent for which results are reported */ + esp_ble_cs_step_info *step_info; /*!< steps information in the CS subevent */ + } cs_subevt_result; /*!< Event parameter of ESP_GAP_BLE_CS_SUBEVENT_RESULT_EVT */ + /** + * @brief ESP_GAP_BLE_CS_SUBEVENT_RESULT_CONTINUE_EVT + */ + struct ble_cs_subevt_result_continue { + uint16_t conn_handle; /*!< 0x0000 to 0x0EFF: Connection Handle + 0x0FFF: CS test + */ + uint8_t config_id; /*!< CS configuration identifier. Range: 0 to 3 */ + uint8_t proc_done_status; /*!< bit 0 to 3: + 0x0 = All results complete for the CS procedure + 0x1 = Partial results with more to follow for the CS procedure + 0xF = All subsequent CS procedures aborted + All other values = Reserved for future use + bit 4 to 7: + Reserved for future use + */ + uint8_t subevt_done_status; /*!< bit 0 to 3: + 0x0 = All results complete for the CS subevent + 0x1 = Partial results with more to follow for the CS subevent + 0xF = Current CS subevent aborted + All other values = Reserved for future use + bit 4 to 7: + Reserved for future use + */ + uint8_t abort_reason; /*!< bit 0 to 3: + Indicates the abort reason when Procedure_Done_Status is set to 0xF, otherwise the default value is set to zero. + 0x0 = Report with no abort + 0x1 = Abort because of local Host or remote request + 0x2 = Abort because filtered channel map has less than 15 channels + 0x3 = Abort because the channel map update instant has passed + 0xF = Abort because of unspecified reasons + All other values = Reserved for future use + bit 4 to 7: + Indicates the abort reason when Subevent_Done_Status is set to 0xF, otherwise the default value is set to zero. + 0x0 = Report with no abort + 0x1 = Abort because of local Host or remote request + 0x2 = Abort because no CS_SYNC (mode-0) received + 0x3 = Abort because of scheduling conflicts or limited resources + 0xF = Abort because of unspecified reasons + All other values = Reserved for future use + */ + uint8_t num_ant_paths; /*!< 0x00: Ignored because phase measurement does not occur during the CS step + 0x01 to 0x04: Number of antenna paths used during the phase measurement stage of the CS step + */ + uint8_t num_steps_reported; /*!< Number of steps in the CS subevent for which results are reported, Range: 0x00 to 0xA0 */ + esp_ble_cs_step_info *step_info; /*!< steps information in the CS subevent */ + } cs_subevt_result_continue; /*!< Event parameter of ESP_GAP_BLE_CS_SUBEVENT_RESULT_CONTINUE_EVT */ +#endif // (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE) } esp_ble_gap_cb_param_t; /** @@ -3317,6 +4231,213 @@ esp_err_t esp_ble_gap_subrate_request(esp_ble_subrate_req_param_t *subrate_req_p */ esp_err_t esp_ble_gap_set_host_feature(uint16_t bit_num, uint8_t bit_val); +/** + * @brief This function is used to set the data for one or more subevents of PAwR in reply to a PA subevent data request event. + * The data for a subevent shall be transmitted only once. + * + * + * @param[in] subevent_data_params: Periodic adv subevent data parameters. + * + * + * @return + * - ESP_OK : success + * - other : failed + * + */ +esp_err_t esp_ble_gap_set_periodic_adv_subevent_data(esp_ble_per_adv_subevent_data_params *subevent_data_params); + +/** + * @brief This function is used to set the data for a response slot in a specific subevent of the PAwR identified. + * The data for a response slot shall be transmitted only once. + * + * + * @param[in] rsp_data_params: Periodic adv response data parameters. + * + * + * @return + * - ESP_OK : success + * - other : failed + */ +esp_err_t esp_ble_gap_set_periodic_adv_response_data(esp_ble_per_adv_response_data_params *rsp_data_params); + +/** + * @brief This function is used to instruct the Controller to synchronize with a subset of the subevents within a PAwR train, + * listen for packets sent by the peer device and pass any received data up to the Host. + * + * + * @param[in] sync_subevent_params: Periodic sync subevent parameters. + * + * + * @return + * - ESP_OK : success + * - other : failed + */ +esp_err_t esp_ble_gap_set_periodic_sync_subevent(esp_ble_per_sync_subevent_params *sync_subevent_params); + +/** + * @brief This function is used to read the CS capabilities that are supported by the local Controller + * + * + * @return + * - ESP_OK : success + * - other : failed + */ +esp_err_t esp_ble_cs_read_local_supported_capabilities(void); + +/** + * @brief This function is used to query the CS capabilities that are supported by the remote Controller + * + * + * + * @param[in] conn_handle: connection handle. + * + * + * @return + * - ESP_OK : success + * - other : failed + */ +esp_err_t esp_ble_cs_read_remote_supported_capabilities(uint16_t conn_handle); + +/** + * @brief This function is used to write the cached copy of the CS capabilities that are supported by the remote Controller + * + * + * + * @param[in] cached_remote_supp_caps_params: CS write cached remote supported capabilities parameters + * + * + * @return + * - ESP_OK : success + * - other : failed + */ +esp_err_t esp_ble_cs_write_cached_remote_supported_capabilities(esp_ble_cs_write_cached_remote_supp_caps_params *cached_remote_supp_caps_params); + +/** + * @brief This function is used to start or restart the Channel Sounding Security Start procedure in the local Controller + * + * + * + * @param[in] conn_handle: the ACL connection identified + * + * + * @return + * - ESP_OK : success + * - other : failed + */ +esp_err_t esp_ble_cs_security_enable(uint16_t conn_handle); + +/** + * @brief This function is used to set default CS settings in the local Controller + * + * + * + * @param[in] default_setting_params: CS set default settings parameters + * + * + * @return + * - ESP_OK : success + * - other : failed + */ +esp_err_t esp_ble_cs_set_default_settings(esp_ble_cs_set_default_settings_params *default_setting_params); + +/** + * @brief This function is used to read the per-channel mode-0 Frequency Actuation Error table of the remote Controller + * + * + * + * @param[in] conn_handle: the ACL connection identified + * + * + * @return + * - ESP_OK : success + * - other : failed + */ +esp_err_t esp_ble_cs_read_remote_fae_table(uint16_t conn_handle); + +/** + * @brief This function is used to write a cached copy of the per-channel mode-0 Frequency Actuation Error table of the remote device in the local Controller + * + * + * + * @param[in] write_cached_remote_fae_tab_params: CS write cached remote FAE table parameters + * + * + * @return + * - ESP_OK : success + * - other : failed + */ +esp_err_t esp_ble_cs_write_cached_remote_fae_table(esp_ble_cs_write_cached_remote_fae_table_params *write_cached_remote_fae_tab_params); + +/** + * @brief This function is used to create a new CS configuration or update an existing CS configuration in the local and/or the remote Controller + * + * + * + * @param[in] create_config_params: CS create config parameters + * + * + * @return + * - ESP_OK : success + * - other : failed + */ +esp_err_t esp_ble_cs_create_config(esp_ble_cs_create_config_params *create_config_params); + +/** + * @brief This function is used to remove a CS configuration from the local Controller + * + * + * + * @param[in] remove_config_params: CS remove config parameters + * + * + * @return + * - ESP_OK : success + * - other : failed + */ +esp_err_t esp_ble_cs_remove_config(esp_ble_cs_remove_config_params *remove_config_params); + +/** + * @brief This function is used to update the channel classification based on its local information + * + * + * + * @param[in] channel_class_params: CS set channel classification parameters + * + * + * @return + * - ESP_OK : success + * - other : failed + */ +esp_err_t esp_ble_cs_set_channel_classification(esp_ble_cs_set_channel_class_params *channel_class_params); + +/** + * @brief This function is used to set the parameters for the scheduling of one or more CS procedures by the local Controller + * + * + * + * @param[in] procedure_params: CS set channel procedure parameters + * + * + * @return + * - ESP_OK : success + * - other : failed + */ +esp_err_t esp_ble_cs_set_procedure_params(esp_ble_cs_set_proc_params *procedure_params); + +/** + * @brief This function is used to enable or disable the scheduling of CS procedures by the local Controller + * + * + * + * @param[in] procedure_enable_params: CS procedure enable parameters + * + * + * @return + * - ESP_OK : success + * - other : failed + */ +esp_err_t esp_ble_cs_procedure_enable(esp_ble_cs_procedure_enable_params *procedure_enable_params); + #ifdef __cplusplus } #endif diff --git a/components/bt/host/bluedroid/api/include/api/esp_gatt_defs.h b/components/bt/host/bluedroid/api/include/api/esp_gatt_defs.h index e8cc134ca7..dcbfe2f6eb 100644 --- a/components/bt/host/bluedroid/api/include/api/esp_gatt_defs.h +++ b/components/bt/host/bluedroid/api/include/api/esp_gatt_defs.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -695,6 +695,19 @@ typedef struct { const esp_ble_conn_params_t *phy_coded_conn_params; /*!< Connection parameters for the LE Coded PHY */ } esp_ble_gatt_creat_conn_params_t; +/** @brief Represents a creat connection element. */ +typedef struct { + esp_bd_addr_t remote_bda; /*!< The Bluetooth address of the remote device */ + esp_ble_addr_type_t remote_addr_type; /*!< Address type of the remote device */ + esp_ble_addr_type_t own_addr_type; /*!< Specifies the address type used in the connection request. Set to 0xFF if the address type is unknown. */ + uint8_t adv_handle; /*!< Advertising_Handle identifying the periodic advertising train. Range: 0x00 to 0xEF or 0xFF */ + uint8_t subevent; /*!< Subevent where the connection request is to be sent. Range: 0x00 to 0x7F or 0xFF */ + esp_ble_phy_mask_t phy_mask; /*!< Indicates which PHY connection parameters will be used. When is_aux is false, only the connection params for 1M PHY can be specified */ + const esp_ble_conn_params_t *phy_1m_conn_params; /*!< Connection parameters for the LE 1M PHY */ + const esp_ble_conn_params_t *phy_2m_conn_params; /*!< Connection parameters for the LE 2M PHY */ + const esp_ble_conn_params_t *phy_coded_conn_params; /*!< Connection parameters for the LE Coded PHY */ +} esp_ble_gatt_pawr_conn_params_t; + #ifdef __cplusplus } #endif diff --git a/components/bt/host/bluedroid/bta/dm/bta_dm_act.c b/components/bt/host/bluedroid/bta/dm/bta_dm_act.c index fd7d665acc..724ea7c67a 100644 --- a/components/bt/host/bluedroid/bta/dm/bta_dm_act.c +++ b/components/bt/host/bluedroid/bta/dm/bta_dm_act.c @@ -6347,6 +6347,106 @@ void bta_dm_ble_set_host_feature(tBTA_DM_MSG *p_data) } #endif // #if (BLE_50_FEATURE_SUPPORT == TRUE) +#if (BT_BLE_FEAT_PAWR_EN == TRUE) +void bta_dm_api_set_periodic_adv_subevt_data(tBTA_DM_MSG *p_data) +{ + BTM_BleSetPaSubeventData(p_data->pa_subevt_data.adv_handle, p_data->pa_subevt_data.num_subevents_with_data, (uint8_t *)(p_data->pa_subevt_data.subevent_params)); +} + +void bta_dm_api_set_periodic_adv_response_data(tBTA_DM_MSG *p_data) +{ + BTM_BleSetPaResponseData(p_data->pa_rsp_data.sync_handle, p_data->pa_rsp_data.request_event, p_data->pa_rsp_data.request_subevent, + p_data->pa_rsp_data.rsp_subevent, p_data->pa_rsp_data.rsp_slot, p_data->pa_rsp_data.rsp_data_len, + p_data->pa_rsp_data.rsp_data); +} + +void bta_dm_api_set_periodic_sync_subevt(tBTA_DM_MSG *p_data) +{ + BTM_BleSetPaSyncSubevt(p_data->pa_sync_subevt.sync_handle, p_data->pa_sync_subevt.periodic_adv_properties, p_data->pa_sync_subevt.num_subevents_to_sync, p_data->pa_sync_subevt.subevent); +} +#endif // #if (BT_BLE_FEAT_PAWR_EN == TRUE) + +#if (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE) +void bta_dm_api_cs_read_local_supported_caps(tBTA_DM_MSG *p_data) +{ + BTM_BleCSReadLocalSuppCaps(); +} + +void bta_dm_api_cs_read_remote_supported_caps(tBTA_DM_MSG *p_data) +{ + BTM_BleCSReadRemoteSuppCaps(p_data->read_remote_supp_caps.conn_handle); +} + +void bta_dm_api_cs_write_cached_remote_supported_caps(tBTA_DM_MSG *p_data) +{ + tBTA_DM_API_CS_WRITE_CACHED_REMOTE_SUPP_CAPS *p = &p_data->write_cached_remote_caps; + BTM_BleGapWriteCachedRemoteSupportedCaps(p->conn_handle, p->num_config_supported, p->max_consecutive_proc_supported, + p->num_ant_supported, p->max_ant_paths_supported, p->roles_supported, + p->modes_supported, p->rtt_capability, p->rtt_aa_only_n, + p->rtt_sounding_n, p->rtt_random_payload_n, p->NADM_sounding_capability, + p->NADM_random_capability, p->cs_sync_phys_supported, p->subfeatures_supported, + p->T_IP1_times_supported, p->T_IP2_times_supported, p->T_FCS_times_supported, + p->T_PM_times_supported, p->T_SW_times_supported, p->TX_SNR_capability); +} + +void bta_dm_api_cs_security_enable(tBTA_DM_MSG *p_data) +{ + BTM_BleGapCsSecurityEnable(p_data->security_enable.conn_handle); +} + +void bta_dm_api_cs_set_default_settings(tBTA_DM_MSG *p_data) +{ + BTM_BleGapCsSetDefaultSetting(p_data->set_default_setting_params.conn_handle, p_data->set_default_setting_params.role_enable, + p_data->set_default_setting_params.cs_sync_ant_selection, p_data->set_default_setting_params.max_tx_power); +} + +void bta_dm_api_cs_read_remote_fae_table(tBTA_DM_MSG *p_data) +{ + BTM_BleGapCsReadRemoteFaeTable(p_data->read_remote_tab.conn_handle); +} + +void bta_dm_api_cs_write_cached_remote_fae_table(tBTA_DM_MSG *p_data) +{ + BTM_BleGapWriteCachedRemoteFaeTable(p_data->write_cached_remote_fae_tab_params.conn_handle, p_data->write_cached_remote_fae_tab_params.remote_fae_table); +} + +void bta_dm_api_cs_create_config(tBTA_DM_MSG *p_data) +{ + tBTA_DM_API_CS_CREATE_CONFIG_PARAMS *p = &p_data->create_config_params; + BTM_BleGapCsCreateConfig(p->conn_handle, p->config_id, p->create_context, + p->main_mode_type, p->sub_mode_type, p->min_main_mode_steps, + p->max_main_mode_steps, p->main_mode_repetition, p->mode_0_steps, + p->role, p->rtt_type, p->cs_sync_phy, &p->channel_map[0], + p->channel_map_repetition, p->channel_selection_type, p->ch3c_shape, + p->ch3c_jump, p->reserved); +} + +void bta_dm_api_cs_remove_config(tBTA_DM_MSG *p_data) +{ + BTM_BleGapCsRemoveConfig(p_data->remove_config_params.conn_handle, p_data->remove_config_params.config_id); +} + +void bta_dm_api_cs_set_channel_classification(tBTA_DM_MSG *p_data) +{ + BTM_BleGapCsSetChannelClass(p_data->set_channel_class_params.channel_class); +} +void bta_dm_api_cs_set_procedure_params(tBTA_DM_MSG *p_data) +{ + tBTA_DM_API_CS_SET_PROC_PARAMS *p = &p_data->set_proc_params; + BTM_BleGapCsSetProcPatams(p->conn_handle, p->config_id, p->max_procedure_len, + p->min_procedure_interval, p->max_procedure_interval, + p->max_procedure_count, p->min_subevent_len, + p->max_subevent_len, p->tone_ant_config_selection, + p->phy, p->tx_power_delta, p->preferred_peer_antenna, + p->SNR_control_initiator, p->SNR_control_reflector); +} + +void bta_dm_api_cs_procedure_enable(tBTA_DM_MSG *p_data) +{ + BTM_BleGapCsProcEnable(p_data->proc_enable_params.conn_handle, p_data->proc_enable_params.config_id, p_data->proc_enable_params.enable); +} +#endif // (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE) + #if (BLE_HOST_SETUP_STORAGE_EN == TRUE) /******************************************************************************* ** @@ -6942,7 +7042,7 @@ void btm_dm_start_gatt_discovery (BD_ADDR bd_addr) } else { //TODO need to add addr_type in future BTA_GATTC_Enh_Open(bta_dm_search_cb.client_if, bd_addr, BLE_ADDR_UNKNOWN_TYPE, TRUE, - BTA_GATT_TRANSPORT_LE, FALSE, BLE_ADDR_UNKNOWN_TYPE, 0, NULL, NULL, NULL); + BTA_GATT_TRANSPORT_LE, FALSE, BLE_ADDR_UNKNOWN_TYPE, false, 0xFF, 0xFF, 0, NULL, NULL, NULL); } } diff --git a/components/bt/host/bluedroid/bta/dm/bta_dm_api.c b/components/bt/host/bluedroid/bta/dm/bta_dm_api.c index 08510894e6..cd06eb4fd1 100644 --- a/components/bt/host/bluedroid/bta/dm/bta_dm_api.c +++ b/components/bt/host/bluedroid/bta/dm/bta_dm_api.c @@ -3169,6 +3169,217 @@ void BTA_DmBleGapSetHostFeature(uint16_t bit_num, uint8_t bit_val) } #endif // #if (BLE_50_FEATURE_SUPPORT == TRUE) +#if (BT_BLE_FEAT_PAWR_EN == TRUE) +void BTA_DmBleGapSetPASubevtData(uint8_t adv_handle, uint8_t num_subevents_with_data, uint8_t *subevent_params) +{ + tBTA_DM_API_BLE_PA_SUBEVENT_DATA *p_msg; + tBTA_BLE_SUBEVENT_PARAMS *p_subevent_params = (tBTA_BLE_SUBEVENT_PARAMS*)subevent_params; + + if ((p_msg = (tBTA_DM_API_BLE_PA_SUBEVENT_DATA *)osi_malloc(sizeof(tBTA_DM_API_BLE_PA_SUBEVENT_DATA) + num_subevents_with_data * sizeof(tBTA_DM_API_BLE_SUBEVENT_PARAMS))) + != NULL) { + p_msg->hdr.event = BTA_DM_API_SET_PA_SUBEVT_DATA; + p_msg->adv_handle = adv_handle; + p_msg->num_subevents_with_data = num_subevents_with_data; + p_msg->subevent_params = (tBTA_DM_API_BLE_SUBEVENT_PARAMS *)(p_msg + 1); + for (uint8_t i = 0; i < num_subevents_with_data; i++) + { + p_msg->subevent_params[i].subevent = p_subevent_params[i].subevent; + p_msg->subevent_params[i].response_slot_start = p_subevent_params[i].response_slot_start; + p_msg->subevent_params[i].response_slot_count = p_subevent_params[i].response_slot_count; + p_msg->subevent_params[i].subevent_data_len = p_subevent_params[i].subevent_data_len; + memcpy(&(p_msg->subevent_params[i].subevent_data), p_subevent_params[i].subevent_data, p_subevent_params[i].subevent_data_len); + } + + bta_sys_sendmsg(p_msg); + } +} + +void BTA_DmBleGapSetPeriodicAdvRspData(uint16_t sync_handle, uint16_t request_event, uint8_t request_subevent, + uint8_t rsp_subevent, uint8_t rsp_slot, uint8_t rsp_data_len, uint8_t *rsp_data) +{ + tBTA_DM_API_BLE_PA_RSP_DATA *p_msg; + + if ((p_msg = (tBTA_DM_API_BLE_PA_RSP_DATA *)osi_malloc(sizeof(tBTA_DM_API_BLE_PA_RSP_DATA) + rsp_data_len)) + != NULL) { + p_msg->hdr.event = BTA_DM_API_SET_PA_RSP_DATA; + p_msg->sync_handle = sync_handle; + p_msg->request_event = request_event; + p_msg->request_subevent = request_subevent; + p_msg->rsp_subevent = rsp_subevent; + p_msg->rsp_slot = rsp_slot; + p_msg->rsp_data_len = rsp_data_len; + p_msg->rsp_data = (UINT8 *)(p_msg + 1); + if (rsp_data_len && rsp_data) { + memcpy(p_msg->rsp_data, rsp_data, rsp_data_len); + } else if (rsp_data_len) { + APPL_TRACE_ERROR("%s rsp_data is NULL", __func__); + } + bta_sys_sendmsg(p_msg); + } +} + +void BTA_DmBleGapSetPeriodicSyncSubevt(uint16_t sync_handle, uint16_t periodic_adv_properties, uint8_t num_subevents_to_sync, uint8_t *subevent) +{ + tBTA_DM_API_BLE_PA_SYNC_SUBEVT *p_msg; + + if ((p_msg = (tBTA_DM_API_BLE_PA_SYNC_SUBEVT *)osi_malloc(sizeof(tBTA_DM_API_BLE_PA_SYNC_SUBEVT) + num_subevents_to_sync)) + != NULL) { + p_msg->hdr.event = BTA_DM_API_SET_PA_SYNC_SUBEVT; + p_msg->sync_handle = sync_handle; + p_msg->periodic_adv_properties = periodic_adv_properties; + p_msg->num_subevents_to_sync = num_subevents_to_sync; + p_msg->subevent = (UINT8 *)(p_msg + 1); + if (num_subevents_to_sync && subevent) { + memcpy(p_msg->subevent, subevent, num_subevents_to_sync); + } else if (num_subevents_to_sync) { + APPL_TRACE_ERROR("%s subevent is NULL", __func__); + } + bta_sys_sendmsg(p_msg); + } +} + +#endif // #if (BT_BLE_FEAT_PAWR_EN == TRUE) + +#if (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE) +void BTA_DmBleGapReadLocalSupportedCaps(void) +{ + tBTA_DM_API_CS_READ_LOCAL_SUPP_CAPS *p_msg; + + if ((p_msg = (tBTA_DM_API_CS_READ_LOCAL_SUPP_CAPS *)osi_malloc(sizeof(tBTA_DM_API_CS_READ_LOCAL_SUPP_CAPS))) != NULL) { + p_msg->hdr.event = BTA_DM_API_CS_READ_LOCAL_SUPPORTED_CAPS; + bta_sys_sendmsg(p_msg); + } +} + +void BTA_DmBleGapReadRemoteSupportedCaps(uint16_t conn_handle) +{ + tBTA_DM_API_CS_READ_REMOTE_SUPP_CAPS *p_msg; + + if ((p_msg = (tBTA_DM_API_CS_READ_REMOTE_SUPP_CAPS *)osi_malloc(sizeof(tBTA_DM_API_CS_READ_REMOTE_SUPP_CAPS))) != NULL) { + p_msg->hdr.event = BTA_DM_API_CS_READ_REMOTE_SUPPORTED_CAPS; + p_msg->conn_handle = conn_handle; + bta_sys_sendmsg(p_msg); + } +} + +void BTA_DmBleGapWriteCachedRemoteSupportedCaps(tBTA_DM_CS_WRITE_CACHED_REMOTE_SUPP_CAPS *write_cachedremote_supp_caps) +{ + tBTA_DM_API_CS_WRITE_CACHED_REMOTE_SUPP_CAPS *p_msg; + + if ((p_msg = (tBTA_DM_API_CS_WRITE_CACHED_REMOTE_SUPP_CAPS *)osi_malloc(sizeof(tBTA_DM_API_CS_WRITE_CACHED_REMOTE_SUPP_CAPS))) != NULL) { + p_msg->hdr.event = BTA_DM_API_CS_WRITE_CACHED_REMOTE_SUPPORTED_CAPS; + memcpy(&p_msg->conn_handle, &write_cachedremote_supp_caps->conn_handle, sizeof(tBTA_DM_CS_WRITE_CACHED_REMOTE_SUPP_CAPS)); + bta_sys_sendmsg(p_msg); + } +} + +void BTA_DmBleGapCsSecurityEnable(uint16_t conn_handle) +{ + tBTA_DM_API_CS_SECURITY_ENABLE *p_msg; + + if ((p_msg = (tBTA_DM_API_CS_SECURITY_ENABLE *)osi_malloc(sizeof(tBTA_DM_API_CS_SECURITY_ENABLE))) != NULL) { + p_msg->hdr.event = BTA_DM_API_CS_SECURITY_ENABLE; + p_msg->conn_handle = conn_handle; + bta_sys_sendmsg(p_msg); + } +} + +void BTA_DmBleGapCsSetDefaultSetting(uint16_t conn_handle, uint8_t role_enable, uint8_t cs_sync_ant_selection, int8_t max_tx_power) +{ + tBTA_DM_API_CS_SET_DEFAULT_SETTING_PARAMS *p_msg; + + if ((p_msg = (tBTA_DM_API_CS_SET_DEFAULT_SETTING_PARAMS *)osi_malloc(sizeof(tBTA_DM_API_CS_SET_DEFAULT_SETTING_PARAMS))) != NULL) { + p_msg->hdr.event = BTA_DM_API_CS_SET_DEFAULT_SETTINGS; + p_msg->conn_handle = conn_handle; + p_msg->role_enable = role_enable; + p_msg->cs_sync_ant_selection = cs_sync_ant_selection; + p_msg->max_tx_power = max_tx_power; + bta_sys_sendmsg(p_msg); + } +} +void BTA_DmBleGapCsReadRemoteFaeTable(uint16_t conn_handle) +{ + tBTA_DM_API_CS_READ_REMOTE_TAB *p_msg; + + if ((p_msg = (tBTA_DM_API_CS_READ_REMOTE_TAB *)osi_malloc(sizeof(tBTA_DM_API_CS_READ_REMOTE_TAB))) != NULL) { + p_msg->hdr.event = BTA_DM_API_CS_READ_REMOTE_FAE_TABLE; + p_msg->conn_handle = conn_handle; + bta_sys_sendmsg(p_msg); + } +} + +void BTA_DmBleGapWriteCachedRemoteFaeTable(uint16_t conn_handle, uint8_t *remote_fae_table, uint8_t table_len) +{ + tBTA_DM_API_CS_WRITE_CACHED_REMOTE_FAE_TAB_PARAMS *p_msg; + + if ((p_msg = (tBTA_DM_API_CS_WRITE_CACHED_REMOTE_FAE_TAB_PARAMS *)osi_malloc(sizeof(tBTA_DM_API_CS_WRITE_CACHED_REMOTE_FAE_TAB_PARAMS))) != NULL) { + p_msg->hdr.event = BTA_DM_API_CS_WRITE_CACHED_REMOTE_FAE_TABLE; + p_msg->conn_handle = conn_handle; + memcpy(&p_msg->remote_fae_table[0], remote_fae_table, table_len); + bta_sys_sendmsg(p_msg); + } +} + +void BTA_DmBleGapCsCreateConfig(tBTA_DM_CS_CREATE_CONFIG_PARAMS *create_config_params) +{ + tBTA_DM_API_CS_CREATE_CONFIG_PARAMS *p_msg; + + if ((p_msg = (tBTA_DM_API_CS_CREATE_CONFIG_PARAMS *)osi_malloc(sizeof(tBTA_DM_API_CS_CREATE_CONFIG_PARAMS))) != NULL) { + p_msg->hdr.event = BTA_DM_API_CS_CREATE_CONFIG; + memcpy(&p_msg->conn_handle, &create_config_params->conn_handle, sizeof(tBTA_DM_CS_CREATE_CONFIG_PARAMS)); + bta_sys_sendmsg(p_msg); + } +} + +void BTA_DmBleGapCsRemoveConfig(uint16_t conn_handle, uint8_t config_id) +{ + tBTA_DM_API_CS_REMOVE_CONFIG_PARAMS *p_msg; + + if ((p_msg = (tBTA_DM_API_CS_REMOVE_CONFIG_PARAMS *)osi_malloc(sizeof(tBTA_DM_API_CS_REMOVE_CONFIG_PARAMS))) != NULL) { + p_msg->hdr.event = BTA_DM_API_CS_REMOVE_CONFIG; + p_msg->conn_handle = conn_handle; + p_msg->config_id = config_id; + bta_sys_sendmsg(p_msg); + } +} + +void BTA_DmBleGapCsSetChannelClass(uint8_t *channel_class, uint8_t channl_len) +{ + tBTA_DM_API_CS_SET_CHANNEL_CLASS_PARAMS *p_msg; + + if ((p_msg = (tBTA_DM_API_CS_SET_CHANNEL_CLASS_PARAMS *)osi_malloc(sizeof(tBTA_DM_API_CS_SET_CHANNEL_CLASS_PARAMS))) != NULL) { + p_msg->hdr.event = BTA_DM_API_CS_SET_CAHNNEL_CLASSIFICATION; + memcpy(&p_msg->channel_class[0], channel_class, channl_len); + bta_sys_sendmsg(p_msg); + } +} + +void BTA_DmBleGapCsSetProcPatams(tBTA_DM_CS_SET_PROC_PARAMS *set_proc_params) +{ + tBTA_DM_API_CS_SET_PROC_PARAMS *p_msg; + + if ((p_msg = (tBTA_DM_API_CS_SET_PROC_PARAMS *)osi_malloc(sizeof(tBTA_DM_API_CS_SET_PROC_PARAMS))) != NULL) { + p_msg->hdr.event = BTA_DM_API_CS_SET_PROCEDURE_PARAMS; + memcpy(&p_msg->conn_handle, &set_proc_params->conn_handle, sizeof(tBTA_DM_CS_SET_PROC_PARAMS)); + bta_sys_sendmsg(p_msg); + } +} + +void BTA_DmBleGapCsProcEnable(uint16_t conn_handle, uint8_t config_id, uint8_t enable) +{ + tBTA_DM_API_CS_PROC_ENABLE_PARAMS *p_msg; + + if ((p_msg = (tBTA_DM_API_CS_PROC_ENABLE_PARAMS *)osi_malloc(sizeof(tBTA_DM_API_CS_PROC_ENABLE_PARAMS))) != NULL) { + p_msg->hdr.event = BTA_DM_API_CS_PROCEDURE_ENABLE; + p_msg->conn_handle = conn_handle; + p_msg->config_id = config_id; + p_msg->enable = enable; + bta_sys_sendmsg(p_msg); + } +} + +#endif // (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE) + /******************************************************************************* ** ** Function BTA_VendorInit diff --git a/components/bt/host/bluedroid/bta/dm/bta_dm_main.c b/components/bt/host/bluedroid/bta/dm/bta_dm_main.c index 9fe5e7696e..77bc60a7f2 100644 --- a/components/bt/host/bluedroid/bta/dm/bta_dm_main.c +++ b/components/bt/host/bluedroid/bta/dm/bta_dm_main.c @@ -344,6 +344,25 @@ const tBTA_DM_ACTION bta_dm_action[BTA_DM_MAX_EVT] = { #if (BLE_50_FEATURE_SUPPORT == TRUE) bta_dm_ble_set_host_feature, /* BTA_DM_API_SET_HOST_FEATURE_EVT */ #endif // #if (BLE_50_FEATURE_SUPPORT == TRUE) +#if (BT_BLE_FEAT_PAWR_EN == TRUE) + bta_dm_api_set_periodic_adv_subevt_data, /* BTA_DM_API_SET_PA_SUBEVT_DATA */ + bta_dm_api_set_periodic_adv_response_data, /* BTA_DM_API_SET_PA_RSP_DATA */ + bta_dm_api_set_periodic_sync_subevt, /* BTA_DM_API_SET_PA_SYNC_SUBEVT */ +#endif // #if (BT_BLE_FEAT_PAWR_EN == TRUE) +#if (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE) + bta_dm_api_cs_read_local_supported_caps, /* BTA_DM_API_CS_READ_LOCAL_SUPPORTED_CAPS */ + bta_dm_api_cs_read_remote_supported_caps, /* BTA_DM_API_CS_READ_REMOTE_SUPPORTED_CAPS */ + bta_dm_api_cs_write_cached_remote_supported_caps, /* BTA_DM_API_CS_WRITE_CACHED_REMOTE_SUPPORTED_CAPS */ + bta_dm_api_cs_security_enable, /* BTA_DM_API_CS_SECURITY_ENABLE */ + bta_dm_api_cs_set_default_settings, /* BTA_DM_API_CS_SET_DEFAULT_SETTINGS */ + bta_dm_api_cs_read_remote_fae_table, /* BTA_DM_API_CS_READ_REMOTE_FAE_TABLE */ + bta_dm_api_cs_write_cached_remote_fae_table, /* BTA_DM_API_CS_WRITE_CACHED_REMOTE_FAE_TABLE */ + bta_dm_api_cs_create_config, /* BTA_DM_API_CS_CREATE_CONFIG */ + bta_dm_api_cs_remove_config, /* BTA_DM_API_CS_REMOVE_CONFIG */ + bta_dm_api_cs_set_channel_classification, /* BTA_DM_API_CS_SET_CAHNNEL_CLASSIFICATION */ + bta_dm_api_cs_set_procedure_params, /* BTA_DM_API_CS_SET_PROCEDURE_PARAMS */ + bta_dm_api_cs_procedure_enable, /* BTA_DM_API_CS_PROCEDURE_ENABLE */ +#endif // (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE) }; diff --git a/components/bt/host/bluedroid/bta/dm/include/bta_dm_int.h b/components/bt/host/bluedroid/bta/dm/include/bta_dm_int.h index e724b37c3a..9ef189a26f 100644 --- a/components/bt/host/bluedroid/bta/dm/include/bta_dm_int.h +++ b/components/bt/host/bluedroid/bta/dm/include/bta_dm_int.h @@ -335,6 +335,25 @@ enum { #if (BLE_50_FEATURE_SUPPORT == TRUE) BTA_DM_API_SET_HOST_FEATURE_EVT, #endif // #if (BLE_50_FEATURE_SUPPORT == TRUE) +#if (BT_BLE_FEAT_PAWR_EN == TRUE) + BTA_DM_API_SET_PA_SUBEVT_DATA, + BTA_DM_API_SET_PA_RSP_DATA, + BTA_DM_API_SET_PA_SYNC_SUBEVT, +#endif // #if (BT_BLE_FEAT_PAWR_EN == TRUE) +#if (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE) + BTA_DM_API_CS_READ_LOCAL_SUPPORTED_CAPS, + BTA_DM_API_CS_READ_REMOTE_SUPPORTED_CAPS, + BTA_DM_API_CS_WRITE_CACHED_REMOTE_SUPPORTED_CAPS, + BTA_DM_API_CS_SECURITY_ENABLE, + BTA_DM_API_CS_SET_DEFAULT_SETTINGS, + BTA_DM_API_CS_READ_REMOTE_FAE_TABLE, + BTA_DM_API_CS_WRITE_CACHED_REMOTE_FAE_TABLE, + BTA_DM_API_CS_CREATE_CONFIG, + BTA_DM_API_CS_REMOVE_CONFIG, + BTA_DM_API_CS_SET_CAHNNEL_CLASSIFICATION, + BTA_DM_API_CS_SET_PROCEDURE_PARAMS, + BTA_DM_API_CS_PROCEDURE_ENABLE, +#endif // (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE) BTA_DM_MAX_EVT }; @@ -1156,6 +1175,167 @@ typedef struct { } tBTA_DM_API_SET_HOST_FEATURE; #endif // #if (BLE_50_FEATURE_SUPPORT == TRUE) +#if (BT_BLE_FEAT_PAWR_EN == TRUE) + +typedef struct { + UINT8 subevent; + UINT8 response_slot_start; + UINT8 response_slot_count; + UINT8 subevent_data_len; + UINT8 *subevent_data; +} tBTA_BLE_SUBEVENT_PARAMS; + +typedef struct { + UINT8 subevent; + UINT8 response_slot_start; + UINT8 response_slot_count; + UINT8 subevent_data_len; + UINT8 subevent_data[251]; +} tBTA_DM_API_BLE_SUBEVENT_PARAMS; + +typedef struct { + BT_HDR hdr; + UINT8 adv_handle; + UINT8 num_subevents_with_data; + tBTA_DM_API_BLE_SUBEVENT_PARAMS *subevent_params; +} tBTA_DM_API_BLE_PA_SUBEVENT_DATA; + +typedef struct { + BT_HDR hdr; + UINT16 sync_handle; + UINT16 request_event; + UINT8 request_subevent; + UINT8 rsp_subevent; + UINT8 rsp_slot; + UINT8 rsp_data_len; + UINT8 *rsp_data; +} tBTA_DM_API_BLE_PA_RSP_DATA; + +typedef struct { + BT_HDR hdr; + UINT16 sync_handle; + UINT16 periodic_adv_properties; + UINT8 num_subevents_to_sync; + UINT8 *subevent; +} tBTA_DM_API_BLE_PA_SYNC_SUBEVT; +#endif // #if (BT_BLE_FEAT_PAWR_EN == TRUE) + +#if (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE) +typedef struct { + BT_HDR hdr; +} tBTA_DM_API_CS_READ_LOCAL_SUPP_CAPS; +typedef struct { + BT_HDR hdr; + UINT16 conn_handle; +} tBTA_DM_API_CS_READ_REMOTE_SUPP_CAPS; +typedef struct { + BT_HDR hdr; + UINT16 conn_handle; + UINT8 num_config_supported; + UINT16 max_consecutive_proc_supported; + UINT8 num_ant_supported; + UINT8 max_ant_paths_supported; + UINT8 roles_supported; + UINT8 modes_supported; + UINT8 rtt_capability; + UINT8 rtt_aa_only_n; + UINT8 rtt_sounding_n; + UINT8 rtt_random_payload_n; + UINT16 NADM_sounding_capability; + UINT16 NADM_random_capability; + UINT8 cs_sync_phys_supported; + UINT16 subfeatures_supported; + UINT16 T_IP1_times_supported; + UINT16 T_IP2_times_supported; + UINT16 T_FCS_times_supported; + UINT16 T_PM_times_supported; + UINT8 T_SW_times_supported; + UINT8 TX_SNR_capability; +} tBTA_DM_API_CS_WRITE_CACHED_REMOTE_SUPP_CAPS; + +typedef struct { + BT_HDR hdr; + UINT16 conn_handle; +} tBTA_DM_API_CS_SECURITY_ENABLE; + +typedef struct { + BT_HDR hdr; + UINT16 conn_handle; + UINT8 role_enable; + UINT8 cs_sync_ant_selection; + INT8 max_tx_power; +} tBTA_DM_API_CS_SET_DEFAULT_SETTING_PARAMS; + +typedef struct { + BT_HDR hdr; + UINT16 conn_handle; +} tBTA_DM_API_CS_READ_REMOTE_TAB; + +typedef struct { + BT_HDR hdr; + UINT16 conn_handle; + UINT8 remote_fae_table[72]; +} tBTA_DM_API_CS_WRITE_CACHED_REMOTE_FAE_TAB_PARAMS; + +typedef struct { + BT_HDR hdr; + UINT16 conn_handle; + UINT8 config_id; + UINT8 create_context; + UINT8 main_mode_type; + UINT8 sub_mode_type; + UINT8 min_main_mode_steps; + UINT8 max_main_mode_steps; + UINT8 main_mode_repetition; + UINT8 mode_0_steps; + UINT8 role; + UINT8 rtt_type; + UINT8 cs_sync_phy; + UINT8 channel_map[10]; + UINT8 channel_map_repetition; + UINT8 channel_selection_type; + UINT8 ch3c_shape; + UINT8 ch3c_jump; + UINT8 reserved; +} tBTA_DM_API_CS_CREATE_CONFIG_PARAMS; + +typedef struct { + BT_HDR hdr; + UINT16 conn_handle; + UINT8 config_id; +} tBTA_DM_API_CS_REMOVE_CONFIG_PARAMS; + +typedef struct { + BT_HDR hdr; + UINT8 channel_class[10]; +} tBTA_DM_API_CS_SET_CHANNEL_CLASS_PARAMS; + +typedef struct { + BT_HDR hdr; + UINT16 conn_handle; + UINT8 config_id; + UINT16 max_procedure_len; + UINT16 min_procedure_interval; + UINT16 max_procedure_interval; + UINT16 max_procedure_count; + UINT32 min_subevent_len; + UINT32 max_subevent_len; + UINT8 tone_ant_config_selection; + UINT8 phy; + UINT8 tx_power_delta; + UINT8 preferred_peer_antenna; + UINT8 SNR_control_initiator; + UINT8 SNR_control_reflector; +} tBTA_DM_API_CS_SET_PROC_PARAMS; + +typedef struct { + BT_HDR hdr; + UINT16 conn_handle; + UINT8 config_id; + UINT8 enable; +} tBTA_DM_API_CS_PROC_ENABLE_PARAMS; +#endif // (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE) + #endif /* BLE_INCLUDED */ #if (BLE_HOST_REMOVE_AN_ACL_EN == TRUE) @@ -1876,6 +2056,25 @@ typedef union { #if (BLE_50_FEATURE_SUPPORT == TRUE) tBTA_DM_API_SET_HOST_FEATURE set_host_feat; #endif // #if (BLE_50_FEATURE_SUPPORT == TRUE) +#if (BT_BLE_FEAT_PAWR_EN == TRUE) + tBTA_DM_API_BLE_PA_SUBEVENT_DATA pa_subevt_data; + tBTA_DM_API_BLE_PA_RSP_DATA pa_rsp_data; + tBTA_DM_API_BLE_PA_SYNC_SUBEVT pa_sync_subevt; +#endif // #if (BT_BLE_FEAT_PAWR_EN == TRUE) +#if (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE) + tBTA_DM_API_CS_READ_LOCAL_SUPP_CAPS read_local_supp_caps; + tBTA_DM_API_CS_READ_REMOTE_SUPP_CAPS read_remote_supp_caps; + tBTA_DM_API_CS_WRITE_CACHED_REMOTE_SUPP_CAPS write_cached_remote_caps; + tBTA_DM_API_CS_SECURITY_ENABLE security_enable; + tBTA_DM_API_CS_SET_DEFAULT_SETTING_PARAMS set_default_setting_params; + tBTA_DM_API_CS_READ_REMOTE_TAB read_remote_tab; + tBTA_DM_API_CS_WRITE_CACHED_REMOTE_FAE_TAB_PARAMS write_cached_remote_fae_tab_params; + tBTA_DM_API_CS_CREATE_CONFIG_PARAMS create_config_params; + tBTA_DM_API_CS_REMOVE_CONFIG_PARAMS remove_config_params; + tBTA_DM_API_CS_SET_CHANNEL_CLASS_PARAMS set_channel_class_params; + tBTA_DM_API_CS_SET_PROC_PARAMS set_proc_params; + tBTA_DM_API_CS_PROC_ENABLE_PARAMS proc_enable_params; +#endif } tBTA_DM_MSG; @@ -2543,4 +2742,23 @@ void bta_dm_api_subrate_request(tBTA_DM_MSG *p_data); #if (BLE_50_FEATURE_SUPPORT == TRUE) extern void bta_dm_ble_set_host_feature(tBTA_DM_MSG *p_data); #endif // #if (BLE_50_FEATURE_SUPPORT == TRUE) +#if (BT_BLE_FEAT_PAWR_EN == TRUE) +void bta_dm_api_set_periodic_adv_subevt_data(tBTA_DM_MSG *p_data); +void bta_dm_api_set_periodic_adv_response_data(tBTA_DM_MSG *p_data); +void bta_dm_api_set_periodic_sync_subevt(tBTA_DM_MSG *p_data); +#endif // #if (BT_BLE_FEAT_PAWR_EN == TRUE) +#if (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE) +void bta_dm_api_cs_read_local_supported_caps(tBTA_DM_MSG *p_data); +void bta_dm_api_cs_read_remote_supported_caps(tBTA_DM_MSG *p_data); +void bta_dm_api_cs_write_cached_remote_supported_caps(tBTA_DM_MSG *p_data); +void bta_dm_api_cs_security_enable(tBTA_DM_MSG *p_data); +void bta_dm_api_cs_set_default_settings(tBTA_DM_MSG *p_data); +void bta_dm_api_cs_read_remote_fae_table(tBTA_DM_MSG *p_data); +void bta_dm_api_cs_write_cached_remote_fae_table(tBTA_DM_MSG *p_data); +void bta_dm_api_cs_create_config(tBTA_DM_MSG *p_data); +void bta_dm_api_cs_remove_config(tBTA_DM_MSG *p_data); +void bta_dm_api_cs_set_channel_classification(tBTA_DM_MSG *p_data); +void bta_dm_api_cs_set_procedure_params(tBTA_DM_MSG *p_data); +void bta_dm_api_cs_procedure_enable(tBTA_DM_MSG *p_data); +#endif // (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE) #endif /* BTA_DM_INT_H */ diff --git a/components/bt/host/bluedroid/bta/gatt/bta_gattc_act.c b/components/bt/host/bluedroid/bta/gatt/bta_gattc_act.c index f65dd43e7c..bbbc1ba09f 100644 --- a/components/bt/host/bluedroid/bta/gatt/bta_gattc_act.c +++ b/components/bt/host/bluedroid/bta/gatt/bta_gattc_act.c @@ -511,6 +511,10 @@ void bta_gattc_open(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data) tGATT_TCB *p_tcb; tBTM_SEC_DEV_REC *p_dev_rec = NULL; + BOOLEAN is_pawr_synced = FALSE; + UINT8 adv_handle = 0xFF; + UINT8 subevent = 0xFF; + if (!p_clcb || !p_data) { return; } @@ -545,10 +549,15 @@ void bta_gattc_open(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data) APPL_TRACE_ERROR("Unknown Device, setting rejected"); } } - +#if (BT_BLE_FEAT_PAWR_EN == TRUE) + is_pawr_synced = p_data->api_conn.is_pawr_synced; + adv_handle = p_data->api_conn.adv_handle; + subevent = p_data->api_conn.subevent; +#endif // (BT_BLE_FEAT_PAWR_EN == TRUE) /* open/hold a connection */ if (!GATT_Connect(p_clcb->p_rcb->client_if, p_data->api_conn.remote_bda, p_data->api_conn.remote_addr_type, - TRUE, p_data->api_conn.transport, p_data->api_conn.is_aux)) { + TRUE, p_data->api_conn.transport, p_data->api_conn.is_aux, is_pawr_synced, + adv_handle, subevent)) { APPL_TRACE_ERROR("Connection open failure"); bta_gattc_sm_execute(p_clcb, BTA_GATTC_INT_OPEN_FAIL_EVT, p_data); @@ -585,7 +594,7 @@ void bta_gattc_init_bk_conn(tBTA_GATTC_API_OPEN *p_data, tBTA_GATTC_RCB *p_clreg /* always call open to hold a connection */ if (!GATT_Connect(p_data->client_if, p_data->remote_bda, p_data->remote_addr_type, FALSE, - p_data->transport, p_data->is_aux)) { + p_data->transport, p_data->is_aux, FALSE, 0xFF, 0xFF)) { #if (!CONFIG_BT_STACK_NO_LOG) uint8_t *bda = (uint8_t *)p_data->remote_bda; #endif diff --git a/components/bt/host/bluedroid/bta/gatt/bta_gattc_api.c b/components/bt/host/bluedroid/bta/gatt/bta_gattc_api.c index 8ac0ec4c96..69738647ba 100644 --- a/components/bt/host/bluedroid/bta/gatt/bta_gattc_api.c +++ b/components/bt/host/bluedroid/bta/gatt/bta_gattc_api.c @@ -144,6 +144,7 @@ void BTA_GATTC_AppDeregister(tBTA_GATTC_IF client_if) *******************************************************************************/ void BTA_GATTC_Enh_Open(tBTA_GATTC_IF client_if, BD_ADDR remote_bda, tBTA_ADDR_TYPE remote_addr_type, BOOLEAN is_direct, tBTA_GATT_TRANSPORT transport, BOOLEAN is_aux, tBTA_ADDR_TYPE own_addr_type, + BOOLEAN is_pawr_synced, UINT8 adv_handle, UINT8 subevent, UINT8 phy_mask, tBTA_BLE_CONN_PARAMS *phy_1m_conn_params, tBTA_BLE_CONN_PARAMS *phy_2m_conn_params, tBTA_BLE_CONN_PARAMS *phy_coded_conn_params) { @@ -156,6 +157,11 @@ void BTA_GATTC_Enh_Open(tBTA_GATTC_IF client_if, BD_ADDR remote_bda, tBTA_ADDR_T p_buf->is_direct = is_direct; p_buf->transport = transport; p_buf->is_aux = is_aux; +#if (BT_BLE_FEAT_PAWR_EN == TRUE) + p_buf->is_pawr_synced = is_pawr_synced; + p_buf->adv_handle = adv_handle; + p_buf->subevent = subevent; +#endif // (BT_BLE_FEAT_PAWR_EN == TRUE) p_buf->remote_addr_type = remote_addr_type; p_buf->own_addr_type = own_addr_type; p_buf->phy_mask = phy_mask; diff --git a/components/bt/host/bluedroid/bta/gatt/bta_gatts_act.c b/components/bt/host/bluedroid/bta/gatt/bta_gatts_act.c index 692c59c660..37c9a67527 100644 --- a/components/bt/host/bluedroid/bta/gatt/bta_gatts_act.c +++ b/components/bt/host/bluedroid/bta/gatt/bta_gatts_act.c @@ -757,7 +757,7 @@ void bta_gatts_open (tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA *p_msg) if ((p_rcb = bta_gatts_find_app_rcb_by_app_if(p_msg->api_open.server_if)) != NULL) { /* should always get the connection ID */ if (GATT_Connect(p_rcb->gatt_if, p_msg->api_open.remote_bda, BLE_ADDR_UNKNOWN_TYPE, - p_msg->api_open.is_direct, p_msg->api_open.transport, FALSE)) { + p_msg->api_open.is_direct, p_msg->api_open.transport, FALSE, FALSE, 0xFF, 0xFF)) { status = BTA_GATT_OK; if (GATT_GetConnIdIfConnected(p_rcb->gatt_if, p_msg->api_open.remote_bda, diff --git a/components/bt/host/bluedroid/bta/gatt/include/bta_gattc_int.h b/components/bt/host/bluedroid/bta/gatt/include/bta_gattc_int.h index cb877fcfc2..ac42de6973 100644 --- a/components/bt/host/bluedroid/bta/gatt/include/bta_gattc_int.h +++ b/components/bt/host/bluedroid/bta/gatt/include/bta_gattc_int.h @@ -130,6 +130,11 @@ typedef struct { tBTA_GATTC_IF client_if; BOOLEAN is_direct; BOOLEAN is_aux; +#if (BT_BLE_FEAT_PAWR_EN == TRUE) + BOOLEAN is_pawr_synced; + UINT8 adv_handle; + UINT8 subevent; +#endif // (BT_BLE_FEAT_PAWR_EN == TRUE) tBTA_TRANSPORT transport; tBTA_ADDR_TYPE own_addr_type; UINT8 phy_mask; diff --git a/components/bt/host/bluedroid/bta/hh/bta_hh_le.c b/components/bt/host/bluedroid/bta/hh/bta_hh_le.c index f5697dff52..ae150a3c94 100644 --- a/components/bt/host/bluedroid/bta/hh/bta_hh_le.c +++ b/components/bt/host/bluedroid/bta/hh/bta_hh_le.c @@ -2603,7 +2603,7 @@ static void bta_hh_le_add_dev_bg_conn(tBTA_HH_DEV_CB *p_cb, BOOLEAN check_bond) !p_cb->in_bg_conn && to_add) { /* add device into BG connection to accept remote initiated connection */ BTA_GATTC_Enh_Open(bta_hh_cb.gatt_if, p_cb->addr, BLE_ADDR_UNKNOWN_TYPE, FALSE, - BTA_GATT_TRANSPORT_LE, FALSE, BLE_ADDR_UNKNOWN_TYPE, 0, NULL, NULL); + BTA_GATT_TRANSPORT_LE, FALSE, BLE_ADDR_UNKNOWN_TYPE, false, 0xFF, 0xFF, 0, NULL, NULL); p_cb->in_bg_conn = TRUE; BTA_DmBleSetBgConnType(BTA_DM_BLE_CONN_AUTO, NULL); diff --git a/components/bt/host/bluedroid/bta/include/bta/bta_api.h b/components/bt/host/bluedroid/bta/include/bta/bta_api.h index aa1b632aad..23bf8915d9 100644 --- a/components/bt/host/bluedroid/bta/include/bta/bta_api.h +++ b/components/bt/host/bluedroid/bta/include/bta/bta_api.h @@ -1228,6 +1228,71 @@ typedef struct { tBTA_DM_SEARCH *p_data; /* Union of all search callback structures */ } tBTA_DM_SEARCH_PARAM; +#if (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE) +typedef struct { + UINT16 conn_handle; + UINT8 num_config_supported; + UINT16 max_consecutive_proc_supported; + UINT8 num_ant_supported; + UINT8 max_ant_paths_supported; + UINT8 roles_supported; + UINT8 modes_supported; + UINT8 rtt_capability; + UINT8 rtt_aa_only_n; + UINT8 rtt_sounding_n; + UINT8 rtt_random_payload_n; + UINT16 NADM_sounding_capability; + UINT16 NADM_random_capability; + UINT8 cs_sync_phys_supported; + UINT16 subfeatures_supported; + UINT16 T_IP1_times_supported; + UINT16 T_IP2_times_supported; + UINT16 T_FCS_times_supported; + UINT16 T_PM_times_supported; + UINT8 T_SW_times_supported; + UINT8 TX_SNR_capability; +} tBTA_DM_CS_WRITE_CACHED_REMOTE_SUPP_CAPS; + +typedef struct { + UINT16 conn_handle; + UINT8 config_id; + UINT8 create_context; + UINT8 main_mode_type; + UINT8 sub_mode_type; + UINT8 min_main_mode_steps; + UINT8 max_main_mode_steps; + UINT8 main_mode_repetition; + UINT8 mode_0_steps; + UINT8 role; + UINT8 rtt_type; + UINT8 cs_sync_phy; + UINT8 channel_map[10]; + UINT8 channel_map_repetition; + UINT8 channel_selection_type; + UINT8 ch3c_shape; + UINT8 ch3c_jump; + UINT8 reserved; +} tBTA_DM_CS_CREATE_CONFIG_PARAMS; + +typedef struct { + UINT16 conn_handle; + UINT8 config_id; + UINT16 max_procedure_len; + UINT16 min_procedure_interval; + UINT16 max_procedure_interval; + UINT16 max_procedure_count; + uint32_t min_subevent_len; + uint32_t max_subevent_len; + UINT8 tone_ant_config_selection; + UINT8 phy; + UINT8 tx_power_delta; + UINT8 preferred_peer_antenna; + UINT8 SNR_control_initiator; + UINT8 SNR_control_reflector; +} tBTA_DM_CS_SET_PROC_PARAMS; + +#endif // (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE) + /* Search callback */ typedef void (tBTA_DM_SEARCH_CBACK)(tBTA_DM_SEARCH_EVT event, tBTA_DM_SEARCH *p_data); @@ -1573,6 +1638,10 @@ typedef struct { tBTA_DM_BLE_GAP_PHY secondary_phy; UINT8 sid; BOOLEAN scan_req_notif; +#if (BT_BLE_FEAT_ADV_CODING_SELECTION == TRUE) + uint8_t primary_adv_phy_options; + uint8_t secondary_adv_phy_options; +#endif // (BT_BLE_FEAT_ADV_CODING_SELECTION == TRUE) } tBTA_DM_BLE_GAP_EXT_ADV_PARAMS; typedef struct { @@ -1584,7 +1653,14 @@ typedef struct { typedef struct { UINT16 interval_min; UINT16 interval_max; - UINT8 properties; + UINT16 properties; +#if (BT_BLE_FEAT_PAWR_EN == TRUE) + UINT8 num_subevents; + UINT8 subevent_interval; + UINT8 rsp_slot_delay; + UINT8 rsp_slot_spacing; + UINT8 num_rsp_slots; +#endif // (BT_BLE_FEAT_PAWR_EN == TRUE) } tBTA_DM_BLE_Periodic_Adv_Params; typedef struct { @@ -1701,6 +1777,30 @@ typedef struct { #define BTA_BLE_GAP_SET_HOST_FEATURE_EVT BTM_BLE_GAP_SET_HOST_FEATURE_EVT #endif // #if (BLE_50_FEATURE_SUPPORT == TRUE) +#if (BT_BLE_FEAT_PAWR_EN == TRUE) +#define BTA_BLE_GAP_SET_PERIODIC_ADV_SUBEVT_DATA_EVT BTM_BLE_GAP_SET_PERIODIC_ADV_SUBEVT_DATA_EVT +#define BTA_BLE_GAP_SET_PERIODIC_ADV_RESPONSE_DATA_EVT BTM_BLE_GAP_SET_PERIODIC_ADV_RESPONSE_DATA_EVT +#define BTA_BLE_GAP_SET_PERIODIC_SYNC_SUBEVT_EVT BTM_BLE_GAP_SET_PERIODIC_SYNC_SUBEVT_EVT +#define BTA_BLE_GAP_PERIODIC_ADV_SUBEVT_DATA_REQUEST_EVT BTM_BLE_GAP_PERIODIC_ADV_SUBEVT_DATA_REQUEST_EVT +#define BTA_BLE_GAP_PERIODIC_ADV_RESPONSE_REPORT_EVT BTM_BLE_GAP_PERIODIC_ADV_RESPONSE_REPORT_EVT +#endif // #if (BT_BLE_FEAT_PAWR_EN == TRUE) + +#if (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE) +#define BTA_BLE_GAP_CS_READ_LOCAL_SUPP_CAPS_EVT BTM_BLE_GAP_CS_READ_LOCAL_SUPP_CAPS_EVT +#define BTA_BLE_GAP_CS_WRITE_CACHED_REMOTE_SUPP_CAPS_EVT BTM_BLE_GAP_CS_WRITE_CACHED_REMOTE_SUPP_CAPS_EVT +#define BTA_BLE_GAP_CS_SET_DEFAULT_SETTINGS_EVT BTM_BLE_GAP_CS_SET_DEFAULT_SETTINGS_EVT +#define BTA_BLE_GAP_CS_WRITE_CACHED_REMOTE_FAE_TAB_EVT BTM_BLE_GAP_CS_WRITE_CACHED_REMOTE_FAE_TAB_EVT +#define BTA_BLE_GAP_CS_READ_REMOTE_SUPP_CAPS_CMPL_EVT BTM_BLE_GAP_CS_READ_REMOTE_SUPP_CAPS_CMPL_EVT +#define BTA_BLE_GAP_CS_SET_CHANNEL_CLASS_CMPL_EVT BTM_BLE_GAP_CS_SET_CHANNEL_CLASS_CMPL_EVT +#define BTA_BLE_GAP_CS_PROC_PARAMS_CMPL_EVT BTM_BLE_GAP_CS_PROC_PARAMS_CMPL_EVT +#define BTA_BLE_GAP_CS_PROC_ENABLE_CMPL_EVT BTM_BLE_GAP_CS_PROC_ENABLE_CMPL_EVT +#define BTA_BLE_GAP_CS_READ_REMOTE_FAE_TABLE_CMPL_EVT BTM_BLE_GAP_CS_READ_REMOTE_FAE_TABLE_CMPL_EVT +#define BTA_BLE_GAP_CS_SECURITY_ENABLE_CMPL_EVT BTM_BLE_GAP_CS_SECURITY_ENABLE_CMPL_EVT +#define BTA_BLE_GAP_CS_CONFIG_CMPL_EVT BTM_BLE_GAP_CS_CONFIG_CMPL_EVT +#define BTA_BLE_GAP_CS_SUBEVENT_RESULT_EVT BTM_BLE_GAP_CS_SUBEVENT_RESULT_EVT +#define BTA_BLE_GAP_CS_SUBEVENT_RESULT_CONTINUE_EVT BTM_BLE_GAP_CS_SUBEVENT_RESULT_CONTINUE_EVT +#endif // (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE) + #define BTA_DM_BLE_5_GAP_UNKNOWN_EVT BTM_BLE_5_GAP_UNKNOWN_EVT typedef tBTM_BLE_5_GAP_EVENT tBTA_DM_BLE_5_GAP_EVENT; @@ -3094,6 +3194,28 @@ void BTA_DmBleGapSubrateReqest(uint16_t conn_handle, uint16_t subrate_min, uint1 extern void BTA_DmBleGapSetHostFeature(uint16_t bit_num, uint8_t bit_val); #endif // #if (BLE_50_FEATURE_SUPPORT == TRUE) +#if (BT_BLE_FEAT_PAWR_EN == TRUE) +void BTA_DmBleGapSetPASubevtData(uint8_t adv_handle, uint8_t num_subevents_with_data, uint8_t *subevent_params); +void BTA_DmBleGapSetPeriodicAdvRspData(uint16_t sync_handle, uint16_t request_event, uint8_t request_subevent, + uint8_t rsp_subevent, uint8_t rsp_slot, uint8_t rsp_data_len, uint8_t *rsp_data); +void BTA_DmBleGapSetPeriodicSyncSubevt(uint16_t sync_handle, uint16_t periodic_adv_properties, uint8_t num_subevents_to_sync, uint8_t *subevent); +#endif// (BT_BLE_FEAT_PAWR_EN == TRUE) + +#if (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE) +void BTA_DmBleGapReadLocalSupportedCaps(void); +void BTA_DmBleGapReadRemoteSupportedCaps(uint16_t conn_handle); +void BTA_DmBleGapWriteCachedRemoteSupportedCaps(tBTA_DM_CS_WRITE_CACHED_REMOTE_SUPP_CAPS *write_cachedremote_supp_caps); +void BTA_DmBleGapCsSecurityEnable(uint16_t conn_handle); +void BTA_DmBleGapCsSetDefaultSetting(uint16_t conn_handle, uint8_t role_enable, uint8_t cs_sync_ant_selection, int8_t max_tx_power); +void BTA_DmBleGapCsReadRemoteFaeTable(uint16_t conn_handle); +void BTA_DmBleGapWriteCachedRemoteFaeTable(uint16_t conn_handle, uint8_t *remote_fae_table, uint8_t table_len); +void BTA_DmBleGapCsCreateConfig(tBTA_DM_CS_CREATE_CONFIG_PARAMS *create_config_params); +void BTA_DmBleGapCsRemoveConfig(uint16_t conn_handle, uint8_t config_id); +void BTA_DmBleGapCsSetChannelClass(uint8_t *channel_class, uint8_t channl_len); +void BTA_DmBleGapCsSetProcPatams(tBTA_DM_CS_SET_PROC_PARAMS *set_proc_params); +void BTA_DmBleGapCsProcEnable(uint16_t conn_handle, uint8_t config_id, uint8_t enable); +#endif // (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE) + /******************************************************************************* ** ** Function BTA_DmBleSetStorageParams diff --git a/components/bt/host/bluedroid/bta/include/bta/bta_gatt_api.h b/components/bt/host/bluedroid/bta/include/bta/bta_gatt_api.h index a42d14084b..7819b8a718 100644 --- a/components/bt/host/bluedroid/bta/include/bta/bta_gatt_api.h +++ b/components/bt/host/bluedroid/bta/include/bta/bta_gatt_api.h @@ -817,6 +817,7 @@ extern void BTA_GATTC_AppDeregister (tBTA_GATTC_IF client_if); *******************************************************************************/ extern void BTA_GATTC_Enh_Open(tBTA_GATTC_IF client_if, BD_ADDR remote_bda, tBTA_ADDR_TYPE remote_addr_type, BOOLEAN is_direct, tBTA_GATT_TRANSPORT transport, BOOLEAN is_aux, tBTA_ADDR_TYPE own_addr_type, + BOOLEAN is_pawr_synced, UINT8 adv_handle, UINT8 subevent, UINT8 phy_mask, tBTA_BLE_CONN_PARAMS *phy_1m_conn_params, tBTA_BLE_CONN_PARAMS *phy_2m_conn_params, tBTA_BLE_CONN_PARAMS *phy_coded_conn_params); diff --git a/components/bt/host/bluedroid/bta/jv/bta_jv_act.c b/components/bt/host/bluedroid/bta/jv/bta_jv_act.c index a49cfc91a0..492c22022e 100644 --- a/components/bt/host/bluedroid/bta/jv/bta_jv_act.c +++ b/components/bt/host/bluedroid/bta/jv/bta_jv_act.c @@ -2923,7 +2923,7 @@ void bta_jv_l2cap_connect_le(tBTA_JV_MSG *p_data) id = t->id; t->init_called = FALSE; - if (L2CA_ConnectFixedChnl(t->chan, t->remote_addr, BLE_ADDR_UNKNOWN_TYPE, FALSE)) { + if (L2CA_ConnectFixedChnl(t->chan, t->remote_addr, BLE_ADDR_UNKNOWN_TYPE, FALSE, FALSE, 0xFF, 0xFF)) { evt.l2c_cl_init.status = BTA_JV_SUCCESS; evt.l2c_cl_init.handle = id; diff --git a/components/bt/host/bluedroid/btc/profile/std/gap/btc_gap_ble.c b/components/bt/host/bluedroid/btc/profile/std/gap/btc_gap_ble.c index 67b54deea8..ff1f63cba8 100644 --- a/components/bt/host/bluedroid/btc/profile/std/gap/btc_gap_ble.c +++ b/components/bt/host/bluedroid/btc/profile/std/gap/btc_gap_ble.c @@ -1155,6 +1155,10 @@ void btc_ble_5_gap_callback(tBTA_DM_BLE_5_GAP_EVENT event, #if (BLE_FEAT_CTE_EN == TRUE) param.period_adv_report.params.cte_type = params->period_adv_report.cte_type; #endif // #if (BLE_FEAT_CTE_EN == TRUE) + #if (BT_BLE_FEAT_PAWR_EN == TRUE) + param.period_adv_report.params.periodic_evt_counter = params->period_adv_report.periodic_evt_cnt; + param.period_adv_report.params.subevt = params->period_adv_report.subevt; + #endif // (BT_BLE_FEAT_PAWR_EN == TRUE) param.period_adv_report.params.data_status = params->period_adv_report.data_status; param.period_adv_report.params.data_length = params->period_adv_report.data_length; if (params->period_adv_report.data) { @@ -1179,6 +1183,12 @@ void btc_ble_5_gap_callback(tBTA_DM_BLE_5_GAP_EVENT event, param.periodic_adv_sync_estab.adv_phy = params->sync_estab.adv_phy; param.periodic_adv_sync_estab.period_adv_interval = params->sync_estab.period_adv_interval; param.periodic_adv_sync_estab.adv_clk_accuracy = params->sync_estab.adv_clk_accuracy; +#if (BT_BLE_FEAT_PAWR_EN == TRUE) + param.periodic_adv_sync_estab.num_subevt = params->sync_estab.num_subevt; + param.periodic_adv_sync_estab.subevt_interval = params->sync_estab.subevt_interval; + param.periodic_adv_sync_estab.rsp_slot_delay = params->sync_estab.rsp_slot_delay; + param.periodic_adv_sync_estab.rsp_slot_spacing = params->sync_estab.rsp_slot_spacing; +#endif // (BT_BLE_FEAT_PAWR_EN == TRUE) break; } #endif // #if (BLE_50_EXTEND_SYNC_EN == TRUE) @@ -1287,12 +1297,198 @@ void btc_ble_5_gap_callback(tBTA_DM_BLE_5_GAP_EVENT event, param.host_feature.status = btc_btm_status_to_esp_status(params->status); break; #endif // #if (BLE_50_FEATURE_SUPPORT == TRUE) +#if (BT_BLE_FEAT_PAWR_EN == TRUE) + case BTA_BLE_GAP_SET_PERIODIC_ADV_SUBEVT_DATA_EVT: + msg.act = ESP_GAP_BLE_SET_PERIODIC_ADV_SUBEVT_DATA_EVT; + param.pa_subevt_data_evt.status = btc_btm_status_to_esp_status(params->pa_subevt_data_evt.status); + param.pa_subevt_data_evt.adv_handle = params->pa_subevt_data_evt.adv_handle; + break; + case BTA_BLE_GAP_SET_PERIODIC_ADV_RESPONSE_DATA_EVT: + msg.act = ESP_GAP_BLE_SET_PERIODIC_ADV_RESPONSE_DATA_EVT; + param.pa_rsp_data_evt.status = btc_btm_status_to_esp_status(params->pa_rsp_data_evt.status); + param.pa_rsp_data_evt.sync_handle = params->pa_rsp_data_evt.sync_handle; + break; + case BTA_BLE_GAP_SET_PERIODIC_SYNC_SUBEVT_EVT: + msg.act = ESP_GAP_BLE_SET_PERIODIC_SYNC_SUBEVT_EVT; + param.pa_sync_subevt_evt.status = btc_btm_status_to_esp_status(params->pa_sync_subevt_evt.status); + param.pa_sync_subevt_evt.sync_handle = params->pa_sync_subevt_evt.sync_handle; + break; + case BTA_BLE_GAP_PERIODIC_ADV_SUBEVT_DATA_REQUEST_EVT: + msg.act = ESP_GAP_BLE_PERIODIC_ADV_SUBEVT_DATA_REQUEST_EVT; + param.pa_subevt_data_req_evt.adv_handle = params->pa_subevent_data_req_evt.adv_handle; + param.pa_subevt_data_req_evt.subevt_start = params->pa_subevent_data_req_evt.subevt_start; + param.pa_subevt_data_req_evt.subevt_data_count = params->pa_subevent_data_req_evt.subevt_data_count; + break; + case BTA_BLE_GAP_PERIODIC_ADV_RESPONSE_REPORT_EVT: + msg.act = ESP_GAP_BLE_PERIODIC_ADV_RESPONSE_REPORT_EVT; + param.pa_rsp_rpt_evt.adv_handle = params->pa_rsp_rpt_evt.adv_handle; + param.pa_rsp_rpt_evt.subevt = params->pa_rsp_rpt_evt.subevt; + param.pa_rsp_rpt_evt.tx_status = params->pa_rsp_rpt_evt.tx_status; + param.pa_rsp_rpt_evt.num_rsp = params->pa_rsp_rpt_evt.num_rsp; + param.pa_rsp_rpt_evt.pa_rsp_info = (esp_ble_pa_rsp_info *)params->pa_rsp_rpt_evt.rsp_data_info; + break; +#endif // #if (BT_BLE_FEAT_PAWR_EN == TRUE) +#if (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE) + case BTA_BLE_GAP_CS_READ_LOCAL_SUPP_CAPS_EVT: + msg.act = ESP_GAP_BLE_CS_READ_LOCAL_SUPP_CAPS_EVT; + param.cs_read_local_supp_caps.status = params->cs_read_local_supp_caps.status; + param.cs_read_local_supp_caps.conn_handle = params->cs_read_local_supp_caps.conn_handle; + param.cs_read_local_supp_caps.num_config_supported = params->cs_read_local_supp_caps.num_config_supported; + param.cs_read_local_supp_caps.max_consecutive_proc_supported = params->cs_read_local_supp_caps.max_consecutive_proc_supported; + param.cs_read_local_supp_caps.num_ant_supported = params->cs_read_local_supp_caps.num_ant_supported; + param.cs_read_local_supp_caps.max_ant_paths_supported= params->cs_read_local_supp_caps.max_ant_paths_supported; + param.cs_read_local_supp_caps.roles_supported = params->cs_read_local_supp_caps.roles_supported; + param.cs_read_local_supp_caps.modes_supported = params->cs_read_local_supp_caps.modes_supported; + param.cs_read_local_supp_caps.rtt_capability = params->cs_read_local_supp_caps.rtt_capability; + param.cs_read_local_supp_caps.rtt_aa_only_n = params->cs_read_local_supp_caps.rtt_aa_only_n; + param.cs_read_local_supp_caps.rtt_sounding_n = params->cs_read_local_supp_caps.rtt_sounding_n; + param.cs_read_local_supp_caps.rtt_random_payload_n = params->cs_read_local_supp_caps.rtt_random_payload_n; + param.cs_read_local_supp_caps.NADM_sounding_capability = params->cs_read_local_supp_caps.NADM_sounding_capability; + param.cs_read_local_supp_caps.NADM_random_capability = params->cs_read_local_supp_caps.NADM_random_capability; + param.cs_read_local_supp_caps.cs_sync_phys_supported = params->cs_read_local_supp_caps.cs_sync_phys_supported; + param.cs_read_local_supp_caps.subfeatures_supported = params->cs_read_local_supp_caps.subfeatures_supported; + param.cs_read_local_supp_caps.T_IP1_times_supported = params->cs_read_local_supp_caps.T_IP1_times_supported; + param.cs_read_local_supp_caps.T_IP2_times_supported = params->cs_read_local_supp_caps.T_IP2_times_supported; + param.cs_read_local_supp_caps.T_FCS_times_supported = params->cs_read_local_supp_caps.T_FCS_times_supported; + param.cs_read_local_supp_caps.T_PM_times_supported = params->cs_read_local_supp_caps.T_PM_times_supported; + param.cs_read_local_supp_caps.T_SW_times_supported = params->cs_read_local_supp_caps.T_SW_times_supported; + param.cs_read_local_supp_caps.TX_SNR_capability = params->cs_read_local_supp_caps.TX_SNR_capability; + break; + case BTA_BLE_GAP_CS_WRITE_CACHED_REMOTE_SUPP_CAPS_EVT: + msg.act = ESP_GAP_BLE_CS_WRITE_CACHED_REMOTE_SUPP_CAPS_EVT; + param.cs_write_cached_remote_supp_caps.status = params->cs_write_cached_remote_supp_caps.status; + param.cs_write_cached_remote_supp_caps.conn_handle = params->cs_write_cached_remote_supp_caps.conn_handle; + break; + case BTA_BLE_GAP_CS_SET_DEFAULT_SETTINGS_EVT: + msg.act = ESP_GAP_BLE_CS_SET_DEFAULT_SETTINGS_EVT; + param.cs_set_default_settings.status = params->cs_set_default_settings.status; + param.cs_set_default_settings.conn_handle = params->cs_set_default_settings.conn_handle; + break; + case BTA_BLE_GAP_CS_WRITE_CACHED_REMOTE_FAE_TAB_EVT: + msg.act = ESP_GAP_BLE_CS_WRITE_CACHED_REMOTE_FAE_TABLE_EVT; + param.cs_write_cached_remote_fae_tab.status = params->cs_write_cached_remote_fae_tab.status; + param.cs_write_cached_remote_fae_tab.conn_handle = params->cs_write_cached_remote_fae_tab.conn_handle; + break; + case BTA_BLE_GAP_CS_READ_REMOTE_SUPP_CAPS_CMPL_EVT: + msg.act = ESP_GAP_BLE_CS_READ_REMOTE_SUPP_CAPS_CMPL_EVT; + param.cs_read_remote_supp_caps.status = params->cs_read_remote_supp_caps.status; + param.cs_read_remote_supp_caps.conn_handle = params->cs_read_remote_supp_caps.conn_handle; + param.cs_read_remote_supp_caps.num_config_supported = params->cs_read_remote_supp_caps.num_config_supported; + param.cs_read_remote_supp_caps.max_consecutive_proc_supported = params->cs_read_remote_supp_caps.max_consecutive_proc_supported; + param.cs_read_remote_supp_caps.num_ant_supported = params->cs_read_remote_supp_caps.num_ant_supported; + param.cs_read_remote_supp_caps.max_ant_paths_supported = params->cs_read_remote_supp_caps.max_ant_paths_supported; + param.cs_read_remote_supp_caps.roles_supported = params->cs_read_remote_supp_caps.roles_supported; + param.cs_read_remote_supp_caps.modes_supported = params->cs_read_remote_supp_caps.modes_supported; + param.cs_read_remote_supp_caps.rtt_capability = params->cs_read_remote_supp_caps.rtt_capability; + param.cs_read_remote_supp_caps.rtt_aa_only_n = params->cs_read_remote_supp_caps.rtt_aa_only_n; + param.cs_read_remote_supp_caps.rtt_sounding_n = params->cs_read_remote_supp_caps.rtt_sounding_n; + param.cs_read_remote_supp_caps.rtt_random_payload_n = params->cs_read_remote_supp_caps.rtt_random_payload_n; + param.cs_read_remote_supp_caps.NADM_sounding_capability = params->cs_read_remote_supp_caps.NADM_sounding_capability; + param.cs_read_remote_supp_caps.NADM_random_capability = params->cs_read_remote_supp_caps.NADM_random_capability; + param.cs_read_remote_supp_caps.cs_sync_phys_supported = params->cs_read_remote_supp_caps.cs_sync_phys_supported; + param.cs_read_remote_supp_caps.subfeatures_supported = params->cs_read_remote_supp_caps.subfeatures_supported; + param.cs_read_remote_supp_caps.T_IP1_times_supported = params->cs_read_remote_supp_caps.T_IP1_times_supported; + param.cs_read_remote_supp_caps.T_IP2_times_supported = params->cs_read_remote_supp_caps.T_IP2_times_supported; + param.cs_read_remote_supp_caps.T_FCS_times_supported = params->cs_read_remote_supp_caps.T_FCS_times_supported; + param.cs_read_remote_supp_caps.T_PM_times_supported = params->cs_read_remote_supp_caps.T_PM_times_supported; + param.cs_read_remote_supp_caps.T_SW_times_supported = params->cs_read_remote_supp_caps.T_SW_times_supported; + param.cs_read_remote_supp_caps.TX_SNR_capability = params->cs_read_remote_supp_caps.TX_SNR_capability; + break; + case BTA_BLE_GAP_CS_SET_CHANNEL_CLASS_CMPL_EVT: + msg.act = ESP_GAP_BLE_CS_SET_CHANNEL_CLASS_CMPL_EVT; + param.cs_set_channel_class.status = params->status; + break; + case BTA_BLE_GAP_CS_PROC_PARAMS_CMPL_EVT: + msg.act = ESP_GAP_BLE_CS_SET_PROC_PARAMS_CMPL_EVT; + param.cs_set_proc_params.status = params->cs_set_proc_params.status; + param.cs_set_proc_params.conn_handle = params->cs_set_proc_params.conn_handle; + break; + case BTA_BLE_GAP_CS_PROC_ENABLE_CMPL_EVT: + msg.act = ESP_GAP_BLE_CS_PROC_ENABLE_CMPL_EVT; + param.cs_proc_enable.status = params->cs_proc_en.status; + param.cs_proc_enable.conn_handle = params->cs_proc_en.conn_handle; + param.cs_proc_enable.config_id = params->cs_proc_en.config_id; + param.cs_proc_enable.state = params->cs_proc_en.state; + param.cs_proc_enable.tone_ant_config_select = params->cs_proc_en.tone_ant_config_select; + param.cs_proc_enable.select_tx_power = params->cs_proc_en.select_tx_power; + param.cs_proc_enable.subevent_Len = params->cs_proc_en.subevent_Len; + param.cs_proc_enable.subevents_per_event = params->cs_proc_en.subevents_per_event; + param.cs_proc_enable.subevent_interval = params->cs_proc_en.subevent_interval; + param.cs_proc_enable.event_interval = params->cs_proc_en.event_interval; + param.cs_proc_enable.procedure_interval = params->cs_proc_en.procedure_interval; + param.cs_proc_enable.procedure_count = params->cs_proc_en.procedure_count; + param.cs_proc_enable.max_procedure_len = params->cs_proc_en.max_procedure_len; + break; + case BTA_BLE_GAP_CS_READ_REMOTE_FAE_TABLE_CMPL_EVT: + msg.act = ESP_GAP_BLE_CS_READ_REMOTE_FAE_TABLE_CMPL_EVT; + param.cs_read_remote_fae_tab.status = params->cs_read_remote_fae_tab.status; + param.cs_read_remote_fae_tab.conn_handle = params->cs_read_remote_fae_tab.conn_handle; + memcpy(param.cs_read_remote_fae_tab.remote_fae_table, params->cs_read_remote_fae_tab.remote_fae_table, 72); + break; + case BTA_BLE_GAP_CS_SECURITY_ENABLE_CMPL_EVT: + msg.act = ESP_GAP_BLE_CS_SECURITY_ENABLE_CMPL_EVT; + param.cs_security_enable.status = params->cs_security_enable.status; + param.cs_security_enable.conn_handle = params->cs_security_enable.conn_handle; + break; + case BTA_BLE_GAP_CS_CONFIG_CMPL_EVT: + msg.act = ESP_GAP_BLE_CS_CONFIG_CMPL_EVT; + param.cs_config_update.status = params->cs_config_update.status; + param.cs_config_update.conn_handle = params->cs_config_update.conn_handle; + param.cs_config_update.config_id = params->cs_config_update.config_id; + param.cs_config_update.action = params->cs_config_update.action; + param.cs_config_update.main_mode_type = params->cs_config_update.main_mode_type; + param.cs_config_update.sub_mode_type = params->cs_config_update.sub_mode_type; + param.cs_config_update.min_main_mode_steps = params->cs_config_update.min_main_mode_steps; + param.cs_config_update.max_main_mode_steps = params->cs_config_update.max_main_mode_steps; + param.cs_config_update.main_mode_repetition = params->cs_config_update.main_mode_repetition; + param.cs_config_update.mode_0_steps = params->cs_config_update.mode_0_steps; + param.cs_config_update.role = params->cs_config_update.role; + param.cs_config_update.rtt_type = params->cs_config_update.rtt_type; + param.cs_config_update.cs_sync_phy = params->cs_config_update.cs_sync_phy; + memcpy(param.cs_config_update.channel_map, params->cs_config_update.channel_map, 10); + param.cs_config_update.channel_map_repetition = params->cs_config_update.channel_map_repetition; + param.cs_config_update.channel_selection_type = params->cs_config_update.channel_selection_type; + param.cs_config_update.ch3c_shape = params->cs_config_update.ch3c_shape; + param.cs_config_update.ch3c_jump = params->cs_config_update.ch3c_jump; + param.cs_config_update.reserved = params->cs_config_update.reserved; + param.cs_config_update.t_ip1_time = params->cs_config_update.t_ip1_time; + param.cs_config_update.t_ip2_time = params->cs_config_update.t_ip2_time; + param.cs_config_update.t_fcs_time = params->cs_config_update.t_fcs_time; + param.cs_config_update.t_pm_time = params->cs_config_update.t_pm_time; + break; + case BTA_BLE_GAP_CS_SUBEVENT_RESULT_EVT: + msg.act = ESP_GAP_BLE_CS_SUBEVENT_RESULT_EVT; + param.cs_subevt_result.conn_handle = params->cs_subevt_result.conn_handle; + param.cs_subevt_result.config_id = params->cs_subevt_result.config_id; + param.cs_subevt_result.start_acl_conn_event_counter = params->cs_subevt_result.start_acl_conn_event_counter; + param.cs_subevt_result.procedure_counter = params->cs_subevt_result.procedure_counter; + param.cs_subevt_result.frequency_compensation = params->cs_subevt_result.frequency_compensation; + param.cs_subevt_result.reference_power_level = params->cs_subevt_result.reference_power_level; + param.cs_subevt_result.procedure_done_status = params->cs_subevt_result.procedure_done_status; + param.cs_subevt_result.subevent_done_status = params->cs_subevt_result.subevent_done_status; + param.cs_subevt_result.abort_reason = params->cs_subevt_result.abort_reason; + param.cs_subevt_result.num_ant_paths = params->cs_subevt_result.num_ant_paths; + param.cs_subevt_result.num_steps_reported = params->cs_subevt_result.num_steps_reported; + param.cs_subevt_result.step_info = (esp_ble_cs_step_info *)params->cs_subevt_result.step_info; + break; + case BTA_BLE_GAP_CS_SUBEVENT_RESULT_CONTINUE_EVT: + msg.act = ESP_GAP_BLE_CS_SUBEVENT_RESULT_CONTINUE_EVT; + param.cs_subevt_result_continue.conn_handle = params->cs_subevt_result_continue.conn_handle; + param.cs_subevt_result_continue.config_id = params->cs_subevt_result_continue.config_id; + param.cs_subevt_result_continue.proc_done_status = params->cs_subevt_result_continue.proc_done_status; + param.cs_subevt_result_continue.subevt_done_status = params->cs_subevt_result_continue.subevt_done_status; + param.cs_subevt_result_continue.abort_reason = params->cs_subevt_result_continue.abort_reason; + param.cs_subevt_result_continue.num_ant_paths = params->cs_subevt_result_continue.num_ant_paths; + param.cs_subevt_result_continue.num_steps_reported = params->cs_subevt_result_continue.num_steps_reported; + param.cs_subevt_result_continue.step_info = (esp_ble_cs_step_info *)params->cs_subevt_result_continue.step_info; + break; +#endif // (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE) default: break; } ret = btc_transfer_context(&msg, ¶m, - sizeof(esp_ble_gap_cb_param_t), NULL, NULL); + sizeof(esp_ble_gap_cb_param_t), btc_gap_ble_cb_deep_copy, btc_gap_ble_cb_deep_free); if (ret != BT_STATUS_SUCCESS) { BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__); @@ -1978,6 +2174,60 @@ void btc_gap_ble_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src) } break; } +#if (BT_BLE_FEAT_PAWR_EN == TRUE) + case BTC_GAP_BLE_SET_PA_SUBEVT_DATA: { + btc_ble_5_gap_args_t *src = (btc_ble_5_gap_args_t *)p_src; + btc_ble_5_gap_args_t *dst = (btc_ble_5_gap_args_t *)p_dest; + if (src->per_adv_subevent_data_params.subevent_params) { + uint16_t params_len = src->per_adv_subevent_data_params.num_subevents_with_data * sizeof(esp_ble_subevent_params); + dst->per_adv_subevent_data_params.subevent_params = osi_malloc(params_len); + if (dst->per_adv_subevent_data_params.subevent_params) { + + for (uint8_t i = 0; i < src->per_adv_subevent_data_params.num_subevents_with_data; i++) + { + memcpy(&dst->per_adv_subevent_data_params.subevent_params[i], &src->per_adv_subevent_data_params.subevent_params[i], params_len); + // dst->per_adv_subevent_data_params.subevent_params[i].subevent = src->per_adv_subevent_data_params.subevent_params[i].subevent; + // dst->per_adv_subevent_data_params.subevent_params[i].response_slot_start = src->per_adv_subevent_data_params.subevent_params[i].response_slot_start; + // dst->per_adv_subevent_data_params.subevent_params[i].response_slot_count = src->per_adv_subevent_data_params.subevent_params[i].response_slot_count; + // dst->per_adv_subevent_data_params.subevent_params[i].subevent_data_len = src->per_adv_subevent_data_params.subevent_params[i].subevent_data_len; + dst->per_adv_subevent_data_params.subevent_params[i].subevent_data = osi_malloc(src->per_adv_subevent_data_params.subevent_params[i].subevent_data_len); + if (dst->per_adv_subevent_data_params.subevent_params[i].subevent_data) { + memcpy(dst->per_adv_subevent_data_params.subevent_params[i].subevent_data, src->per_adv_subevent_data_params.subevent_params[i].subevent_data, src->per_adv_subevent_data_params.subevent_params[i].subevent_data_len); + } else if (src->per_adv_subevent_data_params.subevent_params[i].subevent_data_len != 0) { + BTC_TRACE_ERROR("%s %d no mem\n",__func__, msg->act); + } + } + } + } + break; + } + case BTC_GAP_BLE_SET_PA_RSP_DATA: { + btc_ble_5_gap_args_t *src = (btc_ble_5_gap_args_t *)p_src; + btc_ble_5_gap_args_t *dst = (btc_ble_5_gap_args_t *)p_dest; + if (src->per_adv_response_data_params.response_data && src->per_adv_response_data_params.response_data_len) { + dst->per_adv_response_data_params.response_data = osi_malloc(src->per_adv_response_data_params.response_data_len); + if (dst->per_adv_response_data_params.response_data) { + memcpy(dst->per_adv_response_data_params.response_data, src->per_adv_response_data_params.response_data, src->per_adv_response_data_params.response_data_len); + } else { + BTC_TRACE_ERROR("%s %d no mem\n",__func__, msg->act); + } + } + break; + } + case BTC_GAP_BLE_SET_PA_SYNC_SUBEVT: { + btc_ble_5_gap_args_t *src = (btc_ble_5_gap_args_t *)p_src; + btc_ble_5_gap_args_t *dst = (btc_ble_5_gap_args_t *)p_dest; + if (src->per_sync_subevent_params.subevent && src->per_sync_subevent_params.num_subevents_to_sync) { + dst->per_sync_subevent_params.subevent = osi_malloc(src->per_sync_subevent_params.num_subevents_to_sync); + if (dst->per_sync_subevent_params.subevent) { + memcpy(dst->per_sync_subevent_params.subevent, src->per_sync_subevent_params.subevent, src->per_sync_subevent_params.num_subevents_to_sync); + } else { + BTC_TRACE_ERROR("%s %d no mem\n",__func__, msg->act); + } + } + break; + } +#endif // #if (BT_BLE_FEAT_PAWR_EN == TRUE) default: BTC_TRACE_ERROR("Unhandled deep copy %d\n", msg->act); break; @@ -2014,8 +2264,84 @@ void btc_gap_ble_cb_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src) } break; } +#if (BT_BLE_FEAT_PAWR_EN == TRUE) + case ESP_GAP_BLE_PERIODIC_ADV_RESPONSE_REPORT_EVT: + if (src->pa_rsp_rpt_evt.pa_rsp_info) { + dst->pa_rsp_rpt_evt.pa_rsp_info = osi_malloc(src->pa_rsp_rpt_evt.num_rsp * sizeof(esp_ble_pa_rsp_info)); + if (dst->pa_rsp_rpt_evt.pa_rsp_info) { + for (UINT8 i = 0; i < src->pa_rsp_rpt_evt.num_rsp; i++) + { + dst->pa_rsp_rpt_evt.pa_rsp_info[i].tx_power = src->pa_rsp_rpt_evt.pa_rsp_info[i].tx_power; + dst->pa_rsp_rpt_evt.pa_rsp_info[i].rssi = src->pa_rsp_rpt_evt.pa_rsp_info[i].rssi; + dst->pa_rsp_rpt_evt.pa_rsp_info[i].cte_type = src->pa_rsp_rpt_evt.pa_rsp_info[i].cte_type; + dst->pa_rsp_rpt_evt.pa_rsp_info[i].rsp_slot = src->pa_rsp_rpt_evt.pa_rsp_info[i].rsp_slot; + dst->pa_rsp_rpt_evt.pa_rsp_info[i].data_status = src->pa_rsp_rpt_evt.pa_rsp_info[i].data_status; + dst->pa_rsp_rpt_evt.pa_rsp_info[i].data_len = src->pa_rsp_rpt_evt.pa_rsp_info[i].data_len; + if (src->pa_rsp_rpt_evt.pa_rsp_info[i].data_len) { + dst->pa_rsp_rpt_evt.pa_rsp_info[i].data = osi_malloc(src->pa_rsp_rpt_evt.pa_rsp_info[i].data_len); + if (dst->pa_rsp_rpt_evt.pa_rsp_info[i].data) { + memcpy(dst->pa_rsp_rpt_evt.pa_rsp_info[i].data, src->pa_rsp_rpt_evt.pa_rsp_info[i].data, src->pa_rsp_rpt_evt.pa_rsp_info[i].data_len); + } else { + BTC_TRACE_ERROR("%s, data, no enough memory.", __func__); + } + } + } + } else { + BTC_TRACE_ERROR("%s, pa_rsp_info, no enough memory.", __func__); + } + } + break; +#endif // (BT_BLE_FEAT_PAWR_EN == TRUE) +#if (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE) + case BTA_BLE_GAP_CS_SUBEVENT_RESULT_EVT: + if (src->cs_subevt_result.step_info) { + dst->cs_subevt_result.step_info = osi_malloc(src->cs_subevt_result.num_steps_reported * sizeof(esp_ble_cs_step_info)); + if (dst->cs_subevt_result.step_info) { + for (UINT8 i = 0; i < src->cs_subevt_result.num_steps_reported; i++) + { + dst->cs_subevt_result.step_info[i].step_mode = src->cs_subevt_result.step_info[i].step_mode; + dst->cs_subevt_result.step_info[i].step_channel = src->cs_subevt_result.step_info[i].step_channel; + dst->cs_subevt_result.step_info[i].step_data_len = src->cs_subevt_result.step_info[i].step_data_len; + if (src->cs_subevt_result.step_info[i].step_data_len) { + dst->cs_subevt_result.step_info[i].data = osi_malloc(src->cs_subevt_result.step_info[i].step_data_len); + if (dst->cs_subevt_result.step_info[i].data) { + memcpy(dst->cs_subevt_result.step_info[i].data, src->cs_subevt_result.step_info[i].data, src->cs_subevt_result.step_info[i].step_data_len); + } else { + BTC_TRACE_ERROR("%s, data, no enough memory.", __func__); + } + } + } + } else { + BTC_TRACE_ERROR("%s, pa_rsp_info, no enough memory.", __func__); + } + } + break; + case BTA_BLE_GAP_CS_SUBEVENT_RESULT_CONTINUE_EVT: + if (src->cs_subevt_result_continue.step_info) { + dst->cs_subevt_result_continue.step_info = osi_malloc(src->cs_subevt_result_continue.num_steps_reported * sizeof(esp_ble_cs_step_info)); + if (dst->cs_subevt_result_continue.step_info) { + for (UINT8 i = 0; i < src->cs_subevt_result_continue.num_steps_reported; i++) + { + dst->cs_subevt_result_continue.step_info[i].step_mode = src->cs_subevt_result_continue.step_info[i].step_mode; + dst->cs_subevt_result_continue.step_info[i].step_channel = src->cs_subevt_result_continue.step_info[i].step_channel; + dst->cs_subevt_result_continue.step_info[i].step_data_len = src->cs_subevt_result_continue.step_info[i].step_data_len; + if (src->cs_subevt_result_continue.step_info[i].step_data_len) { + dst->cs_subevt_result_continue.step_info[i].data = osi_malloc(src->cs_subevt_result_continue.step_info[i].step_data_len); + if (dst->cs_subevt_result_continue.step_info[i].data) { + memcpy(dst->cs_subevt_result_continue.step_info[i].data, src->cs_subevt_result_continue.step_info[i].data, src->cs_subevt_result.step_info[i].step_data_len); + } else { + BTC_TRACE_ERROR("%s, data, no enough memory.", __func__); + } + } + } + } else { + BTC_TRACE_ERROR("%s, pa_rsp_info, no enough memory.", __func__); + } + } + break; +#endif // (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE) default: - BTC_TRACE_ERROR("%s, Unhandled deep copy %d\n", __func__, msg->act); + // BTC_TRACE_ERROR("%s, Unhandled deep copy %d\n", __func__, msg->act); break; } } @@ -2136,6 +2462,35 @@ void btc_gap_ble_arg_deep_free(btc_msg_t *msg) break; } break; +#if (BT_BLE_FEAT_PAWR_EN == TRUE) + case BTC_GAP_BLE_SET_PA_SUBEVT_DATA: { + struct per_adv_subevent_data_params_args *per_adv_subevent_data_params = &((btc_ble_5_gap_args_t *)msg->arg)->per_adv_subevent_data_params; + if (per_adv_subevent_data_params->subevent_params) { + for (uint8_t i = 0; i < per_adv_subevent_data_params->num_subevents_with_data; i++) + { + if (per_adv_subevent_data_params->subevent_params[i].subevent_data) { + osi_free(per_adv_subevent_data_params->subevent_params[i].subevent_data); + } + } + osi_free(per_adv_subevent_data_params->subevent_params); + } + break; + } + case BTC_GAP_BLE_SET_PA_RSP_DATA: { + uint8_t *response_data = ((btc_ble_5_gap_args_t *)msg->arg)->per_adv_response_data_params.response_data; + if (response_data) { + osi_free(response_data); + } + break; + } + case BTC_GAP_BLE_SET_PA_SYNC_SUBEVT: { + uint8_t *subevent = ((btc_ble_5_gap_args_t *)msg->arg)->per_sync_subevent_params.subevent; + if (subevent) { + osi_free(subevent); + } + break; + } +#endif // #if (BT_BLE_FEAT_PAWR_EN == TRUE) default: BTC_TRACE_DEBUG("Unhandled deep free %d\n", msg->act); break; @@ -2167,6 +2522,52 @@ void btc_gap_ble_cb_deep_free(btc_msg_t *msg) } break; } +#if (BT_BLE_FEAT_PAWR_EN == TRUE) + case ESP_GAP_BLE_PERIODIC_ADV_RESPONSE_REPORT_EVT: + esp_ble_pa_rsp_info *pa_rsp_info = ((esp_ble_gap_cb_param_t *)msg->arg)->pa_rsp_rpt_evt.pa_rsp_info; + if (pa_rsp_info) { + uint8_t num_rsp = ((esp_ble_gap_cb_param_t *)msg->arg)->pa_rsp_rpt_evt.num_rsp; + for (UINT8 i = 0; i < num_rsp; i++) { + if (pa_rsp_info[i].data) { + osi_free(pa_rsp_info[i].data); + } + } + osi_free(pa_rsp_info); + } + break; +#endif // (BT_BLE_FEAT_PAWR_EN == TRUE) +#if (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE) + case BTA_BLE_GAP_CS_SUBEVENT_RESULT_EVT: + { + esp_ble_cs_step_info *step_info = ((esp_ble_gap_cb_param_t *)msg->arg)->cs_subevt_result.step_info; + if (step_info) { + uint8_t num_step = ((esp_ble_gap_cb_param_t *)msg->arg)->cs_subevt_result.num_steps_reported; + for (uint8_t i = 0; i < num_step; i++) + { + if (step_info[i].data) { + osi_free(step_info[i].data); + } + } + osi_free(step_info); + } + } + break; + case BTA_BLE_GAP_CS_SUBEVENT_RESULT_CONTINUE_EVT: + { + esp_ble_cs_step_info *step_info = ((esp_ble_gap_cb_param_t *)msg->arg)->cs_subevt_result_continue.step_info; + if (step_info) { + uint8_t num_step = ((esp_ble_gap_cb_param_t *)msg->arg)->cs_subevt_result_continue.num_steps_reported; + for (uint8_t i = 0; i < num_step; i++) + { + if (step_info[i].data) { + osi_free(step_info[i].data); + } + } + osi_free(step_info); + } + } + break; +#endif // (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE) default: BTC_TRACE_DEBUG("Unhandled deep free %d", msg->act); break; @@ -2453,7 +2854,10 @@ void btc_gap_ble_call_handler(btc_msg_t *msg) params.secondary_phy = arg_5->ext_adv_set_params.params.secondary_phy; params.sid = arg_5->ext_adv_set_params.params.sid; params.scan_req_notif = arg_5->ext_adv_set_params.params.scan_req_notif; - +#if (BT_BLE_FEAT_ADV_CODING_SELECTION == TRUE) + params.primary_adv_phy_options = arg_5->ext_adv_set_params.params.primary_adv_phy_options; + params.secondary_adv_phy_options= arg_5->ext_adv_set_params.params.secondary_adv_phy_options; +#endif // (BT_BLE_FEAT_ADV_CODING_SELECTION == TRUE) memcpy(params.peer_addr, arg_5->ext_adv_set_params.params.peer_addr, sizeof(BD_ADDR)); BTC_TRACE_DEBUG("BTC_GAP_BLE_SET_EXT_ADV_PARAMS"); @@ -2517,6 +2921,13 @@ void btc_gap_ble_call_handler(btc_msg_t *msg) params.interval_min = arg_5->peridic_adv_set_params.params.interval_min; params.interval_max = arg_5->peridic_adv_set_params.params.interval_max; params.properties = arg_5->peridic_adv_set_params.params.properties; +#if (BT_BLE_FEAT_PAWR_EN == TRUE) + params.num_subevents = arg_5->peridic_adv_set_params.params.num_subevents; + params.subevent_interval = arg_5->peridic_adv_set_params.params.subevent_interval; + params.rsp_slot_delay = arg_5->peridic_adv_set_params.params.rsp_slot_delay; + params.rsp_slot_spacing = arg_5->peridic_adv_set_params.params.rsp_slot_spacing; + params.num_rsp_slots = arg_5->peridic_adv_set_params.params.num_rsp_slots; +#endif // (BT_BLE_FEAT_PAWR_EN == TRUE) BTC_TRACE_DEBUG("BTC_GAP_BLE_SET_PERIODIC_ADV_PARAMS"); BTA_DmBleGapPeriodicAdvSetParams(arg_5->peridic_adv_set_params.instance, ¶ms); @@ -2725,6 +3136,57 @@ void btc_gap_ble_call_handler(btc_msg_t *msg) BTA_DmBleGapSetHostFeature(arg_5->set_host_feature_params.bit_num, arg_5->set_host_feature_params.bit_val); break; #endif // #if (BLE_50_FEATURE_SUPPORT == TRUE) +#if (BT_BLE_FEAT_PAWR_EN == TRUE) + case BTC_GAP_BLE_SET_PA_SUBEVT_DATA: + BTA_DmBleGapSetPASubevtData(arg_5->per_adv_subevent_data_params.adv_handle, arg_5->per_adv_subevent_data_params.num_subevents_with_data, (uint8_t *)(arg_5->per_adv_subevent_data_params.subevent_params)); + break; + case BTC_GAP_BLE_SET_PA_RSP_DATA: + BTA_DmBleGapSetPeriodicAdvRspData(arg_5->per_adv_response_data_params.sync_handle, arg_5->per_adv_response_data_params.request_event, arg_5->per_adv_response_data_params.request_subevent, + arg_5->per_adv_response_data_params.response_subevent, arg_5->per_adv_response_data_params.response_slot, arg_5->per_adv_response_data_params.response_data_len, arg_5->per_adv_response_data_params.response_data); + break; + case BTC_GAP_BLE_SET_PA_SYNC_SUBEVT: + BTA_DmBleGapSetPeriodicSyncSubevt(arg_5->per_sync_subevent_params.sync_handle, arg_5->per_sync_subevent_params.periodic_adv_properties, arg_5->per_sync_subevent_params.num_subevents_to_sync, arg_5->per_sync_subevent_params.subevent); + break; +#endif // #if (BT_BLE_FEAT_PAWR_EN == TRUE) +#if (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE) + case BTC_GAP_BLE_CS_READ_LOCAL_SUPPORTED_CAPS: + BTA_DmBleGapReadLocalSupportedCaps(); + break; + case BTC_GAP_BLE_CS_READ_REMOTE_SUPPORTED_CAPS: + BTA_DmBleGapReadRemoteSupportedCaps(arg_5->cs_read_remote_supp_caps.conn_handle); + break; + case BTC_GAP_BLE_CS_WRITE_CACHED_REMOTE_SUPPORTED_CAPS: + BTA_DmBleGapWriteCachedRemoteSupportedCaps((tBTA_DM_CS_WRITE_CACHED_REMOTE_SUPP_CAPS *)&arg_5->cs_write_cached_remote_supp_caps); + break; + case BTC_GAP_BLE_CS_SECURITY_ENABLE: + BTA_DmBleGapCsSecurityEnable(arg_5->cs_security_enable.conn_handle); + break; + case BTC_GAP_BLE_CS_SET_DEFAULT_SETTINGS: + BTA_DmBleGapCsSetDefaultSetting(arg_5->cs_set_default_settings_params.conn_handle, arg_5->cs_set_default_settings_params.role_enable, + arg_5->cs_set_default_settings_params.cs_sync_ant_selection, arg_5->cs_set_default_settings_params.max_tx_power); + break; + case BTC_GAP_BLE_CS_READ_REMOTE_FAE_TABLE: + BTA_DmBleGapCsReadRemoteFaeTable(arg_5->cs_read_remote_tab.conn_handle); + break; + case BTC_GAP_BLE_CS_WRITE_CACHED_REMOTE_FAE_TABLE: + BTA_DmBleGapWriteCachedRemoteFaeTable(arg_5->cs_write_cached_remote_fae_table_params.conn_handle, &arg_5->cs_write_cached_remote_fae_table_params.remote_fae_table[0], 72); + break; + case BTC_GAP_BLE_CS_CREATE_CONFIG: + BTA_DmBleGapCsCreateConfig((tBTA_DM_CS_CREATE_CONFIG_PARAMS*)&arg_5->cs_create_config_params); + break; + case BTC_GAP_BLE_CS_REMOVE_CONFIG: + BTA_DmBleGapCsRemoveConfig(arg_5->cs_remove_config_params.conn_handle, arg_5->cs_remove_config_params.config_id); + break; + case BTC_GAP_BLE_CS_SET_CAHNNEL_CLASSIFICATION: + BTA_DmBleGapCsSetChannelClass(&arg_5->cs_set_channel_class_params.channel_class[0], 10); + break; + case BTC_GAP_BLE_CS_SET_PROCEDURE_PARAMS: + BTA_DmBleGapCsSetProcPatams((tBTA_DM_CS_SET_PROC_PARAMS *)&arg_5->cs_set_procedure_params); + break; + case BTC_GAP_BLE_CS_PROCEDURE_ENABLE: + BTA_DmBleGapCsProcEnable(arg_5->cs_procedure_enable_params.conn_handle, arg_5->cs_procedure_enable_params.config_id, arg_5->cs_procedure_enable_params.enable); + break; +#endif // (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE) default: break; } diff --git a/components/bt/host/bluedroid/btc/profile/std/gatt/btc_gattc.c b/components/bt/host/bluedroid/btc/profile/std/gatt/btc_gattc.c index e8f7444368..9928a7ab2e 100644 --- a/components/bt/host/bluedroid/btc/profile/std/gatt/btc_gattc.c +++ b/components/bt/host/bluedroid/btc/profile/std/gatt/btc_gattc.c @@ -213,12 +213,21 @@ static void btc_gattc_app_unregister(btc_ble_gattc_args_t *arg) static void btc_gattc_open(btc_ble_gattc_args_t *arg) { tBTA_GATT_TRANSPORT transport = BTA_GATT_TRANSPORT_LE; - +#if (BT_BLE_FEAT_PAWR_EN == TRUE) + BTA_GATTC_Enh_Open(arg->open.gattc_if, arg->open.remote_bda, + arg->open.remote_addr_type, arg->open.is_direct, + transport, arg->open.is_aux, arg->open.own_addr_type, + arg->open.is_pawr_synced, arg->open.adv_handle, arg->open.subevent, + arg->open.phy_mask, (void *)&arg->open.phy_1m_conn_params, + (void *)&arg->open.phy_2m_conn_params, (void *)&arg->open.phy_coded_conn_params); +#else BTA_GATTC_Enh_Open(arg->open.gattc_if, arg->open.remote_bda, arg->open.remote_addr_type, arg->open.is_direct, transport, arg->open.is_aux, arg->open.own_addr_type, + false, 0xff, 0xff, arg->open.phy_mask, (void *)&arg->open.phy_1m_conn_params, (void *)&arg->open.phy_2m_conn_params, (void *)&arg->open.phy_coded_conn_params); +#endif // (BT_BLE_FEAT_PAWR_EN == TRUE) } static void btc_gattc_close(btc_ble_gattc_args_t *arg) diff --git a/components/bt/host/bluedroid/btc/profile/std/include/btc_gap_ble.h b/components/bt/host/bluedroid/btc/profile/std/include/btc_gap_ble.h index 03b1e0885d..8f844a50b8 100644 --- a/components/bt/host/bluedroid/btc/profile/std/include/btc_gap_ble.h +++ b/components/bt/host/bluedroid/btc/profile/std/include/btc_gap_ble.h @@ -141,6 +141,25 @@ typedef enum { BTC_GAP_ACT_SET_HOST_FEATURE, #endif // #if (BLE_50_FEATURE_SUPPORT == TRUE) BTC_GAP_BLE_READ_CHANNEL_MAP, +#if (BT_BLE_FEAT_PAWR_EN == TRUE) + BTC_GAP_BLE_SET_PA_SUBEVT_DATA, + BTC_GAP_BLE_SET_PA_RSP_DATA, + BTC_GAP_BLE_SET_PA_SYNC_SUBEVT, +#endif // #if (BT_BLE_FEAT_PAWR_EN == TRUE) +#if (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE) + BTC_GAP_BLE_CS_READ_LOCAL_SUPPORTED_CAPS, + BTC_GAP_BLE_CS_READ_REMOTE_SUPPORTED_CAPS, + BTC_GAP_BLE_CS_WRITE_CACHED_REMOTE_SUPPORTED_CAPS, + BTC_GAP_BLE_CS_SECURITY_ENABLE, + BTC_GAP_BLE_CS_SET_DEFAULT_SETTINGS, + BTC_GAP_BLE_CS_READ_REMOTE_FAE_TABLE, + BTC_GAP_BLE_CS_WRITE_CACHED_REMOTE_FAE_TABLE, + BTC_GAP_BLE_CS_CREATE_CONFIG, + BTC_GAP_BLE_CS_REMOVE_CONFIG, + BTC_GAP_BLE_CS_SET_CAHNNEL_CLASSIFICATION, + BTC_GAP_BLE_CS_SET_PROCEDURE_PARAMS, + BTC_GAP_BLE_CS_PROCEDURE_ENABLE, +#endif // (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE) } btc_gap_ble_act_t; /* btc_ble_gap_args_t */ @@ -531,9 +550,136 @@ typedef union { } subrate_req_param; #endif // #if (BLE_FEAT_CONN_SUBRATING == TRUE) struct set_host_feature_arg { - uint16_t bit_num; - uint8_t bit_val; - } set_host_feature_params; + uint16_t bit_num; + uint8_t bit_val; + } set_host_feature_params; +#if (BT_BLE_FEAT_PAWR_EN == TRUE) + // BTC_GAP_BLE_SET_PA_SUBEVT_DATA + struct per_adv_subevent_data_params_args { + uint8_t adv_handle; + uint8_t num_subevents_with_data; + esp_ble_subevent_params *subevent_params; + } per_adv_subevent_data_params; + // BTC_GAP_BLE_SET_PA_RSP_DATA + struct per_adv_response_data_params_args { + uint16_t sync_handle; + uint16_t request_event; + uint8_t request_subevent; + uint8_t response_subevent; + uint8_t response_slot; + uint8_t response_data_len; + uint8_t *response_data; + } per_adv_response_data_params; + // BTC_GAP_BLE_SET_PA_SYNC_SUBEVT + struct per_sync_subevent_params_args { + uint16_t sync_handle; + uint16_t periodic_adv_properties; + uint8_t num_subevents_to_sync; + uint8_t *subevent; + } per_sync_subevent_params; +#endif // #if (BT_BLE_FEAT_PAWR_EN == TRUE) +#if (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE) + struct cs_read_remote_supp_caps_args { + uint16_t conn_handle; + } cs_read_remote_supp_caps; + + struct cs_write_cached_remote_supp_caps_args { + uint16_t conn_handle; + uint8_t num_config_supported; + uint16_t max_consecutive_proc_supported; + uint8_t num_ant_supported; + uint8_t max_ant_paths_supported; + uint8_t roles_supported; + uint8_t 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 NADM_sounding_capability; + uint16_t NADM_random_capability; + uint8_t cs_sync_phys_supported; + uint16_t subfeatures_supported; + uint16_t T_IP1_times_supported; + uint16_t T_IP2_times_supported; + uint16_t T_FCS_times_supported; + uint16_t T_PM_times_supported; + uint8_t T_SW_times_supported; + uint8_t TX_SNR_capability; + } cs_write_cached_remote_supp_caps; + + struct cs_security_enable_args { + uint16_t conn_handle; + } cs_security_enable; + + struct cs_set_default_settings_params_args { + uint16_t conn_handle; + uint8_t role_enable; + uint8_t cs_sync_ant_selection; + int8_t max_tx_power; + } cs_set_default_settings_params; + + struct cs_read_remote_tab_args { + uint16_t conn_handle; + } cs_read_remote_tab; + + struct cs_write_cached_remote_fae_table_params_args { + uint16_t conn_handle; + uint8_t remote_fae_table[72]; + } cs_write_cached_remote_fae_table_params; + + struct cs_create_config_params_args { + 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 reserved; + } cs_create_config_params; + + struct cs_remove_config_params_args { + uint16_t conn_handle; + uint8_t config_id; + } cs_remove_config_params; + + struct cs_set_channel_class_params_args { + uint8_t channel_class[10]; + } cs_set_channel_class_params; + + struct cs_set_procedure_params_args { + uint16_t conn_handle; + uint8_t config_id; + uint16_t max_procedure_len; + uint16_t min_procedure_interval; + uint16_t max_procedure_interval; + uint16_t max_procedure_count; + uint32_t min_subevent_len; + uint32_t max_subevent_len; + uint8_t tone_ant_config_selection; + uint8_t phy; + uint8_t tx_power_delta; + uint8_t preferred_peer_antenna; + uint8_t SNR_control_initiator; + uint8_t SNR_control_reflector; + } cs_set_procedure_params; + + struct cs_procedure_enable_params_args { + uint16_t conn_handle; + uint8_t config_id; + uint8_t enable; + } cs_procedure_enable_params; +#endif // (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE) } btc_ble_5_gap_args_t; #endif // #if (BLE_50_FEATURE_SUPPORT == TRUE) diff --git a/components/bt/host/bluedroid/btc/profile/std/include/btc_gattc.h b/components/bt/host/bluedroid/btc/profile/std/include/btc_gattc.h index 1c8ef828b0..7580b7f17c 100644 --- a/components/bt/host/bluedroid/btc/profile/std/include/btc_gattc.h +++ b/components/bt/host/bluedroid/btc/profile/std/include/btc_gattc.h @@ -58,6 +58,9 @@ typedef union { bool is_direct; bool is_aux; esp_ble_addr_type_t own_addr_type; + bool is_pawr_synced; + uint8_t adv_handle; + uint8_t subevent; esp_ble_phy_mask_t phy_mask; esp_ble_conn_params_t phy_1m_conn_params; esp_ble_conn_params_t phy_2m_conn_params; diff --git a/components/bt/host/bluedroid/common/include/common/bluedroid_user_config.h b/components/bt/host/bluedroid/common/include/common/bluedroid_user_config.h index 16a6320dbe..70e967b44b 100644 --- a/components/bt/host/bluedroid/common/include/common/bluedroid_user_config.h +++ b/components/bt/host/bluedroid/common/include/common/bluedroid_user_config.h @@ -364,6 +364,24 @@ #define UC_BT_BLE_FEAT_CONN_SUBRATING FALSE #endif +#ifdef CONFIG_BT_BLE_FEAT_PAWR_EN +#define UC_BT_BLE_FEAT_PAWR_EN CONFIG_BT_BLE_FEAT_PAWR_EN +#else +#define UC_BT_BLE_FEAT_PAWR_EN FALSE +#endif + +#ifdef CONFIG_BT_BLE_FEAT_ADV_CODING_SELECTION +#define UC_BT_BLE_FEAT_ADV_CODING_SELECTION CONFIG_BT_BLE_FEAT_ADV_CODING_SELECTION +#else +#define UC_BT_BLE_FEAT_ADV_CODING_SELECTION FALSE +#endif + +#ifdef CONFIG_BT_BLE_FEAT_CHANNEL_SOUNDING +#define UC_BT_BLE_FEAT_CHANNEL_SOUNDING CONFIG_BT_BLE_FEAT_CHANNEL_SOUNDING +#else +#define UC_BT_BLE_FEAT_CHANNEL_SOUNDING FALSE +#endif + #ifdef CONFIG_BT_BLE_VENDOR_HCI_EN #define UC_BT_BLE_VENDOR_HCI_EN CONFIG_BT_BLE_VENDOR_HCI_EN #else @@ -568,6 +586,12 @@ #define UC_BT_GATTS_APPEARANCE_WRITABLE FALSE #endif +#ifdef CONFIG_BT_GATTS_SECURITY_LEVELS_CHAR +#define UC_BT_GATTS_SECURITY_LEVELS_CHAR CONFIG_BT_GATTS_SECURITY_LEVELS_CHAR +#else +#define UC_BT_GATTS_SECURITY_LEVELS_CHAR FALSE +#endif + #ifdef CONFIG_BT_BLE_ACT_SCAN_REP_ADV_SCAN #define UC_BT_BLE_ACT_SCAN_REP_ADV_SCAN CONFIG_BT_BLE_ACT_SCAN_REP_ADV_SCAN #else diff --git a/components/bt/host/bluedroid/common/include/common/bt_target.h b/components/bt/host/bluedroid/common/include/common/bt_target.h index 6ec7ec52ba..412ca9dd06 100644 --- a/components/bt/host/bluedroid/common/include/common/bt_target.h +++ b/components/bt/host/bluedroid/common/include/common/bt_target.h @@ -415,6 +415,24 @@ #define BLE_FEAT_CONN_SUBRATING FALSE #endif +#if (UC_BT_BLE_FEAT_PAWR_EN == TRUE) +#define BT_BLE_FEAT_PAWR_EN TRUE +#else +#define BT_BLE_FEAT_PAWR_EN FALSE +#endif + +#if (UC_BT_BLE_FEAT_ADV_CODING_SELECTION == TRUE) +#define BT_BLE_FEAT_ADV_CODING_SELECTION TRUE +#else +#define BT_BLE_FEAT_ADV_CODING_SELECTION FALSE +#endif + +#if (UC_BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE) +#define BT_BLE_FEAT_CHANNEL_SOUNDING TRUE +#else +#define BT_BLE_FEAT_CHANNEL_SOUNDING FALSE +#endif + #if (UC_BT_BLE_VENDOR_HCI_EN == TRUE) #define BLE_VENDOR_HCI_EN TRUE #else @@ -786,6 +804,12 @@ #define GATTS_APPEARANCE_WRITABLE FALSE #endif +#if (UC_BT_GATTS_SECURITY_LEVELS_CHAR == TRUE) +#define BT_GATTS_SECURITY_LEVELS_CHAR TRUE +#else +#define BT_GATTS_SECURITY_LEVELS_CHAR FALSE +#endif + #ifdef UC_BT_BLE_ACT_SCAN_REP_ADV_SCAN #define BTM_BLE_ACTIVE_SCAN_REPORT_ADV_SCAN_RSP_INDIVIDUALLY UC_BT_BLE_ACT_SCAN_REP_ADV_SCAN #endif diff --git a/components/bt/host/bluedroid/device/controller.c b/components/bt/host/bluedroid/device/controller.c index 4b68eb93c8..0364ba2ca9 100644 --- a/components/bt/host/bluedroid/device/controller.c +++ b/components/bt/host/bluedroid/device/controller.c @@ -31,7 +31,7 @@ #include "osi/future.h" #include "config/stack_config.h" #if (BLE_50_FEATURE_SUPPORT == TRUE) -const bt_event_mask_t BLE_EVENT_MASK = { "\x00\x00\x00\x07\xff\xff\xff\xff" }; +const bt_event_mask_t BLE_EVENT_MASK = { "\x00\x00\x00\xff\xff\xff\xff\xff" }; #else const bt_event_mask_t BLE_EVENT_MASK = { "\x00\x00\x00\x00\x00\x00\x06\x7f" }; #endif // #if (BLE_50_FEATURE_SUPPORT == TRUE) diff --git a/components/bt/host/bluedroid/stack/btm/btm_ble_5_gap.c b/components/bt/host/bluedroid/stack/btm/btm_ble_5_gap.c index 4b3372504e..b87c9d35f6 100644 --- a/components/bt/host/bluedroid/stack/btm/btm_ble_5_gap.c +++ b/components/bt/host/bluedroid/stack/btm/btm_ble_5_gap.c @@ -401,7 +401,18 @@ tBTM_STATUS BTM_BleSetExtendedAdvParams(UINT8 instance, tBTM_BLE_GAP_EXT_ADV_PAR #else btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type = params->own_addr_type; #endif - +#if (BT_BLE_FEAT_ADV_CODING_SELECTION == TRUE) + if ((err = btsnd_hcic_ble_set_ext_adv_params_v2(instance, params->type, params->interval_min, params->interval_max, + params->channel_map, params->own_addr_type, params->peer_addr_type, + params->peer_addr, params->filter_policy, params->tx_power, + params->primary_phy, params->max_skip, + params->secondary_phy, params->sid, params->scan_req_notif, + params->primary_adv_phy_options, params->secondary_adv_phy_options)) != HCI_SUCCESS) { + BTM_TRACE_ERROR("LE EA SetParams: cmd err=0x%x", err); + status = BTM_HCI_ERROR | err; + goto end; + } +#else if ((err = btsnd_hcic_ble_set_ext_adv_params(instance, params->type, params->interval_min, params->interval_max, params->channel_map, params->own_addr_type, params->peer_addr_type, params->peer_addr, params->filter_policy, params->tx_power, @@ -411,6 +422,7 @@ tBTM_STATUS BTM_BleSetExtendedAdvParams(UINT8 instance, tBTM_BLE_GAP_EXT_ADV_PAR status = BTM_HCI_ERROR | err; goto end; } +#endif // (BT_BLE_FEAT_ADV_CODING_SELECTION == TRUE) extend_adv_cb.inst[instance].configured = true; @@ -692,7 +704,6 @@ tBTM_STATUS BTM_BlePeriodicAdvSetParams(UINT8 instance, tBTM_BLE_Periodic_Adv_Pa tBTM_STATUS status = BTM_SUCCESS; tHCI_STATUS err = HCI_SUCCESS; tBTM_BLE_5_GAP_CB_PARAMS cb_params = {0}; - //ext_adv_flag = true; if (instance >= MAX_BLE_ADV_INSTANCE) { status = BTM_ILLEGAL_VALUE; @@ -710,11 +721,20 @@ tBTM_STATUS BTM_BlePeriodicAdvSetParams(UINT8 instance, tBTM_BLE_Periodic_Adv_Pa goto end; } - if ((err= btsnd_hcic_ble_set_periodic_adv_params(instance, params->interval_min, +#if (BT_BLE_FEAT_PAWR_EN == TRUE) + if ((err = btsnd_hcic_ble_set_periodic_adv_params_v2(instance, params->interval_min, params->interval_max, + params->properties, params->num_subevents, params->subevent_interval, + params->rsp_slot_delay, params->rsp_slot_spacing, params->num_rsp_slots)) != HCI_SUCCESS) { + BTM_TRACE_ERROR("LE PA SetParams_V2: cmd err=0x%x", err); + status = BTM_HCI_ERROR | err; + } +#else + if ((err = btsnd_hcic_ble_set_periodic_adv_params(instance, params->interval_min, params->interval_max, params->properties)) != HCI_SUCCESS) { BTM_TRACE_ERROR("LE PA SetParams: cmd err=0x%x", err); status = BTM_HCI_ERROR | err; } +#endif // (BT_BLE_FEAT_PAWR_EN == TRUE) end: @@ -1740,3 +1760,352 @@ tBTM_STATUS BTM_BleSetHostFeature(uint16_t bit_num, uint8_t bit_val) return status; } #endif // #if (BLE_50_FEATURE_SUPPORT == TRUE) + +#if (BT_BLE_FEAT_PAWR_EN == TRUE) +void BTM_BleSetPaSubeventData(UINT8 adv_handle, UINT8 num_subevents_with_data, uint8_t *subevent_params) +{ + tBTM_STATUS status = BTM_SUCCESS; + tHCI_STATUS err = HCI_SUCCESS; + tBTM_BLE_5_GAP_CB_PARAMS cb_params = {0}; + + if ((err = btsnd_hcic_ble_set_periodic_adv_subevt_data(adv_handle, num_subevents_with_data, (ble_subevent_params *)subevent_params)) != HCI_SUCCESS) { + BTM_TRACE_ERROR("%s cmd err = 0x%x", __func__, err); + status = BTM_HCI_ERROR | err; + } + + cb_params.pa_subevt_data_evt.status = status; + cb_params.pa_subevt_data_evt.adv_handle = adv_handle; + + BTM_ExtBleCallbackTrigger(BTM_BLE_GAP_SET_PERIODIC_ADV_SUBEVT_DATA_EVT, &cb_params); +} + +void BTM_BleSetPaResponseData(UINT16 sync_handle, UINT16 req_evt, UINT8 req_subevt, UINT8 rsp_subevt, UINT8 rsp_slot, UINT8 rsp_data_len, UINT8 *rsp_data) +{ + tBTM_STATUS status = BTM_SUCCESS; + tHCI_STATUS err = HCI_SUCCESS; + tBTM_BLE_5_GAP_CB_PARAMS cb_params = {0}; + + if ((err = btsnd_hcic_ble_set_periodic_adv_rsp_data(sync_handle, req_evt, req_subevt, rsp_subevt, rsp_slot, rsp_data_len, rsp_data)) != HCI_SUCCESS) { + BTM_TRACE_ERROR("%s cmd err = 0x%x", __func__, err); + status = BTM_HCI_ERROR | err; + } + + cb_params.pa_rsp_data_evt.status = status; + cb_params.pa_rsp_data_evt.sync_handle = sync_handle; + + BTM_ExtBleCallbackTrigger(BTM_BLE_GAP_SET_PERIODIC_ADV_RESPONSE_DATA_EVT, &cb_params); +} + +void BTM_BleSetPaSyncSubevt(UINT16 sync_handle, UINT16 periodic_adv_properties, UINT8 num_subevents_to_sync, UINT8 *subevt) +{ + tBTM_STATUS status = BTM_SUCCESS; + tHCI_STATUS err = HCI_SUCCESS; + tBTM_BLE_5_GAP_CB_PARAMS cb_params = {0}; + + if ((err = btsnd_hcic_ble_set_periodic_sync_subevt(sync_handle, periodic_adv_properties, num_subevents_to_sync, subevt)) != HCI_SUCCESS) { + BTM_TRACE_ERROR("%s cmd err = 0x%x", __func__, err); + status = BTM_HCI_ERROR | err; + } + + cb_params.pa_sync_subevt_evt.status = status; + cb_params.pa_sync_subevt_evt.sync_handle = sync_handle; + + BTM_ExtBleCallbackTrigger(BTM_BLE_GAP_SET_PERIODIC_SYNC_SUBEVT_EVT, &cb_params); +} + +void btm_ble_pa_subevt_data_req_evt(tBTM_BLE_PA_SUBEVT_DATA_REQ_EVT *params) +{ + BTM_ExtBleCallbackTrigger(BTM_BLE_GAP_PERIODIC_ADV_SUBEVT_DATA_REQUEST_EVT, (tBTM_BLE_5_GAP_CB_PARAMS *)params); +} + +void btm_ble_pa_rsp_rpt_evt(tBTM_BLE_PA_RSP_REPORT_EVT *params) +{ + BTM_ExtBleCallbackTrigger(BTM_BLE_GAP_PERIODIC_ADV_RESPONSE_REPORT_EVT, (tBTM_BLE_5_GAP_CB_PARAMS *)params); +} + +#endif // #if (BT_BLE_FEAT_PAWR_EN == TRUE) + +#if (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE) +void BTM_BleCSReadLocalSuppCaps(void) +{ + btsnd_hcic_ble_cs_read_local_supported_caps(); +} + +void btm_ble_cs_read_local_supp_caps_cmpl_evt(uint8_t *p) +{ + tBTM_BLE_5_GAP_CB_PARAMS cb_params = {0}; + + STREAM_TO_UINT8(cb_params.cs_read_local_supp_caps.status, p); + if (cb_params.cs_read_local_supp_caps.status != HCI_SUCCESS) { + BTM_TRACE_ERROR("%s cmd err = 0x%x", __func__, cb_params.cs_read_local_supp_caps.status); + cb_params.cs_read_local_supp_caps.status |= BTM_HCI_ERROR; + goto _error; + } + + STREAM_TO_UINT16(cb_params.cs_read_local_supp_caps.conn_handle, p); + STREAM_TO_UINT8(cb_params.cs_read_local_supp_caps.num_config_supported, p); + STREAM_TO_UINT16(cb_params.cs_read_local_supp_caps.max_consecutive_proc_supported, p); + STREAM_TO_UINT8(cb_params.cs_read_local_supp_caps.num_ant_supported, p); + STREAM_TO_UINT8(cb_params.cs_read_local_supp_caps.max_ant_paths_supported, p); + STREAM_TO_UINT8(cb_params.cs_read_local_supp_caps.roles_supported, p); + STREAM_TO_UINT8(cb_params.cs_read_local_supp_caps.modes_supported, p); + STREAM_TO_UINT8(cb_params.cs_read_local_supp_caps.rtt_capability, p); + STREAM_TO_UINT8(cb_params.cs_read_local_supp_caps.rtt_aa_only_n, p); + STREAM_TO_UINT8(cb_params.cs_read_local_supp_caps.rtt_sounding_n, p); + STREAM_TO_UINT8(cb_params.cs_read_local_supp_caps.rtt_random_payload_n, p); + STREAM_TO_UINT16(cb_params.cs_read_local_supp_caps.NADM_sounding_capability, p); + STREAM_TO_UINT16(cb_params.cs_read_local_supp_caps.NADM_random_capability, p); + STREAM_TO_UINT8(cb_params.cs_read_local_supp_caps.cs_sync_phys_supported, p); + STREAM_TO_UINT16(cb_params.cs_read_local_supp_caps.subfeatures_supported, p); + STREAM_TO_UINT16(cb_params.cs_read_local_supp_caps.T_IP1_times_supported, p); + STREAM_TO_UINT16(cb_params.cs_read_local_supp_caps.T_IP2_times_supported, p); + STREAM_TO_UINT16(cb_params.cs_read_local_supp_caps.T_FCS_times_supported, p); + STREAM_TO_UINT16(cb_params.cs_read_local_supp_caps.T_PM_times_supported, p); + STREAM_TO_UINT8(cb_params.cs_read_local_supp_caps.T_SW_times_supported, p); + STREAM_TO_UINT8(cb_params.cs_read_local_supp_caps.TX_SNR_capability, p); + +_error: + + BTM_ExtBleCallbackTrigger(BTM_BLE_GAP_CS_READ_LOCAL_SUPP_CAPS_EVT, &cb_params); +} + +void BTM_BleCSReadRemoteSuppCaps(UINT16 conn_handle) +{ + btsnd_hcic_ble_cs_read_remote_supported_capabilities(conn_handle); +} + +void btm_ble_cs_read_remote_supp_caps_cmd_status(UINT8 status) +{ + if (status != HCI_SUCCESS) { + tBTM_BLE_CS_READ_REMOTE_SUPP_CAPS_CMPL_EVT cs_read_remote_supp_caps = {0}; + cs_read_remote_supp_caps.status = (status | BTM_HCI_ERROR); + + BTM_ExtBleCallbackTrigger(BTM_BLE_GAP_CS_READ_REMOTE_SUPP_CAPS_CMPL_EVT, (tBTM_BLE_5_GAP_CB_PARAMS *)&cs_read_remote_supp_caps); + } +} + +void BTM_BleGapWriteCachedRemoteSupportedCaps(UINT16 conn_handle, UINT8 num_config_supported, UINT16 max_consecutive_proc_supported, + UINT8 num_ant_supported, UINT8 max_ant_paths_supported, UINT8 roles_supported, + UINT8 modes_supported, UINT8 rtt_capability, UINT8 rtt_aa_only_n, + UINT8 rtt_sounding_n, UINT8 rtt_random_payload_n, UINT16 NADM_sounding_capability, + UINT16 NADM_random_capability, UINT8 cs_sync_phys_supported, UINT16 subfeatures_supported, + UINT16 T_IP1_times_supported, UINT16 T_IP2_times_supported, UINT16 T_FCS_times_supported, + UINT16 T_PM_times_supported, UINT8 T_SW_times_supported, UINT8 TX_SNR_capability) +{ + tBTM_STATUS status = BTM_SUCCESS; + tHCI_STATUS err = HCI_SUCCESS; + tBTM_BLE_5_GAP_CB_PARAMS cb_params = {0}; + + if ((err = btsnd_hcic_ble_cs_write_cached_remote_supported_capabilities(conn_handle, num_config_supported, max_consecutive_proc_supported, + num_ant_supported, max_ant_paths_supported, roles_supported, + modes_supported, rtt_capability, rtt_aa_only_n, + rtt_sounding_n, rtt_random_payload_n, NADM_sounding_capability, + NADM_random_capability, cs_sync_phys_supported, subfeatures_supported, + T_IP1_times_supported, T_IP2_times_supported, T_FCS_times_supported, + T_PM_times_supported, T_SW_times_supported, TX_SNR_capability)) != HCI_SUCCESS) { + BTM_TRACE_ERROR("cs write cached remote support caps, cmd err=0x%x", err); + status = BTM_HCI_ERROR | err; + } + + cb_params.cs_write_cached_remote_supp_caps.status = status; + cb_params.cs_write_cached_remote_supp_caps.conn_handle = conn_handle; + BTM_ExtBleCallbackTrigger(BTM_BLE_GAP_CS_WRITE_CACHED_REMOTE_SUPP_CAPS_EVT, &cb_params); +} + +void BTM_BleGapCsSecurityEnable(UINT16 conn_handle) +{ + btsnd_hcic_ble_cs_security_enable(conn_handle); +} + +void btm_ble_cs_security_enable_cmd_status(UINT8 status) +{ + tBTM_BLE_CS_SEC_ENABLE_CMPL_EVT cs_security_enable = {0}; + if (status != HCI_SUCCESS) { + cs_security_enable.status = (status | BTM_HCI_ERROR); + BTM_ExtBleCallbackTrigger(BTM_BLE_GAP_CS_SECURITY_ENABLE_CMPL_EVT, (tBTM_BLE_5_GAP_CB_PARAMS *)&cs_security_enable); + } +} + +void BTM_BleGapCsSetDefaultSetting(UINT16 conn_handle, UINT8 role_enable, UINT8 cs_sync_ant_selection, INT8 max_tx_power) +{ + tBTM_STATUS status = BTM_SUCCESS; + tHCI_STATUS err = HCI_SUCCESS; + tBTM_BLE_5_GAP_CB_PARAMS cb_params = {0}; + + if ((err = btsnd_hcic_ble_cs_set_default_settings(conn_handle, role_enable, cs_sync_ant_selection, max_tx_power)) != HCI_SUCCESS) { + BTM_TRACE_ERROR("cs set default setting, cmd err=0x%x", err); + status = BTM_HCI_ERROR | err; + } + + cb_params.cs_set_default_settings.status = status; + cb_params.cs_set_default_settings.conn_handle = conn_handle; + BTM_ExtBleCallbackTrigger(BTM_BLE_GAP_CS_SET_DEFAULT_SETTINGS_EVT, &cb_params); +} + +void BTM_BleGapCsReadRemoteFaeTable(UINT16 conn_handle) +{ + btsnd_hcic_ble_cs_read_remote_fae_table(conn_handle); +} + +void btm_ble_cs_read_remote_fae_table_cmd_status(UINT8 status) +{ + tBTM_BLE_CS_READ_REMOTE_FAE_TAB_CMPL_EVT cs_read_remote_fae_tab = {0}; + if (status != HCI_SUCCESS) { + cs_read_remote_fae_tab.status = (status | BTM_HCI_ERROR); + BTM_ExtBleCallbackTrigger(BTM_BLE_GAP_CS_READ_REMOTE_FAE_TABLE_CMPL_EVT, (tBTM_BLE_5_GAP_CB_PARAMS *)&cs_read_remote_fae_tab); + } +} + +void BTM_BleGapWriteCachedRemoteFaeTable(UINT16 conn_handle, UINT8 *remote_fae_table) +{ + tBTM_STATUS status = BTM_SUCCESS; + tHCI_STATUS err = HCI_SUCCESS; + tBTM_BLE_5_GAP_CB_PARAMS cb_params = {0}; + + if ((err = btsnd_hcic_ble_cs_write_cached_remote_fae_table(conn_handle, remote_fae_table)) != HCI_SUCCESS) { + BTM_TRACE_ERROR("cs write cached remote fae tab, cmd err=0x%x", err); + status = BTM_HCI_ERROR | err; + } + + cb_params.cs_write_cached_remote_fae_tab.status = status; + cb_params.cs_write_cached_remote_fae_tab.conn_handle = conn_handle; + BTM_ExtBleCallbackTrigger(BTM_BLE_GAP_CS_WRITE_CACHED_REMOTE_FAE_TAB_EVT, &cb_params); +} + +void BTM_BleGapCsCreateConfig(UINT16 conn_handle, UINT8 config_id, UINT8 create_context, + UINT8 main_mode_type, UINT8 sub_mode_type, UINT8 min_main_mode_steps, + UINT8 max_main_mode_steps, UINT8 main_mode_repetition, UINT8 mode_0_steps, + UINT8 role, UINT8 rtt_type, UINT8 cs_sync_phy, UINT8 *channel_map, + UINT8 channel_map_repetition, UINT8 channel_selection_type, UINT8 ch3c_shape, + UINT8 ch3c_jump,UINT8 reserved) +{ + btsnd_hcic_ble_cs_create_config(conn_handle, config_id, create_context, + main_mode_type, sub_mode_type, min_main_mode_steps, + max_main_mode_steps, main_mode_repetition, mode_0_steps, + role, rtt_type, cs_sync_phy, channel_map, + channel_map_repetition, channel_selection_type, ch3c_shape, + ch3c_jump, reserved); +} + +void BTM_BleGapCsRemoveConfig(UINT16 conn_handle, UINT8 config_id) +{ + btsnd_hcic_ble_cs_remove_config(conn_handle, config_id); +} + +void btm_ble_cs_update_config_cmd_status(UINT8 status, BOOLEAN create) +{ + tBTM_BLE_CS_CONFIG_CMPL_EVT config_cmpl = {0}; + if (status != HCI_SUCCESS) { + config_cmpl.status = (status | BTM_HCI_ERROR); + config_cmpl.action = (create? 0x01:0x00); + BTM_ExtBleCallbackTrigger(BTM_BLE_GAP_CS_CONFIG_CMPL_EVT, (tBTM_BLE_5_GAP_CB_PARAMS *)&config_cmpl); + } +} + +void BTM_BleGapCsSetChannelClass(UINT8 *channel_class) +{ + tBTM_STATUS status = BTM_SUCCESS; + tHCI_STATUS err = HCI_SUCCESS; + tBTM_BLE_5_GAP_CB_PARAMS cb_params = {0}; + + if ((err = btsnd_hcic_ble_cs_set_channel_classification(channel_class)) != HCI_SUCCESS) { + BTM_TRACE_ERROR("cs set channel class, cmd err=0x%x", err); + status = BTM_HCI_ERROR | err; + } + + cb_params.status = status; + BTM_ExtBleCallbackTrigger(BTM_BLE_GAP_CS_SET_CHANNEL_CLASS_CMPL_EVT, &cb_params); +} + +void BTM_BleGapCsSetProcPatams(UINT16 conn_handle, UINT8 config_id, UINT16 max_procedure_len, + UINT16 min_procedure_interval, UINT16 max_procedure_interval, + UINT16 max_procedure_count, UINT32 min_subevent_len, + UINT32 max_subevent_len, UINT8 tone_ant_config_selection, + UINT8 phy, UINT8 tx_power_delta, UINT8 preferred_peer_antenna, + UINT8 SNR_control_initiator, UINT8 SNR_control_reflector) +{ + tBTM_STATUS status = BTM_SUCCESS; + tHCI_STATUS err = HCI_SUCCESS; + tBTM_BLE_5_GAP_CB_PARAMS cb_params = {0}; + + if ((err = btsnd_hcic_ble_cs_set_procedure_params(conn_handle, config_id, max_procedure_len, + min_procedure_interval, max_procedure_interval, + max_procedure_count, min_subevent_len, + max_subevent_len, tone_ant_config_selection, + phy, tx_power_delta, preferred_peer_antenna, + SNR_control_initiator, SNR_control_reflector)) != HCI_SUCCESS) { + BTM_TRACE_ERROR("cs set procedure params, cmd err=0x%x", err); + status = BTM_HCI_ERROR | err; + } + + cb_params.cs_set_proc_params.status = status; + cb_params.cs_set_proc_params.conn_handle = conn_handle; + BTM_ExtBleCallbackTrigger(BTM_BLE_GAP_CS_PROC_PARAMS_CMPL_EVT, &cb_params); +} + +void BTM_BleGapCsProcEnable(UINT16 conn_handle, UINT8 config_id, UINT8 enable) +{ + btsnd_hcic_ble_cs_procedure_enable(conn_handle, config_id, enable); +} + +void btm_ble_cs_read_remote_supp_caps_cmpl_evt(tBTM_BLE_CS_READ_REMOTE_SUPP_CAPS_CMPL_EVT *cs_read_remote_supp_caps) +{ + if (cs_read_remote_supp_caps->status != HCI_SUCCESS) { + BTM_TRACE_ERROR("%s cmd err = 0x%x", __func__, cs_read_remote_supp_caps->status); + cs_read_remote_supp_caps->status |= BTM_HCI_ERROR; + } + + BTM_ExtBleCallbackTrigger(BTM_BLE_GAP_CS_READ_REMOTE_SUPP_CAPS_CMPL_EVT, (tBTM_BLE_5_GAP_CB_PARAMS *)cs_read_remote_supp_caps); +} + +void btm_ble_cs_read_remote_fae_tab_cmpl_evt(tBTM_BLE_CS_READ_REMOTE_FAE_TAB_CMPL_EVT *cs_read_remote_fae_tab) +{ + if (cs_read_remote_fae_tab->status != HCI_SUCCESS) { + BTM_TRACE_ERROR("%s cmd err = 0x%x", __func__, cs_read_remote_fae_tab->status); + cs_read_remote_fae_tab->status |= BTM_HCI_ERROR; + } + + BTM_ExtBleCallbackTrigger(BTM_BLE_GAP_CS_READ_REMOTE_FAE_TABLE_CMPL_EVT, (tBTM_BLE_5_GAP_CB_PARAMS *)cs_read_remote_fae_tab); +} + +void btm_ble_cs_securuty_enable_cmpl_evt(tBTM_BLE_CS_SEC_ENABLE_CMPL_EVT *cs_security_enable) +{ + if (cs_security_enable->status != HCI_SUCCESS) { + BTM_TRACE_ERROR("%s cmd err = 0x%x", __func__, cs_security_enable->status); + cs_security_enable->status |= BTM_HCI_ERROR; + } + + BTM_ExtBleCallbackTrigger(BTM_BLE_GAP_CS_SECURITY_ENABLE_CMPL_EVT, (tBTM_BLE_5_GAP_CB_PARAMS *)cs_security_enable); +} + +void btm_ble_cs_config_cmpl_evt(tBTM_BLE_CS_CONFIG_CMPL_EVT *config_cmpl) +{ + if (config_cmpl->status != HCI_SUCCESS) { + BTM_TRACE_ERROR("%s cmd err = 0x%x", __func__, config_cmpl->status); + config_cmpl->status |= BTM_HCI_ERROR; + } + + BTM_ExtBleCallbackTrigger(BTM_BLE_GAP_CS_CONFIG_CMPL_EVT, (tBTM_BLE_5_GAP_CB_PARAMS *)config_cmpl); +} + +void btm_ble_cs_proc_enable_cmpl_evt(tBTM_BLE_CS_PROC_ENABLE_CMPL_EVT *proc_en) +{ + if (proc_en->status != HCI_SUCCESS) { + BTM_TRACE_ERROR("%s cmd err = 0x%x", __func__, proc_en->status); + proc_en->status |= BTM_HCI_ERROR; + } + + BTM_ExtBleCallbackTrigger(BTM_BLE_GAP_CS_PROC_ENABLE_CMPL_EVT, (tBTM_BLE_5_GAP_CB_PARAMS *)proc_en); +} + +void btm_ble_cs_subevt_result_evt(tBTM_BLE_CS_SUBEVT_RESULT_CMPL_EVT *subevt_result) +{ + BTM_ExtBleCallbackTrigger(BTM_BLE_GAP_CS_SUBEVENT_RESULT_EVT, (tBTM_BLE_5_GAP_CB_PARAMS *)subevt_result); +} + +void btm_ble_cs_subevt_continue_result_evt(tBTM_BLE_CS_SUBEVT_RESULT_CONTINUE_EVT *subevt_result_continue) +{ + BTM_ExtBleCallbackTrigger(BTM_BLE_GAP_CS_SUBEVENT_RESULT_CONTINUE_EVT, (tBTM_BLE_5_GAP_CB_PARAMS *)subevt_result_continue); +} + +#endif // (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE) diff --git a/components/bt/host/bluedroid/stack/btm/btm_ble_bgconn.c b/components/bt/host/bluedroid/stack/btm/btm_ble_bgconn.c index bf9b1adbff..1eb67844f1 100644 --- a/components/bt/host/bluedroid/stack/btm/btm_ble_bgconn.c +++ b/components/bt/host/bluedroid/stack/btm/btm_ble_bgconn.c @@ -671,7 +671,7 @@ void btm_ble_initiate_select_conn(BD_ADDR bda) BTM_TRACE_EVENT ("btm_ble_initiate_select_conn"); /* use direct connection procedure to initiate connection */ - if (!L2CA_ConnectFixedChnl(L2CAP_ATT_CID, bda, BLE_ADDR_UNKNOWN_TYPE, FALSE)) { + if (!L2CA_ConnectFixedChnl(L2CAP_ATT_CID, bda, BLE_ADDR_UNKNOWN_TYPE, FALSE, FALSE, 0xFF, 0xFF)) { BTM_TRACE_ERROR("btm_ble_initiate_select_conn failed"); } } diff --git a/components/bt/host/bluedroid/stack/btm/include/btm_ble_int.h b/components/bt/host/bluedroid/stack/btm/include/btm_ble_int.h index de25c6fa3e..c8181086f7 100644 --- a/components/bt/host/bluedroid/stack/btm/include/btm_ble_int.h +++ b/components/bt/host/bluedroid/stack/btm/include/btm_ble_int.h @@ -606,6 +606,21 @@ void btm_ble_transmit_power_report_evt(tBTM_BLE_TRANS_POWER_REPORT_EVT *params); #if (BLE_FEAT_CONN_SUBRATING == TRUE) void btm_ble_subrate_change_evt(tBTM_BLE_SUBRATE_CHANGE_EVT *params); #endif // #if (BLE_FEAT_CONN_SUBRATING == TRUE) +#if (BT_BLE_FEAT_PAWR_EN == TRUE) +void btm_ble_pa_subevt_data_req_evt(tBTM_BLE_PA_SUBEVT_DATA_REQ_EVT *params); +void btm_ble_pa_rsp_rpt_evt(tBTM_BLE_PA_RSP_REPORT_EVT *params); +#endif // #if (BT_BLE_FEAT_PAWR_EN == TRUE) + +#if (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE) +void btm_ble_cs_read_remote_supp_caps_cmpl_evt(tBTM_BLE_CS_READ_REMOTE_SUPP_CAPS_CMPL_EVT *cs_read_remote_supp_caps); +void btm_ble_cs_read_remote_fae_tab_cmpl_evt(tBTM_BLE_CS_READ_REMOTE_FAE_TAB_CMPL_EVT *cs_read_remote_fae_tab); +void btm_ble_cs_securuty_enable_cmpl_evt(tBTM_BLE_CS_SEC_ENABLE_CMPL_EVT *cs_security_enable); +void btm_ble_cs_config_cmpl_evt(tBTM_BLE_CS_CONFIG_CMPL_EVT *config_cmpl); +void btm_ble_cs_proc_enable_cmpl_evt(tBTM_BLE_CS_PROC_ENABLE_CMPL_EVT *proc_en); +void btm_ble_cs_subevt_result_evt(tBTM_BLE_CS_SUBEVT_RESULT_CMPL_EVT *subevt_result); +void btm_ble_cs_subevt_continue_result_evt(tBTM_BLE_CS_SUBEVT_RESULT_CONTINUE_EVT *subevt_continue_result); +#endif // (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE) + /* #ifdef __cplusplus diff --git a/components/bt/host/bluedroid/stack/btm/include/btm_int.h b/components/bt/host/bluedroid/stack/btm/include/btm_int.h index e1036b9174..d4d96c81a9 100644 --- a/components/bt/host/bluedroid/stack/btm/include/btm_int.h +++ b/components/bt/host/bluedroid/stack/btm/include/btm_int.h @@ -702,6 +702,9 @@ struct tBTM_SEC_DEV_REC{ #if (BLE_50_FEATURE_SUPPORT == TRUE) tBTM_EXT_CONN_PARAMS ext_conn_params; #endif // #if (BLE_50_FEATURE_SUPPORT == TRUE) + BOOLEAN is_pawr_synced; + UINT8 adv_handle; + UINT8 subevent; #endif // btla-specific ++ @@ -1134,6 +1137,14 @@ void btm_read_remote_trans_pwr_level_cmpl(UINT8 status); void btm_subrate_req_cmd_status(UINT8 status); #endif // #if (BLE_FEAT_CONN_SUBRATING == TRUE) +#if (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE) +void btm_ble_cs_read_local_supp_caps_cmpl_evt(UINT8 *p); +void btm_ble_cs_read_remote_supp_caps_cmd_status(UINT8 status); +void btm_ble_cs_security_enable_cmd_status(UINT8 status); +void btm_ble_cs_read_remote_fae_table_cmd_status(UINT8 status); +void btm_ble_cs_update_config_cmd_status(UINT8 status, BOOLEAN create); +#endif // (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE) + /* Internal functions provided by btm_sco.c ******************************************** */ diff --git a/components/bt/host/bluedroid/stack/btu/btu_hcif.c b/components/bt/host/bluedroid/stack/btu/btu_hcif.c index 2ff53852e0..4aa1701294 100644 --- a/components/bt/host/bluedroid/stack/btu/btu_hcif.c +++ b/components/bt/host/bluedroid/stack/btu/btu_hcif.c @@ -161,8 +161,8 @@ static void btu_ble_phy_update_complete_evt(UINT8 *p); static void btu_ble_ext_adv_report_evt(UINT8 *p, UINT16 evt_len); #endif // #if (BLE_50_EXTEND_SCAN_EN == TRUE) #if (BLE_50_EXTEND_SYNC_EN == TRUE) -static void btu_ble_periodic_adv_sync_establish_evt(UINT8 *p); -static void btu_ble_periodic_adv_report_evt(UINT8 *p, UINT8 evt_len); +static void btu_ble_periodic_adv_sync_establish_evt(UINT8 *p, bool v2_evt); +static void btu_ble_periodic_adv_report_evt(UINT8 *p, UINT8 evt_len, bool v2_evt); static void btu_ble_periodic_adv_sync_lost_evt(UINT8 *p); #endif // #if (BLE_50_EXTEND_SYNC_EN == TRUE) #if (BLE_50_EXTEND_SCAN_EN == TRUE) @@ -202,7 +202,7 @@ static void btu_ble_accept_cis_req_cmd_status(UINT8 status); static void btu_ble_cis_request_evt(UINT8 *p); #endif // #if (BLE_FEAT_ISO_CIG_PERIPHERAL_EN == TRUE) #if (BLE_FEAT_ISO_CIG_EN == TRUE) -static void btu_ble_cis_established_evt(UINT8 *p); +static void btu_ble_cis_established_evt(UINT8 *p, bool v2_evt); static void btu_ble_cis_disconnected(UINT16 handle, UINT8 reason); #endif // #if (BLE_FEAT_ISO_CIG_EN == TRUE) @@ -228,6 +228,21 @@ static void btu_ble_transmit_power_report_evt(UINT8 *p); static void btu_ble_subrate_change_evt(UINT8 *p); #endif // #if (BLE_FEAT_CONN_SUBRATING == TRUE) +#if (BT_BLE_FEAT_PAWR_EN == TRUE) +static void btu_ble_pa_subevt_data_request_evt(UINT8 *p); +static void btu_ble_pa_response_report_evt(UINT8 *p); +#endif // (BT_BLE_FEAT_PAWR_EN == TRUE) + +#if (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE) +static void btu_ble_cs_read_remote_supp_caps_evt(UINT8 *p); +static void btu_ble_cs_read_remote_fae_tab_evt(UINT8 *p); +static void btu_ble_cs_security_enable_cmpl_evt(UINT8 *p); +static void btu_ble_cs_config_cmpl_evt(UINT8 *p); +static void btu_ble_cs_proc_enable_cmpl_evt(UINT8 *p); +static void btu_ble_cs_subevt_result_evt(UINT8 *p); +static void btu_ble_cs_subevt_result_continue_evt(UINT8 *p); +#endif // (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE) + #if (BLE_42_ADV_EN == TRUE) extern osi_sem_t adv_enable_sem; extern osi_sem_t adv_data_sem; @@ -493,10 +508,16 @@ void btu_hcif_process_event (UNUSED_ATTR UINT8 controller_id, BT_HDR *p_msg) #endif // #if (BLE_50_EXTEND_SCAN_EN == TRUE) #if (BLE_50_EXTEND_SYNC_EN == TRUE) case HCI_BLE_PERIOD_ADV_SYNC_ESTAB_EVT: - btu_ble_periodic_adv_sync_establish_evt(p); + btu_ble_periodic_adv_sync_establish_evt(p, false); + break; + case HCI_BLE_PERIOD_ADV_SYNC_ESTAB_EVT_V2: + btu_ble_periodic_adv_sync_establish_evt(p, true); break; case HCI_BLE_PERIOD_ADV_REPORT_EVT: - btu_ble_periodic_adv_report_evt(p, hci_evt_len); + btu_ble_periodic_adv_report_evt(p, hci_evt_len, false); + break; + case HCI_BLE_PERIOD_ADV_REPORT_EVT_V2: + btu_ble_periodic_adv_report_evt(p, hci_evt_len, true); break; case HCI_BLE_PERIOD_ADV_SYNC_LOST_EVT: btu_ble_periodic_adv_sync_lost_evt(p); @@ -527,8 +548,10 @@ void btu_hcif_process_event (UNUSED_ATTR UINT8 controller_id, BT_HDR *p_msg) #if (BLE_FEAT_ISO_EN == TRUE) #if (BLE_FEAT_ISO_CIG_EN == TRUE) case HCI_BLE_CIS_ESTABLISHED_V1_EVT: + btu_ble_cis_established_evt(p, false); + break; case HCI_BLE_CIS_ESTABLISHED_V2_EVT: - btu_ble_cis_established_evt(p); + btu_ble_cis_established_evt(p, true); break; #endif // #if (BLE_FEAT_ISO_CIG_EN == TRUE) #if (BLE_FEAT_ISO_CIG_PERIPHERAL_EN == TRUE) @@ -586,6 +609,37 @@ void btu_hcif_process_event (UNUSED_ATTR UINT8 controller_id, BT_HDR *p_msg) btu_ble_subrate_change_evt(p); break; #endif // #if (BLE_FEAT_CONN_SUBRATING == TRUE) +#if (BT_BLE_FEAT_PAWR_EN == TRUE) + case HCI_BLE_PA_SUBEVT_DATA_REQUEST_EVT: + btu_ble_pa_subevt_data_request_evt(p); + break; + case HCI_BLE_PA_RESPONSE_REPORT_EVT: + btu_ble_pa_response_report_evt(p); + break; +#endif // #if (BT_BLE_FEAT_PAWR_EN == TRUE) +#if (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE) + case HCI_BLE_CS_READ_REMOTE_SUPP_CAPS_CMPL_EVT: + btu_ble_cs_read_remote_supp_caps_evt(p); + break; + case HCI_BLE_CS_READ_REMOTE_FAE_TAB_CMPL_EVT: + btu_ble_cs_read_remote_fae_tab_evt(p); + break; + case HCI_BLE_CS_SECURITY_ENABLE_CMPL_EVT: + btu_ble_cs_security_enable_cmpl_evt(p); + break; + case HCI_BLE_CS_CONFIG_CMPL_EVT: + btu_ble_cs_config_cmpl_evt(p); + break; + case HCI_BLE_CS_PROC_ENABLE_CMPL_EVT: + btu_ble_cs_proc_enable_cmpl_evt(p); + break; + case HCI_BLE_CS_SUBEVENT_RESULT_EVT: + btu_ble_cs_subevt_result_evt(p); + break; + case HCI_BLE_CS_SUBEVENT_RESULT_CONTINUE_EVT: + btu_ble_cs_subevt_result_continue_evt(p); + break; +#endif // (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE) } break; #endif /* BLE_INCLUDED */ @@ -1390,7 +1444,11 @@ static void btu_hcif_hdl_command_complete (UINT16 opcode, UINT8 *p, UINT16 evt_l btm_enh_read_trans_pwr_level_cmpl_evt(p); break; #endif //#if (BLE_FEAT_POWER_CONTROL_EN == TRUE) - +#if (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE) + case HCI_BLE_CS_READ_LOCAL_SUPP_CAPS: + btm_ble_cs_read_local_supp_caps_cmpl_evt(p); + break; +#endif // (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE) #endif /* (BLE_INCLUDED == TRUE) */ default: { @@ -1598,6 +1656,23 @@ static void btu_hcif_hdl_command_status (UINT16 opcode, UINT8 status, UINT8 *p_c btm_subrate_req_cmd_status(status); break; #endif // #if (BLE_FEAT_CONN_SUBRATING == TRUE) +#if (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE) + case HCI_BLE_CS_READ_REMOTE_SUPP_CAPS: + btm_ble_cs_read_remote_supp_caps_cmd_status(status); + break; + case HCI_BLE_CS_SECURITY_ENABLE: + btm_ble_cs_security_enable_cmd_status(status); + break; + case HCI_BLE_CS_READ_REMOTE_FAE_TABLE: + btm_ble_cs_read_remote_fae_table_cmd_status(status); + break; + case HCI_BLE_CS_CREATE_CONFIG: + btm_ble_cs_update_config_cmd_status(status, true); + break; + case HCI_BLE_CS_REMOVE_CONFIG: + btm_ble_cs_update_config_cmd_status(status, false); + break; +#endif // (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE) default: /* If command failed to start, we may need to tell BTM */ if (status != HCI_SUCCESS) { @@ -2540,7 +2615,7 @@ static void btu_ble_ext_adv_report_evt(UINT8 *p, UINT16 evt_len) #endif // #if (BLE_50_EXTEND_SCAN_EN == TRUE) #if (BLE_50_EXTEND_SYNC_EN == TRUE) -static void btu_ble_periodic_adv_sync_establish_evt(UINT8 *p) +static void btu_ble_periodic_adv_sync_establish_evt(UINT8 *p, bool v2_evt) { tBTM_BLE_PERIOD_ADV_SYNC_ESTAB sync_estab = {0}; @@ -2557,15 +2632,24 @@ static void btu_ble_periodic_adv_sync_establish_evt(UINT8 *p) STREAM_TO_UINT8(sync_estab.adv_phy, p); STREAM_TO_UINT16(sync_estab.period_adv_interval, p); STREAM_TO_UINT8(sync_estab.adv_clk_accuracy, p); +#if (BT_BLE_FEAT_PAWR_EN == TRUE) + if (v2_evt) { + STREAM_TO_UINT8(sync_estab.num_subevt, p); + STREAM_TO_UINT8(sync_estab.subevt_interval, p); + STREAM_TO_UINT8(sync_estab.rsp_slot_delay, p); + STREAM_TO_UINT8(sync_estab.rsp_slot_spacing, p); + } +#endif // (BT_BLE_FEAT_PAWR_EN == TRUE) btm_ble_periodic_adv_sync_establish_evt(&sync_estab); } -static void btu_ble_periodic_adv_report_evt(UINT8 *p, UINT8 evt_len) +static void btu_ble_periodic_adv_report_evt(UINT8 *p, UINT8 evt_len, bool v2_evt) { tBTM_PERIOD_ADV_REPORT adv_report = {0}; /* This parameter is intended to be used in a future feature. */ UINT8 unused = 0; + UINT8 min_len = MIN_BLE_PERIODIC_ADV_REPORT_LEN; if (!p) { HCI_TRACE_ERROR("%s, Invalid params.", __func__); @@ -2581,10 +2665,17 @@ static void btu_ble_periodic_adv_report_evt(UINT8 *p, UINT8 evt_len) STREAM_TO_UINT8(adv_report.tx_power, p); STREAM_TO_UINT8(adv_report.rssi, p); STREAM_TO_UINT8(adv_report.cte_type, p); +#if (BT_BLE_FEAT_PAWR_EN == TRUE) + if (v2_evt) { + STREAM_TO_UINT16(adv_report.periodic_evt_cnt, p); + STREAM_TO_UINT8(adv_report.subevt, p); + min_len += 3; + } +#endif // (BT_BLE_FEAT_PAWR_EN == TRUE) STREAM_TO_UINT8(adv_report.data_status, p); STREAM_TO_UINT8(adv_report.data_length, p); - if ((evt_len - MIN_BLE_PERIODIC_ADV_REPORT_LEN) != adv_report.data_length) { + if ((evt_len - min_len) != adv_report.data_length) { HCI_TRACE_ERROR("%s, Invalid ev_len = %d is less than adv len = %d", __func__, evt_len, adv_report.data_length); return; } @@ -2742,7 +2833,7 @@ static void btu_ble_cis_disconnected(UINT16 handle, UINT8 reason) btm_ble_cis_disconnected_evt(&cis_disconnected_evt); } -static void btu_ble_cis_established_evt(UINT8 *p) +static void btu_ble_cis_established_evt(UINT8 *p, bool v2_evt) { HCI_TRACE_DEBUG("%s", __func__); tBTM_BLE_CIS_ESTABLISHED_CMPL cis_estab_evt = {0}; @@ -2769,12 +2860,14 @@ static void btu_ble_cis_established_evt(UINT8 *p) STREAM_TO_UINT16(cis_estab_evt.max_pdu_p_to_c, p); STREAM_TO_UINT16(cis_estab_evt.iso_interval, p); #if (BLE_FEAT_ISO_60_EN == TRUE) - STREAM_TO_UINT24(cis_estab_evt.sub_interval, p); - STREAM_TO_UINT16(cis_estab_evt.max_sdu_c_to_p, p); - STREAM_TO_UINT16(cis_estab_evt.max_sdu_p_to_c, p); - STREAM_TO_UINT24(cis_estab_evt.sdu_int_c_to_p, p); - STREAM_TO_UINT24(cis_estab_evt.sdu_int_p_to_c, p); - STREAM_TO_UINT8(cis_estab_evt.framing, p); + if (v2_evt) { + STREAM_TO_UINT24(cis_estab_evt.sub_interval, p); + STREAM_TO_UINT16(cis_estab_evt.max_sdu_c_to_p, p); + STREAM_TO_UINT16(cis_estab_evt.max_sdu_p_to_c, p); + STREAM_TO_UINT24(cis_estab_evt.sdu_int_c_to_p, p); + STREAM_TO_UINT24(cis_estab_evt.sdu_int_p_to_c, p); + STREAM_TO_UINT8(cis_estab_evt.framing, p); + } #endif // #if (BLE_FEAT_ISO_60_EN == TRUE) btm_ble_cis_established_evt(&cis_estab_evt); @@ -2807,6 +2900,7 @@ void btu_ble_create_big_cmd_status(UINT8 status) { if (status != HCI_SUCCESS) { tBTM_BLE_BIG_CREATE_CMPL big_cmpl = {0}; + big_cmpl.status = status; btm_ble_big_create_cmpl_evt(&big_cmpl); } } @@ -2973,6 +3067,10 @@ static void btu_ble_cte_connless_iq_report_evt(UINT8 *p) for (uint8_t i = 0; i < connless_iq_rpt.sample_count; i++) { STREAM_TO_UINT8(connless_iq_rpt.i_sample[i], p); + } + + for (uint8_t i = 0; i < connless_iq_rpt.sample_count; i++) + { STREAM_TO_UINT8(connless_iq_rpt.q_sample[i], p); } @@ -3004,6 +3102,10 @@ static void btu_ble_cte_conn_iq_report_evt(UINT8 *p) for (uint8_t i = 0; i < conn_iq_rpt.sample_count; i++) { STREAM_TO_UINT8(conn_iq_rpt.i_sample[i], p); + } + + for (uint8_t i = 0; i < conn_iq_rpt.sample_count; i++) + { STREAM_TO_UINT8(conn_iq_rpt.q_sample[i], p); } @@ -3084,6 +3186,298 @@ static void btu_ble_subrate_change_evt(UINT8 *p) } #endif // #if (BLE_FEAT_CONN_SUBRATING == TRUE) +#if (BT_BLE_FEAT_PAWR_EN == TRUE) +static void btu_ble_pa_subevt_data_request_evt(UINT8 *p) +{ + tBTM_BLE_PA_SUBEVT_DATA_REQ_EVT pa_subevt_req_evt = {0}; + if (!p) { + HCI_TRACE_ERROR("%s, Invalid params.", __func__); + return; + } + + STREAM_TO_UINT8(pa_subevt_req_evt.adv_handle, p); + STREAM_TO_UINT8(pa_subevt_req_evt.subevt_start, p); + STREAM_TO_UINT8(pa_subevt_req_evt.subevt_data_count, p); + + btm_ble_pa_subevt_data_req_evt(&pa_subevt_req_evt); +} + +static void btu_ble_pa_response_report_evt(UINT8 *p) +{ + tBTM_BLE_PA_RSP_REPORT_EVT pa_rsp_rpt_evt = {0}; + if (!p) { + HCI_TRACE_ERROR("%s, Invalid params.", __func__); + return; + } + + STREAM_TO_UINT8(pa_rsp_rpt_evt.adv_handle, p); + STREAM_TO_UINT8(pa_rsp_rpt_evt.subevt, p); + STREAM_TO_UINT8(pa_rsp_rpt_evt.tx_status, p); + STREAM_TO_UINT8(pa_rsp_rpt_evt.num_rsp, p); + + if (pa_rsp_rpt_evt.num_rsp) { + pa_rsp_rpt_evt.rsp_data_info = osi_malloc(pa_rsp_rpt_evt.num_rsp * sizeof(tBTM_BLE_PA_RSP_DATA_INFO)); + if (pa_rsp_rpt_evt.rsp_data_info) + { + for (UINT8 i = 0; i < pa_rsp_rpt_evt.num_rsp; i++) + { + STREAM_TO_UINT8(pa_rsp_rpt_evt.rsp_data_info[i].tx_power, p); + STREAM_TO_UINT8(pa_rsp_rpt_evt.rsp_data_info[i].rssi, p); + STREAM_TO_UINT8(pa_rsp_rpt_evt.rsp_data_info[i].cte_type, p); + STREAM_TO_UINT8(pa_rsp_rpt_evt.rsp_data_info[i].rsp_slot, p); + STREAM_TO_UINT8(pa_rsp_rpt_evt.rsp_data_info[i].data_status, p); + STREAM_TO_UINT8(pa_rsp_rpt_evt.rsp_data_info[i].data_len, p); + if (pa_rsp_rpt_evt.rsp_data_info[i].data_len) { + pa_rsp_rpt_evt.rsp_data_info[i].data = osi_malloc(pa_rsp_rpt_evt.rsp_data_info[i].data_len); + if (pa_rsp_rpt_evt.rsp_data_info[i].data) { + STREAM_TO_ARRAY(pa_rsp_rpt_evt.rsp_data_info[i].data, p, pa_rsp_rpt_evt.rsp_data_info[i].data_len); + } else { + HCI_TRACE_ERROR("%s, no enough memory.", __func__); + } + } + } + } else { + HCI_TRACE_ERROR("%s, no memory.", __func__); + } + } + + btm_ble_pa_rsp_rpt_evt(&pa_rsp_rpt_evt); + + if (pa_rsp_rpt_evt.rsp_data_info) + { + for (UINT8 i = 0; i < pa_rsp_rpt_evt.num_rsp; i++) + { + if (pa_rsp_rpt_evt.rsp_data_info[i].data) { + osi_free(pa_rsp_rpt_evt.rsp_data_info[i].data); + } + } + osi_free(pa_rsp_rpt_evt.rsp_data_info); + } +} +#endif // #if (BT_BLE_FEAT_PAWR_EN == TRUE) + +#if (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE) +static void btu_ble_cs_read_remote_supp_caps_evt(UINT8 *p) +{ + tBTM_BLE_CS_READ_REMOTE_SUPP_CAPS_CMPL_EVT cs_read_remote_supp_caps = {0}; + if (!p) { + HCI_TRACE_ERROR("%s, Invalid params.", __func__); + return; + } + + STREAM_TO_UINT8(cs_read_remote_supp_caps.status, p); + STREAM_TO_UINT16(cs_read_remote_supp_caps.conn_handle, p); + STREAM_TO_UINT8(cs_read_remote_supp_caps.num_config_supported, p); + STREAM_TO_UINT16(cs_read_remote_supp_caps.max_consecutive_proc_supported, p); + STREAM_TO_UINT8(cs_read_remote_supp_caps.num_ant_supported, p); + STREAM_TO_UINT8(cs_read_remote_supp_caps.max_ant_paths_supported, p); + STREAM_TO_UINT8(cs_read_remote_supp_caps.roles_supported, p); + STREAM_TO_UINT8(cs_read_remote_supp_caps.modes_supported, p); + STREAM_TO_UINT8(cs_read_remote_supp_caps.rtt_capability, p); + STREAM_TO_UINT8(cs_read_remote_supp_caps.rtt_aa_only_n, p); + STREAM_TO_UINT8(cs_read_remote_supp_caps.rtt_sounding_n, p); + STREAM_TO_UINT8(cs_read_remote_supp_caps.rtt_random_payload_n, p); + STREAM_TO_UINT16(cs_read_remote_supp_caps.NADM_sounding_capability, p); + STREAM_TO_UINT16(cs_read_remote_supp_caps.NADM_random_capability, p); + STREAM_TO_UINT8(cs_read_remote_supp_caps.cs_sync_phys_supported, p); + STREAM_TO_UINT16(cs_read_remote_supp_caps.subfeatures_supported, p); + STREAM_TO_UINT16(cs_read_remote_supp_caps.T_IP1_times_supported, p); + STREAM_TO_UINT16(cs_read_remote_supp_caps.T_IP2_times_supported, p); + STREAM_TO_UINT16(cs_read_remote_supp_caps.T_FCS_times_supported, p); + STREAM_TO_UINT16(cs_read_remote_supp_caps.T_PM_times_supported, p); + STREAM_TO_UINT8(cs_read_remote_supp_caps.T_SW_times_supported, p); + STREAM_TO_UINT8(cs_read_remote_supp_caps.TX_SNR_capability, p); + + btm_ble_cs_read_remote_supp_caps_cmpl_evt(&cs_read_remote_supp_caps); +} + +static void btu_ble_cs_read_remote_fae_tab_evt(UINT8 *p) +{ + tBTM_BLE_CS_READ_REMOTE_FAE_TAB_CMPL_EVT cs_read_remote_fae_tab = {0}; + + if (!p) { + HCI_TRACE_ERROR("%s, Invalid params.", __func__); + return; + } + + STREAM_TO_UINT8(cs_read_remote_fae_tab.status, p); + STREAM_TO_UINT16(cs_read_remote_fae_tab.conn_handle, p); + STREAM_TO_ARRAY(cs_read_remote_fae_tab.remote_fae_table, p, 72); + + btm_ble_cs_read_remote_fae_tab_cmpl_evt(&cs_read_remote_fae_tab); +} + +static void btu_ble_cs_security_enable_cmpl_evt(UINT8 *p) +{ + tBTM_BLE_CS_SEC_ENABLE_CMPL_EVT cs_security_enable = {0}; + if (!p) { + HCI_TRACE_ERROR("%s, Invalid params.", __func__); + return; + } + STREAM_TO_UINT8(cs_security_enable.status, p); + STREAM_TO_UINT16(cs_security_enable.conn_handle, p); + + btm_ble_cs_securuty_enable_cmpl_evt(&cs_security_enable); +} + +static void btu_ble_cs_config_cmpl_evt(UINT8 *p) +{ + tBTM_BLE_CS_CONFIG_CMPL_EVT config_cmpl = {0}; + if (!p) { + HCI_TRACE_ERROR("%s, Invalid params.", __func__); + return; + } + STREAM_TO_UINT8(config_cmpl.status, p); + STREAM_TO_UINT16(config_cmpl.conn_handle, p); + STREAM_TO_UINT8(config_cmpl.config_id, p); + STREAM_TO_UINT8(config_cmpl.action, p);; + STREAM_TO_UINT8(config_cmpl.main_mode_type, p); + STREAM_TO_UINT8(config_cmpl.sub_mode_type, p); + STREAM_TO_UINT8(config_cmpl.min_main_mode_steps, p); + STREAM_TO_UINT8(config_cmpl.max_main_mode_steps, p); + STREAM_TO_UINT8(config_cmpl.main_mode_repetition, p); + STREAM_TO_UINT8(config_cmpl.mode_0_steps, p); + STREAM_TO_UINT8(config_cmpl.role, p); + STREAM_TO_UINT8(config_cmpl.rtt_type, p); + STREAM_TO_UINT8(config_cmpl.cs_sync_phy, p); + STREAM_TO_ARRAY(config_cmpl.channel_map, p, 10); + STREAM_TO_UINT8(config_cmpl.channel_map_repetition, p); + STREAM_TO_UINT8(config_cmpl.channel_selection_type, p); + STREAM_TO_UINT8(config_cmpl.ch3c_shape, p); + STREAM_TO_UINT8(config_cmpl.ch3c_jump, p); + STREAM_TO_UINT8(config_cmpl.reserved, p); + STREAM_TO_UINT8(config_cmpl.t_ip1_time, p); + STREAM_TO_UINT8(config_cmpl.t_ip2_time, p); + STREAM_TO_UINT8(config_cmpl.t_fcs_time, p); + STREAM_TO_UINT8(config_cmpl.t_pm_time, p); + + btm_ble_cs_config_cmpl_evt(&config_cmpl); +} + +static void btu_ble_cs_proc_enable_cmpl_evt(UINT8 *p) +{ + tBTM_BLE_CS_PROC_ENABLE_CMPL_EVT proc_en = {0}; + + if (!p) { + HCI_TRACE_ERROR("%s, Invalid params.", __func__); + return; + } + + STREAM_TO_UINT8(proc_en.status, p); + STREAM_TO_UINT16(proc_en.conn_handle, p); + STREAM_TO_UINT8(proc_en.config_id, p); + STREAM_TO_UINT8(proc_en.state, p); + STREAM_TO_UINT8(proc_en.tone_ant_config_select, p); + STREAM_TO_UINT8(proc_en.select_tx_power, p); + STREAM_TO_UINT24(proc_en.subevent_Len, p); + STREAM_TO_UINT8(proc_en.subevents_per_event, p); + STREAM_TO_UINT16(proc_en.subevent_interval, p); + STREAM_TO_UINT16(proc_en.event_interval, p); + STREAM_TO_UINT16(proc_en.procedure_interval, p); + STREAM_TO_UINT16(proc_en.procedure_count, p); + STREAM_TO_UINT16(proc_en.max_procedure_len, p); + + btm_ble_cs_proc_enable_cmpl_evt(&proc_en); +} + +static void btu_ble_cs_subevt_result_evt(UINT8 *p) +{ + tBTM_BLE_CS_SUBEVT_RESULT_CMPL_EVT subevt_result = {0}; + if (!p) { + HCI_TRACE_ERROR("%s, Invalid params.", __func__); + return; + } + STREAM_TO_UINT16(subevt_result.conn_handle, p); + STREAM_TO_UINT8(subevt_result.config_id, p); + STREAM_TO_UINT16(subevt_result.start_acl_conn_event_counter, p); + STREAM_TO_UINT16(subevt_result.procedure_counter, p); + STREAM_TO_UINT16(subevt_result.frequency_compensation, p); + STREAM_TO_UINT8(subevt_result.reference_power_level, p); + STREAM_TO_UINT8(subevt_result.procedure_done_status, p); + STREAM_TO_UINT8(subevt_result.subevent_done_status, p); + STREAM_TO_UINT8(subevt_result.abort_reason, p); + STREAM_TO_UINT8(subevt_result.num_ant_paths, p); + STREAM_TO_UINT8(subevt_result.num_steps_reported, p); + + subevt_result.step_info = osi_malloc(subevt_result.num_steps_reported * sizeof(tBTM_BLE_CS_STEP_INFO)); + if (subevt_result.step_info) { + for (uint8_t i = 0; i < subevt_result.num_steps_reported; i++) + { + STREAM_TO_UINT8(subevt_result.step_info[i].step_mode, p); + STREAM_TO_UINT8(subevt_result.step_info[i].step_channel, p); + STREAM_TO_UINT8(subevt_result.step_info[i].step_data_len, p); + subevt_result.step_info[i].data = osi_malloc(subevt_result.step_info[i].step_data_len); + if (subevt_result.step_info[i].data) { + STREAM_TO_ARRAY(subevt_result.step_info[i].data, p, subevt_result.step_info[i].step_data_len); + } else if (subevt_result.step_info[i].step_data_len) { + HCI_TRACE_ERROR("%s, no memory.", __func__); + } + } + } + + btm_ble_cs_subevt_result_evt(&subevt_result); + + if (subevt_result.step_info) + { + for (UINT8 i = 0; i < subevt_result.num_steps_reported; i++) + { + if (subevt_result.step_info[i].data) { + osi_free(subevt_result.step_info[i].data); + } + } + osi_free(subevt_result.step_info); + } + +} + +static void btu_ble_cs_subevt_result_continue_evt(UINT8 *p) +{ + tBTM_BLE_CS_SUBEVT_RESULT_CONTINUE_EVT subevt_continue_result = {0}; + + if (!p) { + HCI_TRACE_ERROR("%s, Invalid params.", __func__); + return; + } + + STREAM_TO_UINT16(subevt_continue_result.conn_handle, p); + STREAM_TO_UINT8(subevt_continue_result.config_id, p); + STREAM_TO_UINT8(subevt_continue_result.proc_done_status, p); + STREAM_TO_UINT8(subevt_continue_result.subevt_done_status, p); + STREAM_TO_UINT8(subevt_continue_result.abort_reason, p); + STREAM_TO_UINT8(subevt_continue_result.num_ant_paths, p); + STREAM_TO_UINT8(subevt_continue_result.num_steps_reported, p); + + subevt_continue_result.step_info = osi_malloc(subevt_continue_result.num_steps_reported * sizeof(tBTM_BLE_CS_STEP_INFO)); + if (subevt_continue_result.step_info) { + for (uint8_t i = 0; i < subevt_continue_result.num_steps_reported; i++) { + STREAM_TO_UINT8(subevt_continue_result.step_info[i].step_mode, p); + STREAM_TO_UINT8(subevt_continue_result.step_info[i].step_channel, p); + STREAM_TO_UINT8(subevt_continue_result.step_info[i].step_data_len, p); + subevt_continue_result.step_info[i].data = osi_malloc(subevt_continue_result.step_info[i].step_data_len); + if (subevt_continue_result.step_info[i].data) { + STREAM_TO_ARRAY(subevt_continue_result.step_info[i].data, p, subevt_continue_result.step_info[i].step_data_len); + } else if (subevt_continue_result.step_info[i].step_data_len) { + HCI_TRACE_ERROR("%s, no memory.", __func__); + } + } + } + + btm_ble_cs_subevt_continue_result_evt(&subevt_continue_result); + + if (subevt_continue_result.step_info) + { + for (UINT8 i = 0; i < subevt_continue_result.num_steps_reported; i++) + { + if (subevt_continue_result.step_info[i].data) { + osi_free(subevt_continue_result.step_info[i].data); + } + } + osi_free(subevt_continue_result.step_info); + } + +} +#endif // (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE) + /********************************************** ** End of BLE Events Handler ***********************************************/ diff --git a/components/bt/host/bluedroid/stack/gap/gap_ble.c b/components/bt/host/bluedroid/stack/gap/gap_ble.c index bf3d97d666..7e4f453278 100644 --- a/components/bt/host/bluedroid/stack/gap/gap_ble.c +++ b/components/bt/host/bluedroid/stack/gap/gap_ble.c @@ -256,6 +256,12 @@ tGATT_STATUS gap_read_attr_value (UINT16 handle, tGATT_VALUE *p_value, BOOLEAN i UINT8_TO_STREAM(p, p_db_attr->attr_value.addr_resolution); p_value->len = 1; break; +#if (BT_GATTS_SECURITY_LEVELS_CHAR == TRUE) + case GATT_UUID_GAP_GATT_SECURITY_LEVELS: + UINT16_TO_STREAM(p, p_db_attr->attr_value.security_level); + p_value->len = 2; + break; +#endif // (BT_GATTS_SECURITY_LEVELS_CHAR == TRUE) } return GATT_SUCCESS; } @@ -464,6 +470,17 @@ void gap_attr_db_init(void) p_db_attr->attr_value.addr_resolution = 0; p_db_attr++; +#if (BT_GATTS_SECURITY_LEVELS_CHAR == TRUE) + /* Add LE Security Levels Characteristic */ + uuid.len = LEN_UUID_16; + uuid.uu.uuid16 = p_db_attr->uuid = GATT_UUID_GAP_GATT_SECURITY_LEVELS; + p_db_attr->handle = GATTS_AddCharacteristic(service_handle, &uuid, + GATT_PERM_READ, GATT_CHAR_PROP_BIT_READ, + NULL, NULL); + p_db_attr->attr_value.security_level = 0x0101; + p_db_attr++; +#endif // (BT_GATTS_SECURITY_LEVELS_CHAR == TRUE) + /* start service now */ memset (&app_uuid.uu.uuid128, 0x81, LEN_UUID_128); @@ -517,6 +534,12 @@ void GAP_BleAttrDBUpdate(UINT16 attr_uuid, tGAP_BLE_ATTR_VALUE *p_value) p_db_attr->attr_value.addr_resolution = p_value->addr_resolution; break; +#if (BT_GATTS_SECURITY_LEVELS_CHAR == TRUE) + case GATT_UUID_GAP_GATT_SECURITY_LEVELS: + p_db_attr->attr_value.security_level = p_value->security_level; + break; +#endif // (BT_GATTS_SECURITY_LEVELS_CHAR == TRUE) + } break; } @@ -741,7 +764,7 @@ BOOLEAN gap_ble_accept_cl_operation(BD_ADDR peer_bda, UINT16 uuid, tGAP_BLE_CMPL } /* hold the link here */ - if (!GATT_Connect(gap_cb.gatt_if, p_clcb->bda, BLE_ADDR_UNKNOWN_TYPE, TRUE, BT_TRANSPORT_LE, FALSE)) { + if (!GATT_Connect(gap_cb.gatt_if, p_clcb->bda, BLE_ADDR_UNKNOWN_TYPE, TRUE, BT_TRANSPORT_LE, FALSE, FALSE, 0xFF, 0xFF)) { return started; } diff --git a/components/bt/host/bluedroid/stack/gap/include/gap_int.h b/components/bt/host/bluedroid/stack/gap/include/gap_int.h index 8a3ae0e2f0..175a27e695 100644 --- a/components/bt/host/bluedroid/stack/gap/include/gap_int.h +++ b/components/bt/host/bluedroid/stack/gap/include/gap_int.h @@ -93,7 +93,7 @@ typedef struct { #if BLE_INCLUDED == TRUE -#define GAP_MAX_CHAR_NUM 4 +#define GAP_MAX_CHAR_NUM 5 typedef struct { UINT16 handle; diff --git a/components/bt/host/bluedroid/stack/gatt/gatt_api.c b/components/bt/host/bluedroid/stack/gatt/gatt_api.c index 51e46e2274..db7952e95a 100644 --- a/components/bt/host/bluedroid/stack/gatt/gatt_api.c +++ b/components/bt/host/bluedroid/stack/gatt/gatt_api.c @@ -1453,7 +1453,8 @@ void GATT_StartIf (tGATT_IF gatt_if) ** *******************************************************************************/ BOOLEAN GATT_Connect (tGATT_IF gatt_if, BD_ADDR bd_addr, tBLE_ADDR_TYPE bd_addr_type, - BOOLEAN is_direct, tBT_TRANSPORT transport, BOOLEAN is_aux) + BOOLEAN is_direct, tBT_TRANSPORT transport, BOOLEAN is_aux, + BOOLEAN is_pawr_synced, UINT8 adv_handle, UINT8 subevent) { tGATT_REG *p_reg; BOOLEAN status = FALSE; @@ -1467,7 +1468,7 @@ BOOLEAN GATT_Connect (tGATT_IF gatt_if, BD_ADDR bd_addr, tBLE_ADDR_TYPE bd_addr_ } if (is_direct) { - status = gatt_act_connect (p_reg, bd_addr, bd_addr_type, transport, is_aux); + status = gatt_act_connect (p_reg, bd_addr, bd_addr_type, transport, is_aux, is_pawr_synced, adv_handle, subevent); } else { #if (tGATT_BG_CONN_DEV == TRUE) if (transport == BT_TRANSPORT_LE) { diff --git a/components/bt/host/bluedroid/stack/gatt/gatt_attr.c b/components/bt/host/bluedroid/stack/gatt/gatt_attr.c index 3ab573426a..27e80d605d 100644 --- a/components/bt/host/bluedroid/stack/gatt/gatt_attr.c +++ b/components/bt/host/bluedroid/stack/gatt/gatt_attr.c @@ -98,7 +98,7 @@ UINT16 gatt_profile_find_conn_id_by_bd_addr(BD_ADDR remote_bda) ** ** Description find clcb by Connection ID ** -** Returns Pointer to the found link conenction control block. +** Returns Pointer to the found link connection control block. ** *******************************************************************************/ static tGATT_PROFILE_CLCB *gatt_profile_find_clcb_by_conn_id(UINT16 conn_id) @@ -119,9 +119,9 @@ static tGATT_PROFILE_CLCB *gatt_profile_find_clcb_by_conn_id(UINT16 conn_id) ** ** Function gatt_profile_find_clcb_by_bd_addr ** -** Description The function searches all LCBs with macthing bd address. +** Description The function searches all LCBs with matching bd address. ** -** Returns Pointer to the found link conenction control block. +** Returns Pointer to the found link connection control block. ** *******************************************************************************/ static tGATT_PROFILE_CLCB *gatt_profile_find_clcb_by_bd_addr(BD_ADDR bda, tBT_TRANSPORT transport) @@ -148,7 +148,7 @@ static tGATT_PROFILE_CLCB *gatt_profile_find_clcb_by_bd_addr(BD_ADDR bda, tBT_TR ** Returns NULL if not found. Otherwise pointer to the connection link block. ** *******************************************************************************/ -tGATT_PROFILE_CLCB *gatt_profile_clcb_alloc (UINT16 conn_id, BD_ADDR bda, tBT_TRANSPORT tranport) +tGATT_PROFILE_CLCB *gatt_profile_clcb_alloc (UINT16 conn_id, BD_ADDR bda, tBT_TRANSPORT transport) { UINT8 i_clcb = 0; tGATT_PROFILE_CLCB *p_clcb = NULL; @@ -158,7 +158,7 @@ tGATT_PROFILE_CLCB *gatt_profile_clcb_alloc (UINT16 conn_id, BD_ADDR bda, tBT_TR p_clcb->in_use = TRUE; p_clcb->conn_id = conn_id; p_clcb->connected = TRUE; - p_clcb->transport = tranport; + p_clcb->transport = transport; memcpy (p_clcb->bda, bda, BD_ADDR_LEN); break; } @@ -435,7 +435,7 @@ static void gatt_connect_cback (tGATT_IF gatt_if, BD_ADDR bda, UINT16 conn_id, ** ** Function gatt_profile_db_init ** -** Description Initializa the GATT profile attribute database. +** Description Initialize the GATT profile attribute database. ** *******************************************************************************/ void gatt_profile_db_init (void) @@ -684,7 +684,7 @@ void GATT_ConfigServiceChangeCCC (BD_ADDR remote_bda, BOOLEAN enable, tBT_TRANSP p_clcb->connected = TRUE; } /* hold the link here */ - GATT_Connect(gatt_cb.gatt_if, remote_bda, BLE_ADDR_UNKNOWN_TYPE, TRUE, transport, FALSE); + GATT_Connect(gatt_cb.gatt_if, remote_bda, BLE_ADDR_UNKNOWN_TYPE, TRUE, transport, FALSE, FALSE, 0xFF, 0xFF); p_clcb->ccc_stage = GATT_SVC_CHANGED_CONNECTING; if (!p_clcb->connected) { diff --git a/components/bt/host/bluedroid/stack/gatt/gatt_main.c b/components/bt/host/bluedroid/stack/gatt/gatt_main.c index e5d9823712..4eaae0d302 100644 --- a/components/bt/host/bluedroid/stack/gatt/gatt_main.c +++ b/components/bt/host/bluedroid/stack/gatt/gatt_main.c @@ -220,7 +220,8 @@ void gatt_free(void) ** Returns TRUE if connection is started, otherwise return FALSE. ** *******************************************************************************/ -BOOLEAN gatt_connect (BD_ADDR rem_bda, tBLE_ADDR_TYPE bd_addr_type, tGATT_TCB *p_tcb, tBT_TRANSPORT transport, BOOLEAN is_aux) +BOOLEAN gatt_connect (BD_ADDR rem_bda, tBLE_ADDR_TYPE bd_addr_type, tGATT_TCB *p_tcb, tBT_TRANSPORT transport, BOOLEAN is_aux, + BOOLEAN is_pawr_synced, UINT8 adv_handle, UINT8 subevent) { BOOLEAN gatt_ret = FALSE; @@ -230,7 +231,7 @@ BOOLEAN gatt_connect (BD_ADDR rem_bda, tBLE_ADDR_TYPE bd_addr_type, tGATT_TCB *p if (transport == BT_TRANSPORT_LE) { p_tcb->att_lcid = L2CAP_ATT_CID; - gatt_ret = L2CA_ConnectFixedChnl (L2CAP_ATT_CID, rem_bda, bd_addr_type, is_aux); + gatt_ret = L2CA_ConnectFixedChnl (L2CAP_ATT_CID, rem_bda, bd_addr_type, is_aux, is_pawr_synced, adv_handle, subevent); #if (CLASSIC_BT_GATT_INCLUDED == TRUE) } else { if ((p_tcb->att_lcid = L2CA_ConnectReq(BT_PSM_ATT, rem_bda)) != 0) { @@ -376,7 +377,8 @@ void gatt_update_app_use_link_flag (tGATT_IF gatt_if, tGATT_TCB *p_tcb, BOOLEAN ** *******************************************************************************/ BOOLEAN gatt_act_connect (tGATT_REG *p_reg, BD_ADDR bd_addr, - tBLE_ADDR_TYPE bd_addr_type, tBT_TRANSPORT transport, BOOLEAN is_aux) + tBLE_ADDR_TYPE bd_addr_type, tBT_TRANSPORT transport, BOOLEAN is_aux, + BOOLEAN is_pawr_synced, UINT8 adv_handle, UINT8 subevent) { BOOLEAN ret = FALSE; tGATT_TCB *p_tcb; @@ -389,7 +391,7 @@ BOOLEAN gatt_act_connect (tGATT_REG *p_reg, BD_ADDR bd_addr, /* before link down, another app try to open a GATT connection */ if (st == GATT_CH_OPEN && gatt_num_apps_hold_link(p_tcb) == 0 && transport == BT_TRANSPORT_LE ) { - if (!gatt_connect(bd_addr, bd_addr_type, p_tcb, transport, is_aux)) { + if (!gatt_connect(bd_addr, bd_addr_type, p_tcb, transport, is_aux, is_pawr_synced, adv_handle, subevent)) { ret = FALSE; } } else if (st == GATT_CH_CLOSING) { @@ -400,7 +402,7 @@ BOOLEAN gatt_act_connect (tGATT_REG *p_reg, BD_ADDR bd_addr, } } else { if ((p_tcb = gatt_allocate_tcb_by_bdaddr(bd_addr, transport)) != NULL) { - if (!gatt_connect(bd_addr, bd_addr_type, p_tcb, transport, is_aux)) { + if (!gatt_connect(bd_addr, bd_addr_type, p_tcb, transport, is_aux, is_pawr_synced, adv_handle, subevent)) { GATT_TRACE_ERROR("gatt_connect failed"); // code enter here if create connection failed. if disconnect after connection, code will not enter here diff --git a/components/bt/host/bluedroid/stack/gatt/include/gatt_int.h b/components/bt/host/bluedroid/stack/gatt/include/gatt_int.h index f9d3cd8e51..778e7d92bf 100644 --- a/components/bt/host/bluedroid/stack/gatt/include/gatt_int.h +++ b/components/bt/host/bluedroid/stack/gatt/include/gatt_int.h @@ -597,8 +597,8 @@ extern void gatt_free(void); /* from gatt_main.c */ extern BOOLEAN gatt_disconnect (tGATT_TCB *p_tcb); -extern BOOLEAN gatt_act_connect (tGATT_REG *p_reg, BD_ADDR bd_addr, tBLE_ADDR_TYPE bd_addr_type, tBT_TRANSPORT transport, BOOLEAN is_aux); -extern BOOLEAN gatt_connect (BD_ADDR rem_bda, tBLE_ADDR_TYPE bd_addr_type, tGATT_TCB *p_tcb, tBT_TRANSPORT transport, BOOLEAN is_aux); +extern BOOLEAN gatt_act_connect (tGATT_REG *p_reg, BD_ADDR bd_addr, tBLE_ADDR_TYPE bd_addr_type, tBT_TRANSPORT transport, BOOLEAN is_aux, BOOLEAN is_pawr_synced, UINT8 adv_handle, UINT8 subevent); +extern BOOLEAN gatt_connect (BD_ADDR rem_bda, tBLE_ADDR_TYPE bd_addr_type, tGATT_TCB *p_tcb, tBT_TRANSPORT transport, BOOLEAN is_aux, BOOLEAN is_pawr_synced, UINT8 adv_handle, UINT8 subevent); extern void gatt_data_process (tGATT_TCB *p_tcb, BT_HDR *p_buf); extern void gatt_update_app_use_link_flag ( tGATT_IF gatt_if, tGATT_TCB *p_tcb, BOOLEAN is_add, BOOLEAN check_acl_link); diff --git a/components/bt/host/bluedroid/stack/hcic/hciblecmds.c b/components/bt/host/bluedroid/stack/hcic/hciblecmds.c index 5ad13216f7..c44e974fff 100644 --- a/components/bt/host/bluedroid/stack/hcic/hciblecmds.c +++ b/components/bt/host/bluedroid/stack/hcic/hciblecmds.c @@ -1221,7 +1221,55 @@ UINT8 btsnd_hcic_ble_set_extend_rand_address(UINT8 adv_handle, BD_ADDR rand_addr return btu_hcif_send_cmd_sync (LOCAL_BR_EDR_CONTROLLER_ID, p); } +#if (BT_BLE_FEAT_ADV_CODING_SELECTION == TRUE) +UINT8 btsnd_hcic_ble_set_ext_adv_params_v2(UINT8 adv_handle, UINT16 properties, UINT32 interval_min, + UINT32 interval_max, UINT8 channel_map, UINT8 own_addr_type, + UINT8 peer_addr_type, BD_ADDR peer_addr, + UINT8 adv_filter_policy, INT8 adv_tx_power, + UINT8 primary_adv_phy, UINT8 secondary_adv_max_skip, + UINT8 secondary_adv_phy, + UINT8 adv_sid, UINT8 scan_req_ntf_enable, + UINT8 primary_adv_phy_options, UINT8 secondary_adv_phy_options) +{ + BT_HDR *p; + UINT8 *pp; + + HCI_TRACE_EVENT("%s, adv_handle = %d, properties = %d, interval_min = %d, interval_max = %d, channel_map = %d,\n\ + own_addr_type = %d, peer_addr_type = %d, adv_filter_policy = %d,\n\ + adv_tx_power = %d, primary_adv_phy = %d, secondary_adv_max_skip = %d, secondary_adv_phy = %d,\n\ + adv_sid = %d, scan_req_ntf_enable = %d, primary_phy_options %d secondary_phy_options %d", __func__, adv_handle, properties, interval_min, interval_max, + channel_map, own_addr_type, peer_addr_type, adv_filter_policy, adv_tx_power, + primary_adv_phy, secondary_adv_max_skip, secondary_adv_phy, adv_sid, scan_req_ntf_enable, + primary_adv_phy_options, secondary_adv_phy_options); + + HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_EXT_ADV_SET_PARAMS + 2); + + UINT16_TO_STREAM(pp, HCI_BLE_SET_EXT_ADV_PARAM_V2); + UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_EXT_ADV_SET_PARAMS + 2); + + UINT8_TO_STREAM(pp, adv_handle); + UINT16_TO_STREAM(pp, properties); + UINT24_TO_STREAM(pp, interval_min); + UINT24_TO_STREAM(pp, interval_max); + UINT8_TO_STREAM(pp, channel_map); + UINT8_TO_STREAM(pp, own_addr_type); + UINT8_TO_STREAM(pp, peer_addr_type); + BDADDR_TO_STREAM (pp, peer_addr); + UINT8_TO_STREAM(pp, adv_filter_policy); + INT8_TO_STREAM(pp, adv_tx_power); + UINT8_TO_STREAM(pp, primary_adv_phy); + UINT8_TO_STREAM(pp, secondary_adv_max_skip); + UINT8_TO_STREAM(pp, secondary_adv_phy); + UINT8_TO_STREAM(pp, adv_sid); + UINT8_TO_STREAM(pp, scan_req_ntf_enable); + UINT8_TO_STREAM(pp, primary_adv_phy_options); + UINT8_TO_STREAM(pp, secondary_adv_phy_options); + + return btu_hcif_send_cmd_sync (LOCAL_BR_EDR_CONTROLLER_ID, p); +} + +#else UINT8 btsnd_hcic_ble_set_ext_adv_params(UINT8 adv_handle, UINT16 properties, UINT32 interval_min, UINT32 interval_max, UINT8 channel_map, UINT8 own_addr_type, UINT8 peer_addr_type, BD_ADDR peer_addr, @@ -1264,8 +1312,7 @@ UINT8 btsnd_hcic_ble_set_ext_adv_params(UINT8 adv_handle, UINT16 properties, UIN return btu_hcif_send_cmd_sync (LOCAL_BR_EDR_CONTROLLER_ID, p); } - -bool ext_adv_flag = false; +#endif // #if (BT_BLE_FEAT_ADV_CODING_SELECTION == TRUE) UINT8 btsnd_hcic_ble_set_ext_adv_data(UINT8 adv_handle, UINT8 operation, UINT8 fragment_prefrence, @@ -1275,7 +1322,6 @@ UINT8 btsnd_hcic_ble_set_ext_adv_data(UINT8 adv_handle, UINT8 *pp; HCI_TRACE_EVENT("%s, adv_handle = %d, operation = %d, fragment_prefrence = %d,\ data_len = %d", __func__, adv_handle, operation, fragment_prefrence, data_len); - ext_adv_flag = true; HCIC_BLE_CMD_CREATED(p, pp, data_len + 4); UINT16_TO_STREAM(pp, HCI_BLE_SET_EXT_ADV_DATA); @@ -1421,10 +1467,40 @@ UINT8 btsnd_hcic_ble_clear_adv_set(void) #endif // #if (BLE_50_EXTEND_ADV_EN == TRUE) #if (BLE_50_PERIODIC_ADV_EN == TRUE) +#if (BT_BLE_FEAT_PAWR_EN == TRUE) +UINT8 btsnd_hcic_ble_set_periodic_adv_params_v2(UINT8 adv_handle, UINT16 interval_min, UINT16 interval_max, + UINT16 propertics, UINT8 num_subevents, UINT8 subevent_interval, + UINT8 rsp_slot_delay, UINT8 rsp_slot_spacing, UINT8 num_rsp_slots) +{ + BT_HDR *p; + UINT8 *pp; + HCI_TRACE_EVENT("%s, adv_handle = %d, interval_min = %d, interval_max = %d, propertics = %d num_subevents = %d subevent_interval = %d rsp_slot_delay %d rsp_slot_spacing %d num_rsp_slots %d", + __func__, adv_handle, interval_min, interval_max, propertics, num_subevents, subevent_interval, rsp_slot_delay, rsp_slot_spacing, num_rsp_slots); + + HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_SET_PERIODIC_ADV_PARAMS_V2); + + UINT16_TO_STREAM(pp, HCI_BLE_SET_PERIOD_ADV_PARAMS_V2); + UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_SET_PERIODIC_ADV_PARAMS_V2); + + UINT8_TO_STREAM(pp, adv_handle); + UINT16_TO_STREAM(pp, interval_min); + UINT16_TO_STREAM(pp, interval_max); + UINT16_TO_STREAM(pp, propertics); + UINT8_TO_STREAM(pp, num_subevents); + UINT8_TO_STREAM(pp, subevent_interval); + UINT8_TO_STREAM(pp, rsp_slot_delay); + UINT8_TO_STREAM(pp, rsp_slot_spacing); + UINT8_TO_STREAM(pp, num_rsp_slots); + + return btu_hcif_send_cmd_sync(LOCAL_BR_EDR_CONTROLLER_ID, p); + +} + +#else UINT8 btsnd_hcic_ble_set_periodic_adv_params(UINT8 adv_handle, UINT16 interval_min, UINT16 interval_max, - UINT8 propertics) + UINT16 propertics) { BT_HDR *p; UINT8 *pp; @@ -1445,6 +1521,9 @@ UINT8 btsnd_hcic_ble_set_periodic_adv_params(UINT8 adv_handle, } +#endif // (BT_BLE_FEAT_PAWR_EN == TRUE) + + UINT8 btsnd_hcic_ble_set_periodic_adv_data(UINT8 adv_handle, UINT8 operation, UINT8 len, @@ -1618,6 +1697,82 @@ BOOLEAN btsnd_hcic_ble_create_ext_conn(tHCI_CreatExtConn *p_conn) } +#if (BT_BLE_FEAT_PAWR_EN == TRUE) +BOOLEAN btsnd_hcic_ble_create_ext_conn_v2(tHCI_CreatExtConn *p_conn) +{ + BT_HDR *p; + UINT8 *pp; + tHCI_ExtConnParams *params; + HCI_TRACE_EVENT("%s", __func__); + uint8_t size = HCIC_PARAM_SIZE_EXT_CONN_CREATE_BASE + 2; + + if (p_conn->init_phy_mask & 0x01) { + size += sizeof(tHCI_ExtConnParams); + } + + if (p_conn->init_phy_mask & 0x02) { + size += sizeof(tHCI_ExtConnParams); + } + + if (p_conn->init_phy_mask & 0x04) { + size += sizeof(tHCI_ExtConnParams); + } + + HCIC_BLE_CMD_CREATED(p, pp, size); + + UINT16_TO_STREAM(pp, HCI_BLE_EXT_CREATE_CONN_V2); + UINT8_TO_STREAM(pp, size); + UINT8_TO_STREAM(pp, p_conn->adv_handle); + UINT8_TO_STREAM(pp, p_conn->subevent); + UINT8_TO_STREAM(pp, p_conn->filter_policy); + UINT8_TO_STREAM(pp, p_conn->filter_policy); + UINT8_TO_STREAM(pp, p_conn->own_addr_type); + UINT8_TO_STREAM(pp, p_conn->peer_addr_type); + BDADDR_TO_STREAM(pp, p_conn->peer_addr); + UINT8_TO_STREAM(pp, p_conn->init_phy_mask); + + if (p_conn->init_phy_mask & 0x01) { + params = &p_conn->params[0]; + UINT16_TO_STREAM(pp, params->scan_interval); + UINT16_TO_STREAM(pp, params->scan_window); + UINT16_TO_STREAM(pp, params->conn_interval_min); + UINT16_TO_STREAM(pp, params->conn_interval_max); + UINT16_TO_STREAM(pp, params->conn_latency); + UINT16_TO_STREAM(pp, params->sup_timeout); + UINT16_TO_STREAM(pp, params->min_ce_len ? params->min_ce_len : BLE_CE_LEN_MIN); + UINT16_TO_STREAM(pp, params->max_ce_len ? params->max_ce_len : BLE_CE_LEN_MIN); + } + + if (p_conn->init_phy_mask & 0x02) { + params = &p_conn->params[1]; + UINT16_TO_STREAM(pp, params->scan_interval); + UINT16_TO_STREAM(pp, params->scan_window); + UINT16_TO_STREAM(pp, params->conn_interval_min); + UINT16_TO_STREAM(pp, params->conn_interval_max); + UINT16_TO_STREAM(pp, params->conn_latency); + UINT16_TO_STREAM(pp, params->sup_timeout); + UINT16_TO_STREAM(pp, params->min_ce_len ? params->min_ce_len : BLE_CE_LEN_MIN); + UINT16_TO_STREAM(pp, params->max_ce_len ? params->max_ce_len : BLE_CE_LEN_MIN); + } + + if (p_conn->init_phy_mask & 0x04) { + params = &p_conn->params[2]; + UINT16_TO_STREAM(pp, params->scan_interval); + UINT16_TO_STREAM(pp, params->scan_window); + UINT16_TO_STREAM(pp, params->conn_interval_min); + UINT16_TO_STREAM(pp, params->conn_interval_max); + UINT16_TO_STREAM(pp, params->conn_latency); + UINT16_TO_STREAM(pp, params->sup_timeout); + UINT16_TO_STREAM(pp, params->min_ce_len ? params->min_ce_len : BLE_CE_LEN_MIN); + UINT16_TO_STREAM(pp, params->max_ce_len ? params->max_ce_len : BLE_CE_LEN_MIN); + } + + btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p); + return TRUE; + +} +#endif // (BT_BLE_FEAT_PAWR_EN == TRUE) + #if (BLE_50_EXTEND_SYNC_EN == TRUE) BOOLEAN btsnd_hcic_ble_periodic_adv_create_sync(UINT8 option, UINT8 adv_sid, UINT8 adv_addr_type, BD_ADDR adv_addr, @@ -2808,3 +2963,435 @@ UINT8 btsnd_hcic_ble_set_host_feature(uint16_t bit_num, uint8_t bit_val) return btu_hcif_send_cmd_sync(LOCAL_BR_EDR_CONTROLLER_ID, p); } #endif // #if (BLE_50_FEATURE_SUPPORT == TRUE) + +#if (BT_BLE_FEAT_PAWR_EN == TRUE) +UINT8 btsnd_hcic_ble_set_periodic_adv_subevt_data(UINT8 adv_handle, UINT8 num_subevents_with_data, ble_subevent_params *subevent_params) +{ + BT_HDR *p; + UINT8 *pp; + uint8_t param_len = 0; + + HCI_TRACE_DEBUG("hci set PA subevent data, adv_handle %d num_subevents_with_data %d", adv_handle, num_subevents_with_data); + + if (!subevent_params) { + HCI_TRACE_ERROR("%s error\n", __func__); + return HCI_ERR_ILLEGAL_PARAMETER_FMT; + } + param_len += HCIC_PARAM_SIZE_SET_PA_SUBEVT_DATA_PARAMS_LEN; + + for (UINT8 i = 0; i < num_subevents_with_data; i++) + { + HCI_TRACE_DEBUG("subevent_params: subevent %d response_slot_start %d response_slot_count %d subevent_data_len %d", + subevent_params[i].subevent, subevent_params[i].response_slot_start, subevent_params[i].response_slot_count, + subevent_params[i].subevent_data_len); + + if (subevent_params[i].subevent_data_len) { + esp_log_buffer_hex_internal("data", subevent_params[i].data, subevent_params[i].subevent_data_len, ESP_LOG_DEBUG); + } + + param_len += (4 + subevent_params->subevent_data_len); + } + + HCIC_BLE_CMD_CREATED(p, pp, param_len); + + pp = (UINT8 *)(p + 1); + + UINT16_TO_STREAM(pp, HCI_BLE_SET_PERIOD_ADV_SUBEVT_DATA); + UINT8_TO_STREAM(pp, param_len); + + UINT8_TO_STREAM(pp, adv_handle); + UINT8_TO_STREAM(pp, num_subevents_with_data); + for (UINT8 i = 0; i < num_subevents_with_data; i++) + { + UINT8_TO_STREAM(pp, subevent_params[i].subevent); + UINT8_TO_STREAM(pp, subevent_params[i].response_slot_start); + UINT8_TO_STREAM(pp, subevent_params[i].response_slot_count); + UINT8_TO_STREAM(pp, subevent_params[i].subevent_data_len); + if (subevent_params[i].subevent_data_len) { + ARRAY_TO_STREAM(pp, subevent_params[i].data, subevent_params[i].subevent_data_len); + } + } + + return btu_hcif_send_cmd_sync(LOCAL_BR_EDR_CONTROLLER_ID, p); +} + +UINT8 btsnd_hcic_ble_set_periodic_adv_rsp_data(UINT16 sync_handle, UINT16 req_evt, UINT8 req_subevt, UINT8 rsp_subevt, UINT8 rsp_slot, UINT8 rsp_data_len, UINT8 *rsp_data) +{ + BT_HDR *p; + UINT8 *pp; + + HCI_TRACE_DEBUG("hci set PA rsp data, sync_handle %d req_evt %d req_subevt %d rsp_subevt %d rsp_slot %d rsp_data_len %d", + sync_handle, req_evt, req_subevt, rsp_subevt, rsp_slot, rsp_data_len); + + HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_SET_PA_RESPONSE_DATA_PARAMS_LEN + rsp_data_len); + + pp = (UINT8 *)(p + 1); + + UINT16_TO_STREAM(pp, HCI_BLE_SET_PERIOD_ADV_RSP_DATA); + UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_SET_PA_RESPONSE_DATA_PARAMS_LEN + rsp_data_len); + + UINT16_TO_STREAM(pp, sync_handle); + UINT16_TO_STREAM(pp, req_evt); + UINT8_TO_STREAM(pp, req_subevt); + UINT8_TO_STREAM(pp, rsp_subevt); + UINT8_TO_STREAM(pp, rsp_slot); + UINT8_TO_STREAM(pp, rsp_data_len); + + if (rsp_data) { + ARRAY_TO_STREAM(pp, rsp_data, rsp_data_len); + } + + return btu_hcif_send_cmd_sync(LOCAL_BR_EDR_CONTROLLER_ID, p); +} + +UINT8 btsnd_hcic_ble_set_periodic_sync_subevt(UINT16 sync_handle, UINT16 periodic_adv_properties, UINT8 num_subevents_to_sync, UINT8 *subevt) +{ + BT_HDR *p; + UINT8 *pp; + + HCI_TRACE_DEBUG("hci set PA sync subevent, sync_handle %d periodic_adv_properties %d num_subevents_to_sync %d", + sync_handle, periodic_adv_properties, num_subevents_to_sync); + for (UINT8 i = 0; i < num_subevents_to_sync; i++) + { + HCI_TRACE_DEBUG("subevt[%d] = %d", i, subevt[i]); + } + + HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_SET_PA_SYNC_SUBEVT_PARAMS_LEN + num_subevents_to_sync); + + pp = (UINT8 *)(p + 1); + + UINT16_TO_STREAM(pp, HCI_BLE_SET_PERIOD_SYNC_SUBEVT); + UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_SET_PA_SYNC_SUBEVT_PARAMS_LEN + num_subevents_to_sync); + + UINT16_TO_STREAM(pp, sync_handle); + UINT16_TO_STREAM(pp, periodic_adv_properties); + UINT8_TO_STREAM(pp, num_subevents_to_sync); + for (UINT8 i = 0; i < num_subevents_to_sync; i++) + { + UINT8_TO_STREAM(pp, subevt[i]); + } + + return btu_hcif_send_cmd_sync(LOCAL_BR_EDR_CONTROLLER_ID, p); +} +#endif // #if (BT_BLE_FEAT_PAWR_EN == TRUE) + +#if (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE) +UINT8 btsnd_hcic_ble_cs_read_local_supported_caps(void) +{ + BT_HDR *p; + UINT8 *pp; + + HCI_TRACE_DEBUG("cs read local supported caps"); + + HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_READ_LOCAL_SUPP_CAPS_PARAMS_LEN); + + pp = (UINT8 *)(p + 1); + + UINT16_TO_STREAM(pp, HCI_BLE_CS_READ_LOCAL_SUPP_CAPS); + UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_READ_LOCAL_SUPP_CAPS_PARAMS_LEN); + + btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p); + return (TRUE); +} + +UINT8 btsnd_hcic_ble_cs_read_remote_supported_capabilities(UINT16 conn_handle) +{ + BT_HDR *p; + UINT8 *pp; + + HCI_TRACE_DEBUG("cs read remote supported caps, conn_handle %d", conn_handle); + + HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_READ_REMOTE_SUPP_CAPS_PARAMS_LEN); + + pp = (UINT8 *)(p + 1); + + UINT16_TO_STREAM(pp, HCI_BLE_CS_READ_REMOTE_SUPP_CAPS); + UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_READ_REMOTE_SUPP_CAPS_PARAMS_LEN); + UINT16_TO_STREAM(pp, conn_handle); + + btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p); + return (TRUE); +} + +UINT8 btsnd_hcic_ble_cs_write_cached_remote_supported_capabilities(UINT16 conn_handle, UINT8 num_config_supported, UINT16 max_consecutive_proc_supported, + UINT8 num_ant_supported, UINT8 max_ant_paths_supported, UINT8 roles_supported, + UINT8 modes_supported, UINT8 rtt_capability, UINT8 rtt_aa_only_n, + UINT8 rtt_sounding_n, UINT8 rtt_random_payload_n, UINT16 NADM_sounding_capability, + UINT16 NADM_random_capability, UINT8 cs_sync_phys_supported, UINT16 subfeatures_supported, + UINT16 T_IP1_times_supported, UINT16 T_IP2_times_supported, UINT16 T_FCS_times_supported, + UINT16 T_PM_times_supported, UINT8 T_SW_times_supported, UINT8 TX_SNR_capability) +{ + BT_HDR *p; + UINT8 *pp; + + HCI_TRACE_DEBUG("cs write cached remote supported caps"); + HCI_TRACE_DEBUG("conn_handle %d num_config_supported %d max_consecutive_proc_supported %d, num_ant_supported %d max_ant_paths_supported %d roles_supported %d,\ + modes_supported %d, rtt_capability %d, rtt_aa_only_n %d, rtt_sounding_n %d, rtt_random_payload_n %d, NADM_sounding_capability %d, NADM_random_capability %d\ + ,cs_sync_phys_supported %d, subfeatures_supported %d, T_IP1_times_supported %d, T_IP2_times_supported %d, T_FCS_times_supported %d, T_PM_times_supported %d\ + ,T_SW_times_supported %d, TX_SNR_capability %d", + conn_handle, num_config_supported, max_consecutive_proc_supported, num_ant_supported, max_ant_paths_supported, roles_supported, + modes_supported, rtt_capability, rtt_aa_only_n, rtt_sounding_n, rtt_random_payload_n, NADM_sounding_capability, + NADM_random_capability, cs_sync_phys_supported, subfeatures_supported, T_IP1_times_supported, T_IP2_times_supported, T_FCS_times_supported, + T_PM_times_supported, T_SW_times_supported, TX_SNR_capability); + + HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_WRITE_CACHE_REMOTE_SUPP_CAPS_PARAMS_LEN); + + pp = (UINT8 *)(p + 1); + + UINT16_TO_STREAM(pp, HCI_BLE_CS_WRITE_CACHED_REMOTE_SUPP_CAPS); + UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_WRITE_CACHE_REMOTE_SUPP_CAPS_PARAMS_LEN); + UINT16_TO_STREAM(pp, conn_handle); + UINT8_TO_STREAM(pp, num_config_supported); + UINT16_TO_STREAM(pp, max_consecutive_proc_supported); + UINT8_TO_STREAM(pp, num_ant_supported); + UINT8_TO_STREAM(pp, max_ant_paths_supported); + UINT8_TO_STREAM(pp, roles_supported); + UINT8_TO_STREAM(pp, modes_supported); + UINT8_TO_STREAM(pp, rtt_capability); + UINT8_TO_STREAM(pp, rtt_aa_only_n); + UINT8_TO_STREAM(pp, rtt_sounding_n); + UINT8_TO_STREAM(pp, rtt_random_payload_n); + UINT16_TO_STREAM(pp, NADM_sounding_capability); + UINT16_TO_STREAM(pp, NADM_random_capability); + UINT8_TO_STREAM(pp, cs_sync_phys_supported); + UINT16_TO_STREAM(pp, subfeatures_supported); + UINT16_TO_STREAM(pp, T_IP1_times_supported); + UINT16_TO_STREAM(pp, T_IP2_times_supported); + UINT16_TO_STREAM(pp, T_FCS_times_supported); + UINT16_TO_STREAM(pp, T_PM_times_supported); + UINT8_TO_STREAM(pp, T_SW_times_supported); + UINT8_TO_STREAM(pp, TX_SNR_capability); + + return btu_hcif_send_cmd_sync(LOCAL_BR_EDR_CONTROLLER_ID, p); + +} + +UINT8 btsnd_hcic_ble_cs_security_enable(UINT16 conn_handle) +{ + BT_HDR *p; + UINT8 *pp; + + HCI_TRACE_DEBUG("cs security enable conn_handle %d", conn_handle); + + HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_SECURITY_ENABLE_PARAMS_LEN); + + pp = (UINT8 *)(p + 1); + + UINT16_TO_STREAM(pp, HCI_BLE_CS_SECURITY_ENABLE); + UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_SECURITY_ENABLE_PARAMS_LEN); + UINT16_TO_STREAM(pp, conn_handle); + + btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p); + return (TRUE); +} + +UINT8 btsnd_hcic_ble_cs_set_default_settings(UINT16 conn_handle, UINT8 role_enable, UINT8 cs_sync_ant_selection, INT8 max_tx_power) +{ + BT_HDR *p; + UINT8 *pp; + + HCI_TRACE_DEBUG("cs set default settings, conn_handle %d role_enable %d cs_sync_ant_selection %d max_tx_power %d", conn_handle, role_enable, cs_sync_ant_selection, max_tx_power); + + HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_SET_DEFAULT_SETTINGS_PARAMS_LEN); + + pp = (UINT8 *)(p + 1); + + UINT16_TO_STREAM(pp, HCI_BLE_CS_SET_DEFAULT_SETTINGS); + UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_SET_DEFAULT_SETTINGS_PARAMS_LEN); + UINT16_TO_STREAM(pp, conn_handle); + UINT8_TO_STREAM(pp, role_enable); + UINT8_TO_STREAM(pp, cs_sync_ant_selection); + INT8_TO_STREAM(pp, max_tx_power); + + return btu_hcif_send_cmd_sync(LOCAL_BR_EDR_CONTROLLER_ID, p); +} + +UINT8 btsnd_hcic_ble_cs_read_remote_fae_table(UINT16 conn_handle) +{ + BT_HDR *p; + UINT8 *pp; + + HCI_TRACE_DEBUG("cs read remote fae table, conn_handle %d", conn_handle); + + HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_READ_REMOTE_FAE_TAB_PARAMS_LEN); + + pp = (UINT8 *)(p + 1); + + UINT16_TO_STREAM(pp, HCI_BLE_CS_READ_REMOTE_FAE_TABLE); + UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_READ_REMOTE_FAE_TAB_PARAMS_LEN); + UINT16_TO_STREAM(pp, conn_handle); + + btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p); + return (TRUE); +} + +UINT8 btsnd_hcic_ble_cs_write_cached_remote_fae_table(UINT16 conn_handle, UINT8 *remote_fae_table) +{ + BT_HDR *p; + UINT8 *pp; + + HCI_TRACE_DEBUG("cs write cached remote fae table, conn_handle %d", conn_handle); + esp_log_buffer_hex_internal("remote_fae_table", remote_fae_table, 72, ESP_LOG_DEBUG); + + HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_WRITE_CACHED_REMOTE_FAE_TAB_PARAMS_LEN); + + pp = (UINT8 *)(p + 1); + + UINT16_TO_STREAM(pp, HCI_BLE_CS_WRITE_CACHED_REMOTE_FAE_TABLE); + UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_WRITE_CACHED_REMOTE_FAE_TAB_PARAMS_LEN); + UINT16_TO_STREAM(pp, conn_handle); + ARRAY_TO_STREAM(pp, remote_fae_table, 72); + + return btu_hcif_send_cmd_sync(LOCAL_BR_EDR_CONTROLLER_ID, p); +} + +UINT8 btsnd_hcic_ble_cs_create_config(UINT16 conn_handle, UINT8 config_id, UINT8 create_context, + UINT8 main_mode_type, UINT8 sub_mode_type, UINT8 min_main_mode_steps, + UINT8 max_main_mode_steps, UINT8 main_mode_repetition, UINT8 mode_0_steps, + UINT8 role, UINT8 rtt_type, UINT8 cs_sync_phy, UINT8 *channel_map, + UINT8 channel_map_repetition, UINT8 channel_selection_type, UINT8 ch3c_shape, + UINT8 ch3c_jump,UINT8 reserved) +{ + BT_HDR *p; + UINT8 *pp; + + HCI_TRACE_DEBUG("cs create config"); + HCI_TRACE_DEBUG("conn_handle %d config_id %d create_context %d main_mode_type %d sub_mode_type %d min_main_mode_steps %d max_main_mode_steps\ + %d main_mode_repetition %d mode_0_steps %d role %d rtt_type %d cs_sync_phy %d, channel_map_repetition %d, channel_selection_type %d\ + ch3c_shape %d ch3c_jump %d,reserved %d", conn_handle, config_id, create_context, main_mode_type, sub_mode_type, min_main_mode_steps, max_main_mode_steps,\ + main_mode_repetition, mode_0_steps, role, rtt_type, cs_sync_phy, channel_map_repetition, channel_selection_type\ + ,ch3c_shape, ch3c_jump, reserved); + esp_log_buffer_hex_internal("channel_map", channel_map, 10, ESP_LOG_DEBUG); + + HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_CREATE_CONFIG_PARAMS_LEN); + + pp = (UINT8 *)(p + 1); + + UINT16_TO_STREAM(pp, HCI_BLE_CS_CREATE_CONFIG); + UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_CREATE_CONFIG_PARAMS_LEN); + UINT16_TO_STREAM(pp, conn_handle); + UINT8_TO_STREAM(pp, config_id); + UINT8_TO_STREAM(pp, create_context); + UINT8_TO_STREAM(pp, main_mode_type); + UINT8_TO_STREAM(pp, sub_mode_type); + UINT8_TO_STREAM(pp, min_main_mode_steps); + UINT8_TO_STREAM(pp, max_main_mode_steps); + UINT8_TO_STREAM(pp, main_mode_repetition); + UINT8_TO_STREAM(pp, mode_0_steps); + UINT8_TO_STREAM(pp, role); + UINT8_TO_STREAM(pp, rtt_type); + UINT8_TO_STREAM(pp, cs_sync_phy); + ARRAY_TO_STREAM(pp, channel_map, 10); + UINT8_TO_STREAM(pp, channel_map_repetition); + UINT8_TO_STREAM(pp, channel_selection_type); + UINT8_TO_STREAM(pp, ch3c_shape); + UINT8_TO_STREAM(pp, ch3c_jump); + UINT8_TO_STREAM(pp, reserved); + + btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p); + return (TRUE); +} + +UINT8 btsnd_hcic_ble_cs_remove_config(UINT16 conn_handle, UINT8 config_id) +{ + BT_HDR *p; + UINT8 *pp; + + HCI_TRACE_DEBUG("cs remove config, conn_handle %d config_id %d", conn_handle, config_id); + + HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_REMOVE_CONFIG_PARAMS_LEN); + + pp = (UINT8 *)(p + 1); + + UINT16_TO_STREAM(pp, HCI_BLE_CS_REMOVE_CONFIG); + UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_REMOVE_CONFIG_PARAMS_LEN); + UINT16_TO_STREAM(pp, conn_handle); + UINT8_TO_STREAM(pp, config_id); + + btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p); + + return TRUE; +} + +UINT8 btsnd_hcic_ble_cs_set_channel_classification(UINT8 *channel_class) +{ + BT_HDR *p; + UINT8 *pp; + + HCI_TRACE_DEBUG("cs set channel class"); + esp_log_buffer_hex_internal("channel", channel_class, 10, ESP_LOG_DEBUG); + + HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_SET_CHANNEL_CLASS_PARAMS_LEN); + + pp = (UINT8 *)(p + 1); + + UINT16_TO_STREAM(pp, HCI_BLE_CS_SET_CAHNNEL_CLASS); + UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_SET_CHANNEL_CLASS_PARAMS_LEN); + ARRAY_TO_STREAM(pp, channel_class, 10); + + return btu_hcif_send_cmd_sync(LOCAL_BR_EDR_CONTROLLER_ID, p); +} + +UINT8 btsnd_hcic_ble_cs_set_procedure_params(UINT16 conn_handle, UINT8 config_id, UINT16 max_procedure_len, + UINT16 min_procedure_interval, UINT16 max_procedure_interval, + UINT16 max_procedure_count, UINT32 min_subevent_len, + UINT32 max_subevent_len, UINT8 tone_ant_config_selection, + UINT8 phy, UINT8 tx_power_delta, UINT8 preferred_peer_antenna, + UINT8 SNR_control_initiator, UINT8 SNR_control_reflector) +{ + BT_HDR *p; + UINT8 *pp; + + HCI_TRACE_DEBUG("cs set procedure params"); + HCI_TRACE_DEBUG("conn_handle %d config_id %d max_procedure_len %d min_procedure_interval %d max_procedure_interval %d\ + max_procedure_count %d min_subevent_len %d max_subevent_len %d tone_ant_config_selection %d phy %d tx_power_delta %d,\ + preferred_peer_antenna %d SNR_control_initiator %d SNR_control_reflector %d\n", + conn_handle, config_id, max_procedure_len, min_procedure_interval, max_procedure_interval, max_procedure_count, min_subevent_len, max_subevent_len, + tone_ant_config_selection, phy, tx_power_delta, preferred_peer_antenna, SNR_control_initiator, SNR_control_reflector); + + HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_SET_PROCEDURE_PARAMS_LEN); + + pp = (UINT8 *)(p + 1); + + UINT16_TO_STREAM(pp, HCI_BLE_CS_SET_PROCEDURE_PARAMS); + UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_SET_PROCEDURE_PARAMS_LEN); + UINT16_TO_STREAM(pp, conn_handle); + UINT8_TO_STREAM(pp, config_id); + UINT16_TO_STREAM(pp, max_procedure_len); + UINT16_TO_STREAM(pp, min_procedure_interval); + UINT16_TO_STREAM(pp, max_procedure_interval); + UINT16_TO_STREAM(pp, max_procedure_count); + UINT24_TO_STREAM(pp, min_subevent_len); + UINT24_TO_STREAM(pp, max_subevent_len); + UINT8_TO_STREAM(pp, tone_ant_config_selection); + UINT8_TO_STREAM(pp, phy); + UINT8_TO_STREAM(pp, tx_power_delta); + UINT8_TO_STREAM(pp, preferred_peer_antenna); + UINT8_TO_STREAM(pp, SNR_control_initiator); + UINT8_TO_STREAM(pp, SNR_control_reflector); + + return btu_hcif_send_cmd_sync(LOCAL_BR_EDR_CONTROLLER_ID, p); +} + +UINT8 btsnd_hcic_ble_cs_procedure_enable(UINT16 conn_handle, UINT8 config_id, UINT8 enable) +{ + BT_HDR *p; + UINT8 *pp; + + HCI_TRACE_DEBUG("cs set procedure enable, conn_handle %d config_id %d enable %d", conn_handle, config_id, enable); + + HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_SET_PROCEDURE_ENABLE_PARAMS_LEN); + + pp = (UINT8 *)(p + 1); + + UINT16_TO_STREAM(pp, HCI_BLE_CS_SET_PROCEDURE_ENABLE); + UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_SET_PROCEDURE_ENABLE_PARAMS_LEN); + UINT16_TO_STREAM(pp, conn_handle); + UINT8_TO_STREAM(pp, config_id); + UINT8_TO_STREAM(pp, enable); + + btu_hcif_send_cmd_sync(LOCAL_BR_EDR_CONTROLLER_ID, p); + + return TRUE; +} +#endif // (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE) diff --git a/components/bt/host/bluedroid/stack/include/stack/btm_ble_api.h b/components/bt/host/bluedroid/stack/include/stack/btm_ble_api.h index e696fe65cf..8961197865 100644 --- a/components/bt/host/bluedroid/stack/include/stack/btm_ble_api.h +++ b/components/bt/host/bluedroid/stack/include/stack/btm_ble_api.h @@ -781,6 +781,10 @@ typedef struct { tBTM_BLE_GAP_PHY secondary_phy; UINT8 sid; BOOLEAN scan_req_notif; +#if (BT_BLE_FEAT_ADV_CODING_SELECTION == TRUE) + UINT8 primary_adv_phy_options; + UINT8 secondary_adv_phy_options; +#endif // (BT_BLE_FEAT_ADV_CODING_SELECTION == TRUE) } tBTM_BLE_GAP_EXT_ADV_PARAMS; typedef struct { @@ -808,7 +812,14 @@ typedef struct { typedef struct { UINT16 interval_min; UINT16 interval_max; - UINT8 properties; + UINT16 properties; +#if (BT_BLE_FEAT_PAWR_EN == TRUE) + UINT8 num_subevents; + UINT8 subevent_interval; + UINT8 rsp_slot_delay; + UINT8 rsp_slot_spacing; + UINT8 num_rsp_slots; +#endif // (BT_BLE_FEAT_PAWR_EN == TRUE) } tBTM_BLE_Periodic_Adv_Params; typedef struct { @@ -1090,7 +1101,29 @@ typedef void (tBTM_SET_VENDOR_EVT_MASK_CBACK) (tBTM_STATUS status); #if (BLE_50_FEATURE_SUPPORT == TRUE) #define BTM_BLE_GAP_SET_HOST_FEATURE_EVT 51 #endif // #if (BLE_50_FEATURE_SUPPORT == TRUE) -#define BTM_BLE_5_GAP_UNKNOWN_EVT 52 +#if (BT_BLE_FEAT_PAWR_EN == TRUE) +#define BTM_BLE_GAP_SET_PERIODIC_ADV_SUBEVT_DATA_EVT 52 +#define BTM_BLE_GAP_SET_PERIODIC_ADV_RESPONSE_DATA_EVT 53 +#define BTM_BLE_GAP_SET_PERIODIC_SYNC_SUBEVT_EVT 54 +#define BTM_BLE_GAP_PERIODIC_ADV_SUBEVT_DATA_REQUEST_EVT 55 +#define BTM_BLE_GAP_PERIODIC_ADV_RESPONSE_REPORT_EVT 56 +#endif // #if (BT_BLE_FEAT_PAWR_EN == TRUE) +#if (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE) +#define BTM_BLE_GAP_CS_READ_LOCAL_SUPP_CAPS_EVT 57 +#define BTM_BLE_GAP_CS_WRITE_CACHED_REMOTE_SUPP_CAPS_EVT 58 +#define BTM_BLE_GAP_CS_SET_DEFAULT_SETTINGS_EVT 59 +#define BTM_BLE_GAP_CS_WRITE_CACHED_REMOTE_FAE_TAB_EVT 60 +#define BTM_BLE_GAP_CS_READ_REMOTE_SUPP_CAPS_CMPL_EVT 61 +#define BTM_BLE_GAP_CS_SET_CHANNEL_CLASS_CMPL_EVT 62 +#define BTM_BLE_GAP_CS_PROC_PARAMS_CMPL_EVT 63 +#define BTM_BLE_GAP_CS_PROC_ENABLE_CMPL_EVT 64 +#define BTM_BLE_GAP_CS_READ_REMOTE_FAE_TABLE_CMPL_EVT 65 +#define BTM_BLE_GAP_CS_SECURITY_ENABLE_CMPL_EVT 66 +#define BTM_BLE_GAP_CS_CONFIG_CMPL_EVT 67 +#define BTM_BLE_GAP_CS_SUBEVENT_RESULT_EVT 68 +#define BTM_BLE_GAP_CS_SUBEVENT_RESULT_CONTINUE_EVT 69 +#endif // (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE) +#define BTM_BLE_5_GAP_UNKNOWN_EVT 70 typedef UINT8 tBTM_BLE_5_GAP_EVENT; #if (BLE_FEAT_ISO_EN == TRUE) @@ -1332,6 +1365,10 @@ typedef struct { UINT8 tx_power; INT8 rssi; UINT8 cte_type; +#if (BT_BLE_FEAT_PAWR_EN == TRUE) + UINT16 periodic_evt_cnt; + UINT8 subevt; +#endif // (BT_BLE_FEAT_PAWR_EN == TRUE) tBTM_BLE_EXT_ADV_DATA_STATUS data_status; UINT8 data_length; UINT8 *data; @@ -1350,6 +1387,12 @@ typedef struct { UINT8 adv_phy; UINT16 period_adv_interval; UINT8 adv_clk_accuracy; +#if (BT_BLE_FEAT_PAWR_EN == TRUE) + UINT8 num_subevt; + UINT8 subevt_interval; + UINT8 rsp_slot_delay; + UINT8 rsp_slot_spacing; +#endif // (BT_BLE_FEAT_PAWR_EN == TRUE) } tBTM_BLE_PERIOD_ADV_SYNC_ESTAB; typedef struct { @@ -1453,6 +1496,199 @@ typedef struct { } __attribute__((packed)) tBTM_BLE_SUBRATE_CHANGE_EVT; #endif // #if (BLE_FEAT_CONN_SUBRATING == TRUE) +#if (BT_BLE_FEAT_PAWR_EN == TRUE) +typedef struct { + UINT8 status; + UINT8 adv_handle; +} __attribute__((packed)) tBTM_BLE_PA_SUBEVT_DATA_EVT; +typedef struct { + UINT8 status; + UINT16 sync_handle; +} __attribute__((packed)) tBTM_BLE_PA_RSP_DATA_EVT; +typedef struct { + UINT8 status; + UINT16 sync_handle; +} __attribute__((packed)) tBTM_BLE_PA_SYNC_SUBEVT_DATA_EVT; +typedef struct { + UINT8 adv_handle; + UINT8 subevt_start; + UINT8 subevt_data_count; +} __attribute__((packed)) tBTM_BLE_PA_SUBEVT_DATA_REQ_EVT; + +typedef struct { + INT8 tx_power; + INT8 rssi; + UINT8 cte_type; + UINT8 rsp_slot; + UINT8 data_status; + UINT8 data_len; + UINT8 *data; +} __attribute__((packed)) tBTM_BLE_PA_RSP_DATA_INFO; + +typedef struct { + UINT8 adv_handle; + UINT8 subevt; + UINT8 tx_status; + UINT8 num_rsp; + tBTM_BLE_PA_RSP_DATA_INFO *rsp_data_info; +} __attribute__((packed)) tBTM_BLE_PA_RSP_REPORT_EVT; +#endif // #if (BT_BLE_FEAT_PAWR_EN == TRUE) + +#if (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE) +typedef struct { + UINT8 status; + UINT16 conn_handle; +} __attribute__((packed)) tBTM_BLE_CS_WRITE_CACHED_SUPPORT_CAPS_EVT; +typedef struct { + UINT8 status; + UINT16 conn_handle; +} __attribute__((packed)) tBTM_BLE_CS_SET_DEFAULT_SETTINGS_EVT; +typedef struct { + UINT8 status; + UINT16 conn_handle; +} __attribute__((packed)) tBTM_BLE_CS_WRITE_CACHED_REMOTE_FAE_TAB_EVT; +typedef struct { + UINT8 status; + UINT16 conn_handle; +} __attribute__((packed)) tBTM_BLE_CS_SET_PAROC_PARAMS_EVT; +typedef struct { + UINT8 status; + UINT16 conn_handle; + UINT8 num_config_supported; + UINT16 max_consecutive_proc_supported; + UINT8 num_ant_supported; + UINT8 max_ant_paths_supported; + UINT8 roles_supported; + UINT8 modes_supported; + UINT8 rtt_capability; + UINT8 rtt_aa_only_n; + UINT8 rtt_sounding_n; + UINT8 rtt_random_payload_n; + UINT16 NADM_sounding_capability; + UINT16 NADM_random_capability; + UINT8 cs_sync_phys_supported; + UINT16 subfeatures_supported; + UINT16 T_IP1_times_supported; + UINT16 T_IP2_times_supported; + UINT16 T_FCS_times_supported; + UINT16 T_PM_times_supported; + UINT8 T_SW_times_supported; + UINT8 TX_SNR_capability; +} __attribute__((packed)) tBTM_BLE_CS_READ_REMOTE_SUPP_CAPS_CMPL_EVT; + +typedef struct { + UINT8 status; + UINT16 conn_handle; + UINT8 remote_fae_table[72]; +} __attribute__((packed)) tBTM_BLE_CS_READ_REMOTE_FAE_TAB_CMPL_EVT; + +typedef struct { + UINT8 status; + UINT16 conn_handle; +} __attribute__((packed)) tBTM_BLE_CS_SEC_ENABLE_CMPL_EVT; + +typedef struct { + UINT8 status; + UINT16 conn_handle; + UINT8 config_id; + UINT8 action; + UINT8 main_mode_type; + UINT8 sub_mode_type; + UINT8 min_main_mode_steps; + UINT8 max_main_mode_steps; + UINT8 main_mode_repetition; + UINT8 mode_0_steps; + UINT8 role; + UINT8 rtt_type; + UINT8 cs_sync_phy; + UINT8 channel_map[10]; + UINT8 channel_map_repetition; + UINT8 channel_selection_type; + UINT8 ch3c_shape; + UINT8 ch3c_jump; + UINT8 reserved; + UINT8 t_ip1_time; + UINT8 t_ip2_time; + UINT8 t_fcs_time; + UINT8 t_pm_time; +}__attribute__((packed)) tBTM_BLE_CS_CONFIG_CMPL_EVT; + +typedef struct { + UINT8 status; + UINT16 conn_handle; + UINT8 config_id; + UINT8 state; + UINT8 tone_ant_config_select; + INT8 select_tx_power; + UINT32 subevent_Len; + UINT8 subevents_per_event; + UINT16 subevent_interval; + UINT16 event_interval; + UINT16 procedure_interval; + UINT16 procedure_count; + UINT16 max_procedure_len; +}__attribute__((packed)) tBTM_BLE_CS_PROC_ENABLE_CMPL_EVT; + +typedef struct { + UINT8 step_mode; + UINT8 step_channel; + UINT8 step_data_len; + UINT8 *data; +} __attribute__((packed)) tBTM_BLE_CS_STEP_INFO; + +typedef struct { + UINT16 conn_handle; + UINT8 config_id; + UINT16 start_acl_conn_event_counter; + UINT16 procedure_counter; + INT16 frequency_compensation; + INT8 reference_power_level; + UINT8 procedure_done_status; + UINT8 subevent_done_status; + UINT8 abort_reason; + UINT8 num_ant_paths; + UINT8 num_steps_reported; + tBTM_BLE_CS_STEP_INFO *step_info; +}__attribute__((packed)) tBTM_BLE_CS_SUBEVT_RESULT_CMPL_EVT; + +typedef struct { + UINT16 conn_handle; + UINT8 config_id; + UINT8 proc_done_status; + UINT8 subevt_done_status; + UINT8 abort_reason; + UINT8 num_ant_paths; + UINT8 num_steps_reported; + tBTM_BLE_CS_STEP_INFO *step_info; +}__attribute__((packed)) tBTM_BLE_CS_SUBEVT_RESULT_CONTINUE_EVT; + +typedef struct { + UINT8 status; + UINT16 conn_handle; + UINT8 num_config_supported; + UINT16 max_consecutive_proc_supported; + UINT8 num_ant_supported; + UINT8 max_ant_paths_supported; + UINT8 roles_supported; + UINT8 modes_supported; + UINT8 rtt_capability; + UINT8 rtt_aa_only_n; + UINT8 rtt_sounding_n; + UINT8 rtt_random_payload_n; + UINT16 NADM_sounding_capability; + UINT16 NADM_random_capability; + UINT8 cs_sync_phys_supported; + UINT16 subfeatures_supported; + UINT16 T_IP1_times_supported; + UINT16 T_IP2_times_supported; + UINT16 T_FCS_times_supported; + UINT16 T_PM_times_supported; + UINT8 T_SW_times_supported; + UINT8 TX_SNR_capability; +} __attribute__((packed)) tBTM_BLE_CS_READ_LOCAL_SUPP_CAPS_CMPL_EVT; + +#endif // (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE) + #if (BLE_FEAT_ISO_EN == TRUE) #if (BLE_FEAT_ISO_BIG_BROCASTER_EN == TRUE) typedef struct { @@ -1819,6 +2055,27 @@ typedef union { #if (BLE_FEAT_CONN_SUBRATING == TRUE) tBTM_BLE_SUBRATE_CHANGE_EVT subrate_change_evt; #endif // #if (BLE_FEAT_CONN_SUBRATING == TRUE) +#if (BT_BLE_FEAT_PAWR_EN == TRUE) + tBTM_BLE_PA_SUBEVT_DATA_EVT pa_subevt_data_evt; + tBTM_BLE_PA_RSP_DATA_EVT pa_rsp_data_evt; + tBTM_BLE_PA_SYNC_SUBEVT_DATA_EVT pa_sync_subevt_evt; + tBTM_BLE_PA_SUBEVT_DATA_REQ_EVT pa_subevent_data_req_evt; + tBTM_BLE_PA_RSP_REPORT_EVT pa_rsp_rpt_evt; +#endif // #if (BT_BLE_FEAT_PAWR_EN == TRUE) +#if (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE) + tBTM_BLE_CS_WRITE_CACHED_SUPPORT_CAPS_EVT cs_write_cached_remote_supp_caps; + tBTM_BLE_CS_SET_DEFAULT_SETTINGS_EVT cs_set_default_settings; + tBTM_BLE_CS_WRITE_CACHED_REMOTE_FAE_TAB_EVT cs_write_cached_remote_fae_tab; + tBTM_BLE_CS_SET_PAROC_PARAMS_EVT cs_set_proc_params; + tBTM_BLE_CS_READ_LOCAL_SUPP_CAPS_CMPL_EVT cs_read_local_supp_caps; + tBTM_BLE_CS_READ_REMOTE_SUPP_CAPS_CMPL_EVT cs_read_remote_supp_caps; + tBTM_BLE_CS_READ_REMOTE_FAE_TAB_CMPL_EVT cs_read_remote_fae_tab; + tBTM_BLE_CS_SEC_ENABLE_CMPL_EVT cs_security_enable; + tBTM_BLE_CS_PROC_ENABLE_CMPL_EVT cs_proc_en; + tBTM_BLE_CS_CONFIG_CMPL_EVT cs_config_update; + tBTM_BLE_CS_SUBEVT_RESULT_CMPL_EVT cs_subevt_result; + tBTM_BLE_CS_SUBEVT_RESULT_CONTINUE_EVT cs_subevt_result_continue; +#endif // (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE) } tBTM_BLE_5_GAP_CB_PARAMS; typedef struct { @@ -3371,7 +3628,46 @@ void BTM_BleSetDefaultSubrate(UINT16 subrate_min, UINT16 subrate_max, UINT16 max void BTM_BleSubrateRequest(UINT16 conn_handle, UINT16 subrate_min, UINT16 subrate_max, UINT16 max_latency, UINT16 continuation_number, UINT16 supervision_timeout); #endif // #if (BLE_FEAT_CONN_SUBRATING == TRUE) + #if (BLE_50_FEATURE_SUPPORT == TRUE) tBTM_STATUS BTM_BleSetHostFeature(uint16_t bit_num, uint8_t bit_val); #endif // #if (BLE_50_FEATURE_SUPPORT == TRUE) + +#if (BT_BLE_FEAT_PAWR_EN == TRUE) +void BTM_BleSetPaSubeventData(UINT8 adv_handle, UINT8 num_subevents_with_data, uint8_t *subevent_params); +void BTM_BleSetPaResponseData(UINT16 sync_handle, UINT16 req_evt, UINT8 req_subevt, UINT8 rsp_subevt, UINT8 rsp_slot, UINT8 rsp_data_len, UINT8 *rsp_data); +void BTM_BleSetPaSyncSubevt(UINT16 sync_handle, UINT16 periodic_adv_properties, UINT8 num_subevents_to_sync, UINT8 *subevt); +#endif // #if (BT_BLE_FEAT_PAWR_EN == TRUE) + +#if (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE) +void BTM_BleCSReadLocalSuppCaps(void); +void BTM_BleCSReadRemoteSuppCaps(UINT16 conn_handle); +void BTM_BleGapWriteCachedRemoteSupportedCaps(UINT16 conn_handle, UINT8 num_config_supported, UINT16 max_consecutive_proc_supported, + UINT8 num_ant_supported, UINT8 max_ant_paths_supported, UINT8 roles_supported, + UINT8 modes_supported, UINT8 rtt_capability, UINT8 rtt_aa_only_n, + UINT8 rtt_sounding_n, UINT8 rtt_random_payload_n, UINT16 NADM_sounding_capability, + UINT16 NADM_random_capability, UINT8 cs_sync_phys_supported, UINT16 subfeatures_supported, + UINT16 T_IP1_times_supported, UINT16 T_IP2_times_supported, UINT16 T_FCS_times_supported, + UINT16 T_PM_times_supported, UINT8 T_SW_times_supported, UINT8 TX_SNR_capability); +void BTM_BleGapCsSecurityEnable(UINT16 conn_handle); +void BTM_BleGapCsSetDefaultSetting(UINT16 conn_handle, UINT8 role_enable, UINT8 cs_sync_ant_selection, INT8 max_tx_power); +void BTM_BleGapCsReadRemoteFaeTable(UINT16 conn_handle); +void BTM_BleGapWriteCachedRemoteFaeTable(UINT16 conn_handle, UINT8 *remote_fae_table); +void BTM_BleGapCsCreateConfig(UINT16 conn_handle, UINT8 config_id, UINT8 create_context, + UINT8 main_mode_type, UINT8 sub_mode_type, UINT8 min_main_mode_steps, + UINT8 max_main_mode_steps, UINT8 main_mode_repetition, UINT8 mode_0_steps, + UINT8 role, UINT8 rtt_type, UINT8 cs_sync_phy, UINT8 *channel_map, + UINT8 channel_map_repetition, UINT8 channel_selection_type, UINT8 ch3c_shape, + UINT8 ch3c_jump,UINT8 reserved); +void BTM_BleGapCsRemoveConfig(UINT16 conn_handle, UINT8 config_id); +void BTM_BleGapCsSetChannelClass(UINT8 *channel_class); +void BTM_BleGapCsSetProcPatams(UINT16 conn_handle, UINT8 config_id, UINT16 max_procedure_len, + UINT16 min_procedure_interval, UINT16 max_procedure_interval, + UINT16 max_procedure_count, UINT32 min_subevent_len, + UINT32 max_subevent_len, UINT8 tone_ant_config_selection, + UINT8 phy, UINT8 tx_power_delta, UINT8 preferred_peer_antenna, + UINT8 SNR_control_initiator, UINT8 SNR_control_reflector); +void BTM_BleGapCsProcEnable(UINT16 conn_handle, UINT8 config_id, UINT8 enable); +#endif // (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE) + #endif diff --git a/components/bt/host/bluedroid/stack/include/stack/gap_api.h b/components/bt/host/bluedroid/stack/include/stack/gap_api.h index 62062d2f21..a79d9748c8 100644 --- a/components/bt/host/bluedroid/stack/include/stack/gap_api.h +++ b/components/bt/host/bluedroid/stack/include/stack/gap_api.h @@ -119,6 +119,9 @@ typedef union { UINT16 icon; UINT8 *p_dev_name; UINT8 addr_resolution; +#if (BT_GATTS_SECURITY_LEVELS_CHAR == TRUE) + UINT16 security_level; +#endif // (BT_GATTS_SECURITY_LEVELS_CHAR == TRUE) } tGAP_BLE_ATTR_VALUE; diff --git a/components/bt/host/bluedroid/stack/include/stack/gatt_api.h b/components/bt/host/bluedroid/stack/include/stack/gatt_api.h index 002cb16e33..83667e7724 100644 --- a/components/bt/host/bluedroid/stack/include/stack/gatt_api.h +++ b/components/bt/host/bluedroid/stack/include/stack/gatt_api.h @@ -1140,7 +1140,8 @@ extern void GATT_StartIf (tGATT_IF gatt_if); ** *******************************************************************************/ extern BOOLEAN GATT_Connect (tGATT_IF gatt_if, BD_ADDR bd_addr, tBLE_ADDR_TYPE bd_addr_type, - BOOLEAN is_direct, tBT_TRANSPORT transport, BOOLEAN is_aux); + BOOLEAN is_direct, tBT_TRANSPORT transport, BOOLEAN is_aux, + BOOLEAN is_pawr_synced, UINT8 adv_handle, UINT8 subevent); /******************************************************************************* diff --git a/components/bt/host/bluedroid/stack/include/stack/gattdefs.h b/components/bt/host/bluedroid/stack/include/stack/gattdefs.h index d8e4cb591e..2ae8cef839 100644 --- a/components/bt/host/bluedroid/stack/include/stack/gattdefs.h +++ b/components/bt/host/bluedroid/stack/include/stack/gattdefs.h @@ -52,6 +52,8 @@ #define GATT_UUID_GAP_PREF_CONN_PARAM 0x2A04 #define GATT_UUID_GAP_CENTRAL_ADDR_RESOL 0x2AA6 +#define GATT_UUID_GAP_GATT_SECURITY_LEVELS 0x2BF5 + /* Attribute Profile Attribute UUID */ #define GATT_UUID_GATT_SRV_CHGD 0x2A05 /* Attribute Protocol Test */ @@ -81,7 +83,7 @@ #define GATT_UUID_GM_CONTROL_POINT 0x2A52 #define GATT_UUID_GM_FEATURE 0x2A51 -/* device infor characteristic */ +/* device information characteristic */ #define GATT_UUID_SYSTEM_ID 0x2A23 #define GATT_UUID_MODEL_NUMBER_STR 0x2A24 #define GATT_UUID_SERIAL_NUMBER_STR 0x2A25 diff --git a/components/bt/host/bluedroid/stack/include/stack/hcidefs.h b/components/bt/host/bluedroid/stack/include/stack/hcidefs.h index 23f9b3e6b8..9365de9d54 100644 --- a/components/bt/host/bluedroid/stack/include/stack/hcidefs.h +++ b/components/bt/host/bluedroid/stack/include/stack/hcidefs.h @@ -443,6 +443,33 @@ #define HCI_BLE_SUBRATE_REQUEST (0x007E | HCI_GRP_BLE_CMDS) #endif // #if (BLE_FEAT_CONN_SUBRATING == TRUE) +#if (BT_BLE_FEAT_ADV_CODING_SELECTION == TRUE) +#define HCI_BLE_SET_EXT_ADV_PARAM_V2 (0x007F | HCI_GRP_BLE_CMDS) +#endif // (BT_BLE_FEAT_ADV_CODING_SELECTION == TRUE) + +#if (BT_BLE_FEAT_PAWR_EN == TRUE) +#define HCI_BLE_SET_PERIOD_ADV_SUBEVT_DATA (0x0082 | HCI_GRP_BLE_CMDS) +#define HCI_BLE_SET_PERIOD_ADV_RSP_DATA (0x0083 | HCI_GRP_BLE_CMDS) +#define HCI_BLE_SET_PERIOD_SYNC_SUBEVT (0x0084 | HCI_GRP_BLE_CMDS) +#define HCI_BLE_EXT_CREATE_CONN_V2 (0x0085 | HCI_GRP_BLE_CMDS) +#define HCI_BLE_SET_PERIOD_ADV_PARAMS_V2 (0x0086 | HCI_GRP_BLE_CMDS) +#endif // #if (BT_BLE_FEAT_PAWR_EN == TRUE) + +#if (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE) +#define HCI_BLE_CS_READ_LOCAL_SUPP_CAPS (0x0089 | HCI_GRP_BLE_CMDS) +#define HCI_BLE_CS_READ_REMOTE_SUPP_CAPS (0x008A | HCI_GRP_BLE_CMDS) +#define HCI_BLE_CS_WRITE_CACHED_REMOTE_SUPP_CAPS (0x008B | HCI_GRP_BLE_CMDS) +#define HCI_BLE_CS_SECURITY_ENABLE (0x008C | HCI_GRP_BLE_CMDS) +#define HCI_BLE_CS_SET_DEFAULT_SETTINGS (0x008D | HCI_GRP_BLE_CMDS) +#define HCI_BLE_CS_READ_REMOTE_FAE_TABLE (0x008E | HCI_GRP_BLE_CMDS) +#define HCI_BLE_CS_WRITE_CACHED_REMOTE_FAE_TABLE (0x008F | HCI_GRP_BLE_CMDS) +#define HCI_BLE_CS_CREATE_CONFIG (0x0090 | HCI_GRP_BLE_CMDS) +#define HCI_BLE_CS_REMOVE_CONFIG (0x0091 | HCI_GRP_BLE_CMDS) +#define HCI_BLE_CS_SET_CAHNNEL_CLASS (0x0092 | HCI_GRP_BLE_CMDS) +#define HCI_BLE_CS_SET_PROCEDURE_PARAMS (0x0093 | HCI_GRP_BLE_CMDS) +#define HCI_BLE_CS_SET_PROCEDURE_ENABLE (0x0094 | HCI_GRP_BLE_CMDS) +#endif // (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE) + // Vendor OGF define #define HCI_VENDOR_OGF 0x3F @@ -918,6 +945,24 @@ #define HCI_BLE_SUBRATE_CHANGE_EVT 0x23 #endif // #if (BLE_FEAT_CONN_SUBRATING == TRUE) +#define HCI_BLE_PERIOD_ADV_SYNC_ESTAB_EVT_V2 0x24 +#define HCI_BLE_PERIOD_ADV_REPORT_EVT_V2 0x25 + +#if (BT_BLE_FEAT_PAWR_EN == TRUE) +#define HCI_BLE_PA_SUBEVT_DATA_REQUEST_EVT 0x27 +#define HCI_BLE_PA_RESPONSE_REPORT_EVT 0x28 +#endif // #if (BT_BLE_FEAT_PAWR_EN == TRUE) + +#if (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE) +#define HCI_BLE_CS_READ_REMOTE_SUPP_CAPS_CMPL_EVT 0x2C +#define HCI_BLE_CS_READ_REMOTE_FAE_TAB_CMPL_EVT 0x2D +#define HCI_BLE_CS_SECURITY_ENABLE_CMPL_EVT 0x2E +#define HCI_BLE_CS_CONFIG_CMPL_EVT 0x2F +#define HCI_BLE_CS_PROC_ENABLE_CMPL_EVT 0x30 +#define HCI_BLE_CS_SUBEVENT_RESULT_EVT 0x31 +#define HCI_BLE_CS_SUBEVENT_RESULT_CONTINUE_EVT 0x32 +#endif // (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE) + /* Definitions for LE Channel Map */ #define HCI_BLE_CHNL_MAP_SIZE 5 diff --git a/components/bt/host/bluedroid/stack/include/stack/hcimsgs.h b/components/bt/host/bluedroid/stack/include/stack/hcimsgs.h index 4ee07b4d40..c4da454d0f 100644 --- a/components/bt/host/bluedroid/stack/include/stack/hcimsgs.h +++ b/components/bt/host/bluedroid/stack/include/stack/hcimsgs.h @@ -947,6 +947,10 @@ typedef struct { } tHCI_ExtConnParams; typedef struct { +#if (BT_BLE_FEAT_PAWR_EN == TRUE) + UINT8 adv_handle; + UINT8 subevent; +#endif // (BT_BLE_FEAT_PAWR_EN == TRUE) UINT8 filter_policy; UINT8 own_addr_type; UINT8 peer_addr_type; @@ -1013,7 +1017,7 @@ UINT8 btsnd_hcic_ble_clear_adv_set(void); UINT8 btsnd_hcic_ble_set_periodic_adv_params(UINT8 adv_handle, UINT16 interval_min, UINT16 interval_max, - UINT8 propertics); + UINT16 propertics); UINT8 btsnd_hcic_ble_set_periodic_adv_data(UINT8 adv_handle, UINT8 operation, @@ -1032,6 +1036,10 @@ UINT8 btsnd_hcic_ble_ext_scan_enable(UINT8 enable, UINT8 filter_dups, BOOLEAN btsnd_hcic_ble_create_ext_conn(tHCI_CreatExtConn *p_conn); +#if (BT_BLE_FEAT_PAWR_EN == TRUE) +BOOLEAN btsnd_hcic_ble_create_ext_conn_v2(tHCI_CreatExtConn *p_conn); +#endif // (BT_BLE_FEAT_PAWR_EN == TRUE) + BOOLEAN btsnd_hcic_ble_periodic_adv_create_sync(UINT8 filter_policy, UINT8 adv_sid, UINT8 adv_addr_type, BD_ADDR adv_addr, UINT16 sync_timeout, UINT8 sync_cte_type); @@ -1243,4 +1251,82 @@ UINT8 btsnd_hcic_ble_subrate_request(UINT16 conn_handle, UINT16 subrate_min, UIN UINT8 btsnd_hcic_ble_set_host_feature(uint16_t bit_num, uint8_t bit_val); #endif // #if (BLE_50_FEATURE_SUPPORT == TRUE) +#if (BT_BLE_FEAT_PAWR_EN == TRUE) +typedef struct { + uint8_t subevent; + uint8_t response_slot_start; + uint8_t response_slot_count; + uint8_t subevent_data_len; + uint8_t data[251]; +} ble_subevent_params; + +#define HCIC_PARAM_SIZE_SET_PA_SUBEVT_DATA_PARAMS_LEN 2 +#define HCIC_PARAM_SIZE_SET_PA_RESPONSE_DATA_PARAMS_LEN 8 +#define HCIC_PARAM_SIZE_SET_PA_SYNC_SUBEVT_PARAMS_LEN 5 + +#define HCIC_PARAM_SIZE_SET_PERIODIC_ADV_PARAMS_V2 12 +UINT8 btsnd_hcic_ble_set_periodic_adv_params_v2(UINT8 adv_handle, UINT16 interval_min, UINT16 interval_max, + UINT16 propertics, UINT8 num_subevents, UINT8 subevent_interval, + UINT8 rsp_slot_delay, UINT8 rsp_slot_spacing, UINT8 num_rsp_slots); +UINT8 btsnd_hcic_ble_set_periodic_adv_subevt_data(UINT8 adv_handle, UINT8 num_subevents_with_data, ble_subevent_params *subevent_params); +UINT8 btsnd_hcic_ble_set_periodic_adv_rsp_data(UINT16 sync_handle, UINT16 req_evt, UINT8 req_subevt, UINT8 rsp_subevt, UINT8 rsp_slot, UINT8 rsp_data_len, UINT8 *rsp_data); +UINT8 btsnd_hcic_ble_set_periodic_sync_subevt(UINT16 sync_handle, UINT16 periodic_adv_properties, UINT8 num_subevents_to_sync, UINT8 *subevt); +#endif // #if (BT_BLE_FEAT_PAWR_EN == TRUE) + +#if (BT_BLE_FEAT_ADV_CODING_SELECTION == TRUE) +UINT8 btsnd_hcic_ble_set_ext_adv_params_v2(UINT8 adv_handle, UINT16 properties, UINT32 interval_min, + UINT32 interval_max, UINT8 channel_map, UINT8 own_addr_type, + UINT8 peer_addr_type, BD_ADDR peer_addr, + UINT8 adv_filter_policy, INT8 adv_tx_power, + UINT8 primary_adv_phy, UINT8 secondary_adv_max_skip, + UINT8 secondary_adv_phy, + UINT8 adv_sid, UINT8 scan_req_ntf_enable, + UINT8 primary_adv_phy_options, UINT8 secondary_adv_phy_options); +#endif // (BT_BLE_FEAT_ADV_CODING_SELECTION == TRUE) + +#if (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE) +#define HCIC_PARAM_SIZE_READ_LOCAL_SUPP_CAPS_PARAMS_LEN 0 +#define HCIC_PARAM_SIZE_READ_REMOTE_SUPP_CAPS_PARAMS_LEN 2 +#define HCIC_PARAM_SIZE_WRITE_CACHE_REMOTE_SUPP_CAPS_PARAMS_LEN 30 +#define HCIC_PARAM_SIZE_SECURITY_ENABLE_PARAMS_LEN 2 +#define HCIC_PARAM_SIZE_SET_DEFAULT_SETTINGS_PARAMS_LEN 5 +#define HCIC_PARAM_SIZE_READ_REMOTE_FAE_TAB_PARAMS_LEN 2 +#define HCIC_PARAM_SIZE_WRITE_CACHED_REMOTE_FAE_TAB_PARAMS_LEN 74 +#define HCIC_PARAM_SIZE_CREATE_CONFIG_PARAMS_LEN 28 +#define HCIC_PARAM_SIZE_REMOVE_CONFIG_PARAMS_LEN 3 +#define HCIC_PARAM_SIZE_SET_CHANNEL_CLASS_PARAMS_LEN 10 +#define HCIC_PARAM_SIZE_SET_PROCEDURE_PARAMS_LEN 21 +#define HCIC_PARAM_SIZE_SET_PROCEDURE_ENABLE_PARAMS_LEN 4 + +UINT8 btsnd_hcic_ble_cs_read_local_supported_caps(void); +UINT8 btsnd_hcic_ble_cs_read_remote_supported_capabilities(UINT16 conn_handle); +UINT8 btsnd_hcic_ble_cs_write_cached_remote_supported_capabilities(UINT16 conn_handle, UINT8 num_config_supported, UINT16 max_consecutive_proc_supported, + UINT8 num_ant_supported, UINT8 max_ant_paths_supported, UINT8 roles_supported, + UINT8 modes_supported, UINT8 rtt_capability, UINT8 rtt_aa_only_n, + UINT8 rtt_sounding_n, UINT8 rtt_random_payload_n, UINT16 NADM_sounding_capability, + UINT16 NADM_random_capability, UINT8 cs_sync_phys_supported, UINT16 subfeatures_supported, + UINT16 T_IP1_times_supported, UINT16 T_IP2_times_supported, UINT16 T_FCS_times_supported, + UINT16 T_PM_times_supported, UINT8 T_SW_times_supported, UINT8 TX_SNR_capability); + +UINT8 btsnd_hcic_ble_cs_security_enable(UINT16 conn_handle); +UINT8 btsnd_hcic_ble_cs_set_default_settings(UINT16 conn_handle, UINT8 role_enable, UINT8 cs_sync_ant_selection, INT8 max_tx_power); +UINT8 btsnd_hcic_ble_cs_read_remote_fae_table(UINT16 conn_handle); +UINT8 btsnd_hcic_ble_cs_write_cached_remote_fae_table(UINT16 conn_handle, UINT8 *remote_fae_table); +UINT8 btsnd_hcic_ble_cs_create_config(UINT16 conn_handle, UINT8 config_id, UINT8 create_context, + UINT8 main_mode_type, UINT8 sub_mode_type, UINT8 min_main_mode_steps, + UINT8 max_main_mode_steps, UINT8 main_mode_repetition, UINT8 mode_0_steps, + UINT8 role, UINT8 rtt_type, UINT8 cs_sync_phy, UINT8 *channel_map, + UINT8 channel_map_repetition, UINT8 channel_selection_type, UINT8 ch3c_shape, + UINT8 ch3c_jump,UINT8 reserved); +UINT8 btsnd_hcic_ble_cs_remove_config(UINT16 conn_handle, UINT8 config_id); +UINT8 btsnd_hcic_ble_cs_set_channel_classification(UINT8 *channel_class); +UINT8 btsnd_hcic_ble_cs_set_procedure_params(UINT16 conn_handle, UINT8 config_id, UINT16 max_procedure_len, + UINT16 min_procedure_interval, UINT16 max_procedure_interval, + UINT16 max_procedure_count, UINT32 min_subevent_len, + UINT32 max_subevent_len, UINT8 tone_ant_config_selection, + UINT8 phy, UINT8 tx_power_delta, UINT8 preferred_peer_antenna, + UINT8 SNR_control_initiator, UINT8 SNR_control_reflector); +UINT8 btsnd_hcic_ble_cs_procedure_enable(UINT16 conn_handle, UINT8 config_id, UINT8 enable); +#endif // (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE) + #endif diff --git a/components/bt/host/bluedroid/stack/include/stack/l2c_api.h b/components/bt/host/bluedroid/stack/include/stack/l2c_api.h index b985b641e8..45538ff534 100644 --- a/components/bt/host/bluedroid/stack/include/stack/l2c_api.h +++ b/components/bt/host/bluedroid/stack/include/stack/l2c_api.h @@ -121,7 +121,7 @@ typedef UINT8 tL2CAP_CHNL_DATA_RATE; #define L2CAP_FCR_CHAN_OPT_ALL_MASK (L2CAP_FCR_CHAN_OPT_BASIC | L2CAP_FCR_CHAN_OPT_ERTM | L2CAP_FCR_CHAN_OPT_STREAM) /* Validity check for PSM. PSM values must be odd. Also, all PSM values must -** be assigned such that the least significant bit of the most sigificant +** be assigned such that the least significant bit of the most significant ** octet equals zero. */ #define L2C_INVALID_PSM(psm) (((psm) & 0x0101) != 0x0001) @@ -938,7 +938,7 @@ typedef struct { ** ** Parameters: tL2CAP_UCD_CB_INFO ** -** Return value: TRUE if successs +** Return value: TRUE if success ** *******************************************************************************/ extern BOOLEAN L2CA_UcdRegister ( UINT16 psm, tL2CAP_UCD_CB_INFO *p_cb_info ); @@ -951,7 +951,7 @@ extern BOOLEAN L2CA_UcdRegister ( UINT16 psm, tL2CAP_UCD_CB_INFO *p_cb_info ); ** ** Parameters: PSM ** -** Return value: TRUE if successs +** Return value: TRUE if success ** *******************************************************************************/ extern BOOLEAN L2CA_UcdDeregister ( UINT16 psm ); @@ -968,7 +968,7 @@ extern BOOLEAN L2CA_UcdDeregister ( UINT16 psm ); ** L2CAP_UCD_INFO_TYPE_MTU ** ** -** Return value: TRUE if successs +** Return value: TRUE if success ** *******************************************************************************/ extern BOOLEAN L2CA_UcdDiscover ( UINT16 psm, BD_ADDR rem_bda, UINT8 info_type ); @@ -1001,7 +1001,7 @@ extern UINT16 L2CA_UcdDataWrite (UINT16 psm, BD_ADDR rem_bda, BT_HDR *p_buf, UIN ** Parameters: BD Addr ** Timeout in second ** -** Return value: TRUE if successs +** Return value: TRUE if success ** *******************************************************************************/ extern BOOLEAN L2CA_UcdSetIdleTimeout ( BD_ADDR rem_bda, UINT16 timeout ); @@ -1089,7 +1089,8 @@ extern BOOLEAN L2CA_RegisterFixedChannel (UINT16 fixed_cid, tL2CAP_FIXED_CHNL_R ** Return value: TRUE if connection started ** *******************************************************************************/ -extern BOOLEAN L2CA_ConnectFixedChnl (UINT16 fixed_cid, BD_ADDR bd_addr, tBLE_ADDR_TYPE bd_addr_type, BOOLEAN is_aux); +extern BOOLEAN L2CA_ConnectFixedChnl (UINT16 fixed_cid, BD_ADDR bd_addr, tBLE_ADDR_TYPE bd_addr_type, BOOLEAN is_aux, + BOOLEAN is_pawr_synced, UINT8 adv_handle, UINT8 subevent); /******************************************************************************* ** diff --git a/components/bt/host/bluedroid/stack/l2cap/include/l2c_int.h b/components/bt/host/bluedroid/stack/l2cap/include/l2c_int.h index 88eac86b2f..d17f82f4cc 100644 --- a/components/bt/host/bluedroid/stack/l2cap/include/l2c_int.h +++ b/components/bt/host/bluedroid/stack/l2cap/include/l2c_int.h @@ -379,6 +379,11 @@ typedef struct t_l2c_linkcb { BOOLEAN in_use; /* TRUE when in use, FALSE when not */ tL2C_LINK_STATE link_state; BOOLEAN is_aux; /* This variable used for BLE 5.0 or higher version when do auxiliary connection */ +#if (BT_BLE_FEAT_PAWR_EN == TRUE) + BOOLEAN is_pawr_synced; + UINT8 adv_handle; + UINT8 subevent; +#endif // (BT_BLE_FEAT_PAWR_EN == TRUE) TIMER_LIST_ENT timer_entry; /* Timer list entry for timeout evt */ UINT16 handle; /* The handle used with LM */ diff --git a/components/bt/host/bluedroid/stack/l2cap/l2c_api.c b/components/bt/host/bluedroid/stack/l2cap/l2c_api.c index fa01790d5f..8030df8078 100644 --- a/components/bt/host/bluedroid/stack/l2cap/l2c_api.c +++ b/components/bt/host/bluedroid/stack/l2cap/l2c_api.c @@ -215,7 +215,7 @@ UINT16 L2CA_ConnectReq (UINT16 psm, BD_ADDR p_bd_addr) ** ** Parameters: PSM: L2CAP PSM for the connection ** BD address of the peer -** Enhaced retransmission mode configurations +** Enhanced retransmission mode configurations ** Returns the CID of the connection, or 0 if it failed to start ** @@ -760,7 +760,7 @@ bool L2CA_GetIdentifiers(uint16_t lcid, uint16_t *rcid, uint16_t *handle) ** ** NOTE This timeout takes effect after at least 1 channel has been ** established and removed. L2CAP maintains its own timer from -** whan a connection is established till the first channel is +** when a connection is established till the first channel is ** set up. *******************************************************************************/ BOOLEAN L2CA_SetIdleTimeout (UINT16 cid, UINT16 timeout, BOOLEAN is_global) @@ -1649,7 +1649,8 @@ BOOLEAN L2CA_RegisterFixedChannel (UINT16 fixed_cid, tL2CAP_FIXED_CHNL_REG *p_f ** Return value: TRUE if connection started ** *******************************************************************************/ -BOOLEAN L2CA_ConnectFixedChnl (UINT16 fixed_cid, BD_ADDR rem_bda, tBLE_ADDR_TYPE bd_addr_type, BOOLEAN is_aux) +BOOLEAN L2CA_ConnectFixedChnl (UINT16 fixed_cid, BD_ADDR rem_bda, tBLE_ADDR_TYPE bd_addr_type, BOOLEAN is_aux, + BOOLEAN is_pawr_synced, UINT8 adv_handle, UINT8 subevent) { tL2C_LCB *p_lcb; tBT_TRANSPORT transport = BT_TRANSPORT_BR_EDR; @@ -1738,6 +1739,11 @@ BOOLEAN L2CA_ConnectFixedChnl (UINT16 fixed_cid, BD_ADDR rem_bda, tBLE_ADDR_TYPE #if (BLE_INCLUDED == TRUE) p_lcb->is_aux = is_aux; p_lcb->open_addr_type = bd_addr_type; +#if (BT_BLE_FEAT_PAWR_EN == TRUE) + p_lcb->is_pawr_synced = is_pawr_synced; + p_lcb->adv_handle = adv_handle; + p_lcb->subevent = subevent; +#endif // (BT_BLE_FEAT_PAWR_EN == TRUE) #endif if (!l2cu_create_conn(p_lcb, transport)) { L2CAP_TRACE_WARNING ("%s() - create_conn failed", __func__); diff --git a/components/bt/host/bluedroid/stack/l2cap/l2c_ble.c b/components/bt/host/bluedroid/stack/l2cap/l2c_ble.c index 3ce25ab977..88d18b08a2 100644 --- a/components/bt/host/bluedroid/stack/l2cap/l2c_ble.c +++ b/components/bt/host/bluedroid/stack/l2cap/l2c_ble.c @@ -1020,6 +1020,10 @@ BOOLEAN l2cble_init_direct_conn (tL2C_LCB *p_lcb) } tHCI_CreatExtConn aux_conn = {0}; +#if (BT_BLE_FEAT_PAWR_EN == TRUE) + aux_conn.adv_handle = p_lcb->adv_handle; + aux_conn.subevent = p_lcb->subevent; +#endif // (BT_BLE_FEAT_PAWR_EN == TRUE) aux_conn.filter_policy = FALSE; aux_conn.own_addr_type = own_addr_type; aux_conn.peer_addr_type = peer_addr_type; @@ -1041,9 +1045,19 @@ BOOLEAN l2cble_init_direct_conn (tL2C_LCB *p_lcb) memcpy (l2cb.ble_connecting_bda, p_lcb->remote_bd_addr, BD_ADDR_LEN); btu_start_timer (&p_lcb->timer_entry, BTU_TTYPE_L2CAP_LINK, link_timeout); btm_ble_set_conn_st (BLE_DIR_CONN); - if(!btsnd_hcic_ble_create_ext_conn(&aux_conn)) { - l2cu_release_lcb (p_lcb); - L2CAP_TRACE_ERROR("initiate Aux connection failed, no resources"); +#if (BT_BLE_FEAT_PAWR_EN == TRUE) + if (p_lcb->is_pawr_synced) { + if(!btsnd_hcic_ble_create_ext_conn_v2(&aux_conn)) { + l2cu_release_lcb (p_lcb); + L2CAP_TRACE_ERROR("initiate pawr sync connection failed, no resources"); + } + } else +#endif // (BT_BLE_FEAT_PAWR_EN == TRUE) + { + if(!btsnd_hcic_ble_create_ext_conn(&aux_conn)) { + l2cu_release_lcb (p_lcb); + L2CAP_TRACE_ERROR("initiate Aux connection failed, no resources"); + } } #else L2CAP_TRACE_ERROR("BLE 5.0 not support!\n"); diff --git a/components/bt/host/bluedroid/stack/smp/smp_api.c b/components/bt/host/bluedroid/stack/smp/smp_api.c index 78e295f4f1..b99c94abd8 100644 --- a/components/bt/host/bluedroid/stack/smp/smp_api.c +++ b/components/bt/host/bluedroid/stack/smp/smp_api.c @@ -161,7 +161,7 @@ tSMP_STATUS SMP_Pair (BD_ADDR bd_addr) memcpy (p_cb->pairing_bda, bd_addr, BD_ADDR_LEN); - if (!L2CA_ConnectFixedChnl (L2CAP_SMP_CID, bd_addr, BLE_ADDR_UNKNOWN_TYPE, FALSE)) { + if (!L2CA_ConnectFixedChnl (L2CAP_SMP_CID, bd_addr, BLE_ADDR_UNKNOWN_TYPE, FALSE, FALSE, 0xFF, 0xFF)) { SMP_TRACE_ERROR("%s: L2C connect fixed channel failed.\n", __FUNCTION__); smp_sm_event(p_cb, SMP_AUTH_CMPL_EVT, &status); return status; @@ -205,7 +205,7 @@ tSMP_STATUS SMP_BR_PairWith (BD_ADDR bd_addr) memcpy (p_cb->pairing_bda, bd_addr, BD_ADDR_LEN); - if (!L2CA_ConnectFixedChnl (L2CAP_SMP_BR_CID, bd_addr, BLE_ADDR_UNKNOWN_TYPE, FALSE)) { + if (!L2CA_ConnectFixedChnl (L2CAP_SMP_BR_CID, bd_addr, BLE_ADDR_UNKNOWN_TYPE, FALSE, FALSE, 0xFF, 0xFF)) { SMP_TRACE_ERROR("%s: L2C connect fixed channel failed.", __FUNCTION__); smp_br_state_machine_event(p_cb, SMP_BR_AUTH_CMPL_EVT, &status); return status; @@ -524,10 +524,10 @@ void SMP_SecureConnectionOobDataReply(UINT8 *p_data) ** Description This function is called to encrypt the data with the specified ** key ** -** Parameters: key - Pointer to key key[0] conatins the MSB +** Parameters: key - Pointer to key key[0] contains the MSB ** key_len - key length ** plain_text - Pointer to data to be encrypted -** plain_text[0] conatins the MSB +** plain_text[0] contains the MSB ** pt_len - plain text length ** p_out - output of the encrypted texts **