From c8e79a926620e48830778714cfe4b2ea2453fcaf Mon Sep 17 00:00:00 2001 From: jacqueline Date: Fri, 25 Jul 2025 13:33:07 +1000 Subject: Update forked idf components --- lib/bt/host/bluedroid/stack/btu/btu_hcif.c | 766 +++++++++++++++++++++++++++-- lib/bt/host/bluedroid/stack/btu/btu_init.c | 11 - lib/bt/host/bluedroid/stack/btu/btu_task.c | 4 +- 3 files changed, 737 insertions(+), 44 deletions(-) (limited to 'lib/bt/host/bluedroid/stack/btu') diff --git a/lib/bt/host/bluedroid/stack/btu/btu_hcif.c b/lib/bt/host/bluedroid/stack/btu/btu_hcif.c index 30e76125..eb2995b9 100644 --- a/lib/bt/host/bluedroid/stack/btu/btu_hcif.c +++ b/lib/bt/host/bluedroid/stack/btu/btu_hcif.c @@ -55,6 +55,7 @@ extern void btm_ble_test_command_complete(UINT8 *p); /********************************************************************************/ /* L O C A L F U N C T I O N P R O T O T Y P E S */ /********************************************************************************/ +#if (CLASSIC_BT_INCLUDED == TRUE) static void btu_hcif_inquiry_comp_evt (UINT8 *p); static void btu_hcif_inquiry_result_evt (UINT8 *p); static void btu_hcif_inquiry_rssi_result_evt (UINT8 *p); @@ -62,30 +63,46 @@ static void btu_hcif_extended_inquiry_result_evt (UINT8 *p); static void btu_hcif_connection_comp_evt (UINT8 *p); static void btu_hcif_connection_request_evt (UINT8 *p); +#endif // #if (CLASSIC_BT_INCLUDED == TRUE) static void btu_hcif_disconnection_comp_evt (UINT8 *p); #if (SMP_INCLUDED == TRUE) static void btu_hcif_authentication_comp_evt (UINT8 *p); #endif ///SMP_INCLUDED == TRUE +#if (CLASSIC_BT_INCLUDED == TRUE) static void btu_hcif_rmt_name_request_comp_evt (UINT8 *p, UINT16 evt_len); +#endif // #if (CLASSIC_BT_INCLUDED == TRUE) #if (SMP_INCLUDED == TRUE) static void btu_hcif_encryption_change_evt (UINT8 *p); #endif ///SMP_INCLUDED == TRUE +#if (CLASSIC_BT_INCLUDED == TRUE) static void btu_hcif_read_rmt_features_comp_evt (UINT8 *p); static void btu_hcif_read_rmt_ext_features_comp_evt (UINT8 *p); +#endif // #if (CLASSIC_BT_INCLUDED == TRUE) static void btu_hcif_read_rmt_version_comp_evt (UINT8 *p); +#if (CLASSIC_BT_INCLUDED == TRUE) static void btu_hcif_qos_setup_comp_evt (UINT8 *p); +#endif // #if (CLASSIC_BT_INCLUDED == TRUE) static void btu_hcif_command_complete_evt (BT_HDR *response, void *context); static void btu_hcif_command_status_evt (uint8_t status, BT_HDR *command, void *context); static void btu_hcif_hardware_error_evt (UINT8 *p); +#if (CLASSIC_BT_INCLUDED == TRUE) static void btu_hcif_flush_occured_evt (void); static void btu_hcif_role_change_evt (UINT8 *p); +#endif // #if (CLASSIC_BT_INCLUDED == TRUE) static void btu_hcif_num_compl_data_pkts_evt (UINT8 *p); + +#if (CLASSIC_BT_INCLUDED == TRUE) static void btu_hcif_mode_change_evt (UINT8 *p); +#endif // #if (CLASSIC_BT_INCLUDED == TRUE) + #if (SMP_INCLUDED == TRUE) +#if (CLASSIC_BT_INCLUDED == TRUE) static void btu_hcif_pin_code_request_evt (UINT8 *p); static void btu_hcif_link_key_request_evt (UINT8 *p); static void btu_hcif_link_key_notification_evt (UINT8 *p); +#endif // #if (CLASSIC_BT_INCLUDED == TRUE) #endif ///SMP_INCLUDED == TRUE +#if (CLASSIC_BT_INCLUDED == TRUE) static void btu_hcif_loopback_command_evt (void); static void btu_hcif_data_buf_overflow_evt (void); static void btu_hcif_max_slots_changed_evt (void); @@ -98,6 +115,8 @@ static void btu_hcif_esco_connection_comp_evt(UINT8 *p); static void btu_hcif_esco_connection_chg_evt(UINT8 *p); static void btu_hcif_host_support_evt (UINT8 *p); +#endif // #if (CLASSIC_BT_INCLUDED == TRUE) + /* Simple Pairing Events */ #if (CLASSIC_BT_INCLUDED == TRUE) static void btu_hcif_io_cap_request_evt (UINT8 *p); @@ -111,12 +130,14 @@ static void btu_hcif_keypress_notif_evt (UINT8 *p); #if BTM_OOB_INCLUDED == TRUE && SMP_INCLUDED == TRUE static void btu_hcif_rem_oob_request_evt (UINT8 *p); #endif +#if (CLASSIC_BT_INCLUDED == TRUE) static void btu_hcif_link_supv_to_changed_evt (UINT8 *p); #if L2CAP_NON_FLUSHABLE_PB_INCLUDED == TRUE static void btu_hcif_enhanced_flush_complete_evt (void); #endif static void btu_hcif_ssr_evt (UINT8 *p, UINT16 evt_len); +#endif // #if (CLASSIC_BT_INCLUDED == TRUE) #if BLE_INCLUDED == TRUE static void btu_ble_ll_conn_complete_evt (UINT8 *p, UINT16 evt_len); @@ -136,29 +157,91 @@ static void btu_ble_proc_enhanced_conn_cmpl (UINT8 *p, UINT16 evt_len); //#endif #if (BLE_50_FEATURE_SUPPORT == TRUE) static void btu_ble_phy_update_complete_evt(UINT8 *p); +#if (BLE_50_EXTEND_SCAN_EN == TRUE) 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_lost_evt(UINT8 *p); +#endif // #if (BLE_50_EXTEND_SYNC_EN == TRUE) +#if (BLE_50_EXTEND_SCAN_EN == TRUE) static void btu_ble_scan_timeout_evt(UINT8 *p); +#endif // #if (BLE_50_EXTEND_SCAN_EN == TRUE) +#if (BLE_50_EXTEND_ADV_EN == TRUE) static void btu_ble_adv_set_terminate_evt(UINT8 *p); static void btu_ble_scan_req_received_evt(UINT8 *p); +#endif // #if (BLE_50_EXTEND_ADV_EN == TRUE) +static void btu_ble_channel_select_alg_evt(UINT8 *p); #endif // #if (BLE_50_FEATURE_SUPPORT == TRUE) + #if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE) static void btu_ble_periodic_adv_sync_trans_recv(UINT8 *p); #endif // #if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE) +#if (BLE_FEAT_ISO_EN == TRUE) + +#if (BLE_FEAT_ISO_BIG_BROCASTER_EN == TRUE) +void btu_ble_create_big_cmd_status(UINT8 status); +static void btu_ble_big_create_complete_evt(UINT8 *p); +void btu_ble_big_terminate_cmd_status(UINT8 status); +static void btu_ble_big_terminate_complete_evt(UINT8 *p); +#endif // #if (BLE_FEAT_ISO_BIG_BROCASTER_EN == TRUE) + +#if (BLE_FEAT_ISO_BIG_SYNCER_EN == TRUE) +static void btu_ble_create_big_sync_cmd_status(UINT8 status); +static void btu_ble_big_sync_establish_evt(UINT8 *p); +static void btu_ble_big_sync_lost_evt(UINT8 *p); +static void btu_ble_biginfo_adv_report_evt(UINT8 *p); +#endif // #if (BLE_FEAT_ISO_BIG_SYNCER_EN == TRUE) +#if (BLE_FEAT_ISO_CIG_CENTRAL_EN == TRUE) +static void btu_ble_create_cis_cmd_status(UINT8 status); +#endif // #if (BLE_FEAT_ISO_CIG_CENTRAL_EN == TRUE) +#if (BLE_FEAT_ISO_CIG_PERIPHERAL_EN == TRUE) +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_disconnected(UINT16 handle, UINT8 reason); +#endif // #if (BLE_FEAT_ISO_CIG_EN == TRUE) + +#endif // #if (BLE_FEAT_ISO_EN == TRUE) + + +#if (BLE_FEAT_CTE_EN == TRUE) +#if (BLE_FEAT_CTE_CONNECTIONLESS_EN == TRUE) +static void btu_ble_cte_connless_iq_report_evt(UINT8 *p); +#endif // #if (BLE_FEAT_CTE_CONNECTIONLESS_EN == TRUE) +#if (BLE_FEAT_CTE_CONNECTION_EN == TRUE) +static void btu_ble_cte_conn_iq_report_evt(UINT8 *p); +static void btu_ble_cte_req_failed_evt(UINT8 *p); +#endif // #if (BLE_FEAT_CTE_CONNECTION_EN == TRUE) +#endif // #if (BLE_FEAT_CTE_EN == TRUE) + +#if (BLE_FEAT_POWER_CONTROL_EN == TRUE) +static void btu_ble_path_loss_threshold_evt(UINT8 *p); +static void btu_ble_transmit_power_report_evt(UINT8 *p); +#endif // #if (BLE_FEAT_POWER_CONTROL_EN == TRUE) + +#if (BLE_FEAT_CONN_SUBRATING == TRUE) +static void btu_ble_subrate_change_evt(UINT8 *p); +#endif // #if (BLE_FEAT_CONN_SUBRATING == TRUE) + +#if (BLE_42_ADV_EN == TRUE) extern osi_sem_t adv_enable_sem; extern osi_sem_t adv_data_sem; extern osi_sem_t adv_param_sem; -extern osi_sem_t scan_enable_sem; -extern osi_sem_t scan_param_sem; extern uint8_t adv_enable_status; extern uint8_t adv_data_status; extern uint8_t adv_param_status; +#endif // #if (BLE_42_ADV_EN == TRUE) +#if (BLE_42_SCAN_EN == TRUE) +extern osi_sem_t scan_enable_sem; +extern osi_sem_t scan_param_sem; extern uint8_t scan_enable_status; extern uint8_t scan_param_status; - +#endif // #if (BLE_42_SCAN_EN == TRUE) #endif /******************************************************************************* @@ -182,6 +265,7 @@ void btu_hcif_process_event (UNUSED_ATTR UINT8 controller_id, BT_HDR *p_msg) STREAM_TO_UINT8 (hci_evt_len, p); switch (hci_evt_code) { +#if (CLASSIC_BT_INCLUDED == TRUE) case HCI_INQUIRY_COMP_EVT: btu_hcif_inquiry_comp_evt (p); break; @@ -200,6 +284,7 @@ void btu_hcif_process_event (UNUSED_ATTR UINT8 controller_id, BT_HDR *p_msg) case HCI_CONNECTION_REQUEST_EVT: btu_hcif_connection_request_evt (p); break; +#endif // #if (CLASSIC_BT_INCLUDED == TRUE) case HCI_DISCONNECTION_COMP_EVT: btu_hcif_disconnection_comp_evt (p); break; @@ -208,9 +293,11 @@ void btu_hcif_process_event (UNUSED_ATTR UINT8 controller_id, BT_HDR *p_msg) btu_hcif_authentication_comp_evt (p); #endif ///SMP_INCLUDED == TRUE break; +#if (CLASSIC_BT_INCLUDED == TRUE) case HCI_RMT_NAME_REQUEST_COMP_EVT: btu_hcif_rmt_name_request_comp_evt (p, hci_evt_len); break; +#endif // #if (CLASSIC_BT_INCLUDED == TRUE) case HCI_ENCRYPTION_CHANGE_EVT: #if (SMP_INCLUDED == TRUE) btu_hcif_encryption_change_evt (p); @@ -223,18 +310,22 @@ void btu_hcif_process_event (UNUSED_ATTR UINT8 controller_id, BT_HDR *p_msg) #endif ///SMP_INCLUDED == TRUE break; #endif +#if (CLASSIC_BT_INCLUDED == TRUE) case HCI_READ_RMT_FEATURES_COMP_EVT: btu_hcif_read_rmt_features_comp_evt (p); break; case HCI_READ_RMT_EXT_FEATURES_COMP_EVT: btu_hcif_read_rmt_ext_features_comp_evt (p); break; +#endif // #if (CLASSIC_BT_INCLUDED == TRUE) case HCI_READ_RMT_VERSION_COMP_EVT: btu_hcif_read_rmt_version_comp_evt (p); break; +#if (CLASSIC_BT_INCLUDED == TRUE) case HCI_QOS_SETUP_COMP_EVT: btu_hcif_qos_setup_comp_evt (p); break; +#endif // #if (CLASSIC_BT_INCLUDED == TRUE) case HCI_COMMAND_COMPLETE_EVT: //HCI_TRACE_ERROR("%s should not have received a command complete event. " // "Someone didn't go through the hci transmit_command function.", __func__); @@ -246,19 +337,24 @@ void btu_hcif_process_event (UNUSED_ATTR UINT8 controller_id, BT_HDR *p_msg) case HCI_HARDWARE_ERROR_EVT: btu_hcif_hardware_error_evt (p); break; +#if (CLASSIC_BT_INCLUDED == TRUE) case HCI_FLUSH_OCCURED_EVT: btu_hcif_flush_occured_evt (); break; case HCI_ROLE_CHANGE_EVT: btu_hcif_role_change_evt (p); break; +#endif // #if (CLASSIC_BT_INCLUDED == TRUE) case HCI_NUM_COMPL_DATA_PKTS_EVT: btu_hcif_num_compl_data_pkts_evt (p); break; + #if (CLASSIC_BT_INCLUDED == TRUE) case HCI_MODE_CHANGE_EVT: btu_hcif_mode_change_evt (p); break; +#endif // #if (CLASSIC_BT_INCLUDED == TRUE) #if (SMP_INCLUDED == TRUE) +#if (CLASSIC_BT_INCLUDED == TRUE) case HCI_PIN_CODE_REQUEST_EVT: btu_hcif_pin_code_request_evt (p); break; @@ -268,7 +364,9 @@ void btu_hcif_process_event (UNUSED_ATTR UINT8 controller_id, BT_HDR *p_msg) case HCI_LINK_KEY_NOTIFICATION_EVT: btu_hcif_link_key_notification_evt (p); break; +#endif // #if (CLASSIC_BT_INCLUDED == TRUE) #endif ///SMP_INCLUDED == TRUE +#if (CLASSIC_BT_INCLUDED == TRUE) case HCI_LOOPBACK_COMMAND_EVT: btu_hcif_loopback_command_evt (); break; @@ -305,7 +403,6 @@ void btu_hcif_process_event (UNUSED_ATTR UINT8 controller_id, BT_HDR *p_msg) case HCI_RMT_HOST_SUP_FEAT_NOTIFY_EVT: btu_hcif_host_support_evt (p); break; -#if (CLASSIC_BT_INCLUDED == TRUE) case HCI_IO_CAPABILITY_REQUEST_EVT: btu_hcif_io_cap_request_evt (p); break; @@ -334,7 +431,6 @@ void btu_hcif_process_event (UNUSED_ATTR UINT8 controller_id, BT_HDR *p_msg) case HCI_KEYPRESS_NOTIFY_EVT: btu_hcif_keypress_notif_evt (p); break; -#endif /* (CLASSIC_BT_INCLUDED == TRUE) */ case HCI_LINK_SUPER_TOUT_CHANGED_EVT: btu_hcif_link_supv_to_changed_evt (p); break; @@ -343,6 +439,7 @@ void btu_hcif_process_event (UNUSED_ATTR UINT8 controller_id, BT_HDR *p_msg) btu_hcif_enhanced_flush_complete_evt (); break; #endif +#endif /* (CLASSIC_BT_INCLUDED == TRUE) */ #if (BLE_INCLUDED == TRUE) case HCI_BLE_EVENT: @@ -388,10 +485,13 @@ void btu_hcif_process_event (UNUSED_ATTR UINT8 controller_id, BT_HDR *p_msg) case HCI_BLE_PHY_UPDATE_COMPLETE_EVT: btu_ble_phy_update_complete_evt(p); break; +#if (BLE_50_EXTEND_SCAN_EN == TRUE) case HCI_BLE_EXT_ADV_REPORT_EVT: //HCI_TRACE_ERROR("%s, HCI_BLE_EXT_ADV_REPORT_EVT.", __func__); btu_ble_ext_adv_report_evt(p, hci_evt_len); break; +#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); break; @@ -401,16 +501,22 @@ void btu_hcif_process_event (UNUSED_ATTR UINT8 controller_id, BT_HDR *p_msg) case HCI_BLE_PERIOD_ADV_SYNC_LOST_EVT: btu_ble_periodic_adv_sync_lost_evt(p); break; +#endif // #if (BLE_50_EXTEND_SYNC_EN == TRUE) +#if (BLE_50_EXTEND_SCAN_EN == TRUE) case HCI_BLE_SCAN_TIMEOUT_EVT: btu_ble_scan_timeout_evt(p); break; +#endif // #if (BLE_50_EXTEND_SCAN_EN == TRUE) +#if (BLE_50_EXTEND_ADV_EN == TRUE) case HCI_BLE_ADV_SET_TERMINATED_EVT: btu_ble_adv_set_terminate_evt(p); break; case HCI_BLE_SCAN_REQ_RECEIVED_EVT: btu_ble_scan_req_received_evt(p); break; +#endif // #if (BLE_50_EXTEND_ADV_EN == TRUE) case HCI_BLE_CHANNEL_SELECT_ALG: + btu_ble_channel_select_alg_evt(p); break; #endif // #if (BLE_50_FEATURE_SUPPORT == TRUE) #if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE) @@ -418,6 +524,68 @@ void btu_hcif_process_event (UNUSED_ATTR UINT8 controller_id, BT_HDR *p_msg) btu_ble_periodic_adv_sync_trans_recv(p); break; #endif // #if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE) +#if (BLE_FEAT_ISO_EN == TRUE) +#if (BLE_FEAT_ISO_CIG_EN == TRUE) + case HCI_BLE_CIS_ESTABLISHED_V1_EVT: + case HCI_BLE_CIS_ESTABLISHED_V2_EVT: + btu_ble_cis_established_evt(p); + break; +#endif // #if (BLE_FEAT_ISO_CIG_EN == TRUE) +#if (BLE_FEAT_ISO_CIG_PERIPHERAL_EN == TRUE) + case HCI_BLE_CIS_REQUEST_EVT: + btu_ble_cis_request_evt(p); + break; +#endif // #if (BLE_FEAT_ISO_CIG_PERIPHERAL_EN == TRUE) +#if (BLE_FEAT_ISO_BIG_BROCASTER_EN == TRUE) + case HCI_BLE_BIG_CREATE_COMPLETE_EVT: + btu_ble_big_create_complete_evt(p); + break; + case HCI_BLE_BIG_TERMINATE_COMPLETE_EVT: + btu_ble_big_terminate_complete_evt(p); + break; +#endif // #if (BLE_FEAT_ISO_BIG_BROCASTER_EN == TRUE) +#if (BLE_FEAT_ISO_BIG_SYNCER_EN == TRUE) + case HCI_BLE_BIG_SYNC_ESTABLISHED_EVT: + btu_ble_big_sync_establish_evt(p); + break; + case HCI_BLE_BIG_SYNC_LOST_EVT: + btu_ble_big_sync_lost_evt(p); + break; + case HCI_BLE_BIGINFO_ADV_REPORT_EVT: + btu_ble_biginfo_adv_report_evt(p); + break; +#endif // #if (BLE_FEAT_ISO_BIG_SYNCER_EN == TRUE) +#endif // #if (BLE_FEAT_ISO_EN == TRUE) +#if (BLE_FEAT_CTE_EN == TRUE) +#if (BLE_FEAT_CTE_CONNECTIONLESS_EN == TRUE) + case HCI_BLE_CONNLESS_IQ_REPORT_EVT: + btu_ble_cte_connless_iq_report_evt(p); + break; +#endif // #if (BLE_FEAT_CTE_CONNECTIONLESS_EN == TRUE) + +#if (BLE_FEAT_CTE_CONNECTION_EN == TRUE) + case HCI_BLE_CONN_IQ_REPORT_EVT: + btu_ble_cte_conn_iq_report_evt(p); + break; + case HCI_BLE_CTE_REQUEST_FAILED_EVT: + btu_ble_cte_req_failed_evt(p); + break; +#endif // #if (BLE_FEAT_CTE_CONNECTION_EN == TRUE) + +#endif // #if (BLE_FEAT_CTE_EN == TRUE) +#if (BLE_FEAT_POWER_CONTROL_EN == TRUE) + case HCI_BLE_PATH_LOSS_THRESHOLD_EVT: + btu_ble_path_loss_threshold_evt(p); + break; + case HCI_BLE_TRANS_POWER_REPORTING_EVT: + btu_ble_transmit_power_report_evt(p); + break; +#endif // #if (BLE_FEAT_POWER_CONTROL_EN == TRUE) +#if (BLE_FEAT_CONN_SUBRATING == TRUE) + case HCI_BLE_SUBRATE_CHANGE_EVT: + btu_ble_subrate_change_evt(p); + break; +#endif // #if (BLE_FEAT_CONN_SUBRATING == TRUE) } break; #endif /* BLE_INCLUDED */ @@ -559,7 +727,7 @@ void btu_hcif_send_host_rdy_for_data(void) btsnd_hcic_host_num_xmitted_pkts (num_ents, handles, num_pkts); } } - +#if (CLASSIC_BT_INCLUDED == TRUE) /******************************************************************************* ** ** Function btu_hcif_inquiry_comp_evt @@ -687,7 +855,7 @@ static void btu_hcif_connection_request_evt (UINT8 *p) } #endif /* BTM_SCO_INCLUDED */ } - +#endif // #if (CLASSIC_BT_INCLUDED == TRUE) /******************************************************************************* ** @@ -702,6 +870,7 @@ static void btu_hcif_disconnection_comp_evt (UINT8 *p) { UINT16 handle; UINT8 reason; + BOOLEAN dev_find = FALSE; ++p; STREAM_TO_UINT16 (handle, p); @@ -709,9 +878,18 @@ static void btu_hcif_disconnection_comp_evt (UINT8 *p) handle = HCID_GET_HANDLE (handle); - btm_acl_disconnected(handle, reason); + dev_find = btm_acl_disconnected(handle, reason); + +#if (BLE_FEAT_ISO_CIG_EN == TRUE) + // Not find device. it is iso handle + if (!dev_find) { + btu_ble_cis_disconnected(handle, reason); + } +#endif // #if (BLE_FEAT_ISO_CIG_EN == TRUE) - HCI_TRACE_WARNING("hcif disc complete: hdl 0x%x, rsn 0x%x", handle, reason); + HCI_TRACE_WARNING("hcif disc complete: hdl 0x%x, rsn 0x%x dev_find %d", handle, reason, dev_find); + + UNUSED(dev_find); } /******************************************************************************* @@ -736,6 +914,7 @@ static void btu_hcif_authentication_comp_evt (UINT8 *p) } #endif ///SMP_INCLUDED == TRUE +#if (CLASSIC_BT_INCLUDED == TRUE) /******************************************************************************* ** ** Function btu_hcif_rmt_name_request_comp_evt @@ -760,7 +939,7 @@ static void btu_hcif_rmt_name_request_comp_evt (UINT8 *p, UINT16 evt_len) btm_sec_rmt_name_request_complete (bd_addr, p, status); #endif ///SMP_INCLUDED == TRUE } - +#endif // #if (CLASSIC_BT_INCLUDED == TRUE) /******************************************************************************* ** @@ -786,7 +965,7 @@ static void btu_hcif_encryption_change_evt (UINT8 *p) btm_sec_encrypt_change (handle, status, encr_enable); } #endif ///SMP_INCLUDED == TRUE - +#if (CLASSIC_BT_INCLUDED == TRUE) /******************************************************************************* ** ** Function btu_hcif_read_rmt_features_comp_evt @@ -825,6 +1004,7 @@ static void btu_hcif_read_rmt_ext_features_comp_evt (UINT8 *p) btm_read_remote_ext_features_failed(status, handle); } } +#endif // #if (CLASSIC_BT_INCLUDED == TRUE) /******************************************************************************* ** @@ -840,7 +1020,7 @@ static void btu_hcif_read_rmt_version_comp_evt (UINT8 *p) btm_read_remote_version_complete (p); } - +#if (CLASSIC_BT_INCLUDED == TRUE) /******************************************************************************* ** ** Function btu_hcif_qos_setup_comp_evt @@ -934,6 +1114,7 @@ static void btu_hcif_esco_connection_chg_evt (UINT8 *p) rx_pkt_len, tx_pkt_len); #endif } +#endif // #if (CLASSIC_BT_INCLUDED == TRUE) /******************************************************************************* ** @@ -949,6 +1130,7 @@ static void btu_hcif_hdl_command_complete (UINT16 opcode, UINT8 *p, UINT16 evt_l { uint8_t status; switch (opcode) { +#if (CLASSIC_BT_INCLUDED == TRUE) case HCI_INQUIRY_CANCEL: /* Tell inquiry processing that we are done */ btm_process_cancel_complete(HCI_SUCCESS, BTM_BR_INQUIRY_MASK); @@ -961,37 +1143,39 @@ static void btu_hcif_hdl_command_complete (UINT16 opcode, UINT8 *p, UINT16 evt_l btm_delete_stored_link_key_complete (p); break; - case HCI_READ_LOCAL_NAME: - btm_read_local_name_complete (p, evt_len); - break; - case HCI_GET_LINK_QUALITY: btm_read_link_quality_complete (p); break; - +#endif // #if (CLASSIC_BT_INCLUDED == TRUE) + case HCI_READ_LOCAL_NAME: + btm_read_local_name_complete (p, evt_len); + break; case HCI_READ_RSSI: btm_read_rssi_complete (p); break; - + case HCI_BLE_READ_CHNL_MAP: + btm_read_channel_map_complete (p); + break; case HCI_READ_TRANSMIT_POWER_LEVEL: +#if (BLE_HOST_READ_TX_POWER_EN == TRUE) btm_read_tx_power_complete(p, FALSE); +#endif // #if (BLE_HOST_READ_TX_POWER_EN == TRUE) break; - +#if (CLASSIC_BT_INCLUDED == TRUE) case HCI_CREATE_CONNECTION_CANCEL: btm_create_conn_cancel_complete(p); break; - +#endif // #if (CLASSIC_BT_INCLUDED == TRUE) case HCI_READ_LOCAL_OOB_DATA: #if BTM_OOB_INCLUDED == TRUE && SMP_INCLUDED == TRUE btm_read_local_oob_complete(p); #endif break; - +#if (CLASSIC_BT_INCLUDED == TRUE) case HCI_READ_INQ_TX_POWER_LEVEL: btm_read_linq_tx_power_complete (p); break; -#if (CLASSIC_BT_INCLUDED == TRUE) case HCI_SET_AFH_CHANNELS: btm_set_afh_channels_complete(p); break; @@ -1055,22 +1239,26 @@ static void btu_hcif_hdl_command_complete (UINT16 opcode, UINT8 *p, UINT16 evt_l break; case HCI_BLE_READ_ADV_CHNL_TX_POWER: +#if (BLE_HOST_READ_TX_POWER_EN == TRUE) btm_read_tx_power_complete(p, TRUE); +#endif // #if (BLE_HOST_READ_TX_POWER_EN == TRUE) break; - +#if (BLE_42_ADV_EN == TRUE) case HCI_BLE_WRITE_ADV_ENABLE: btm_ble_write_adv_enable_complete(p); break; - +#endif // #if (BLE_42_ADV_EN == TRUE) case HCI_BLE_CREATE_LL_CONN: btm_ble_create_ll_conn_complete(*p); break; case HCI_BLE_TRANSMITTER_TEST: case HCI_BLE_RECEIVER_TEST: +#if ((BLE_42_DTM_TEST_EN == TRUE) || (BLE_50_DTM_TEST_EN == TRUE)) case HCI_BLE_TEST_END: btm_ble_test_command_complete(p); break; +#endif // #if ((BLE_42_DTM_TEST_EN == TRUE) || (BLE_50_DTM_TEST_EN == TRUE)) case HCI_BLE_CREATE_CONN_CANCEL: btm_ble_create_conn_cancel_complete(p); break; @@ -1105,6 +1293,7 @@ static void btu_hcif_hdl_command_complete (UINT16 opcode, UINT8 *p, UINT16 evt_l break; #endif // #if (defined BLE_PRIVACY_SPT && BLE_PRIVACY_SPT == TRUE) #if (BLE_50_FEATURE_SUPPORT == TRUE) +#if (BLE_50_EXTEND_ADV_EN == TRUE) case HCI_BLE_SET_EXT_ADV_PARAM: case HCI_BLE_SET_EXT_ADV_DATA: case HCI_BLE_SET_EXT_SCAN_RSP_DATA: @@ -1113,6 +1302,7 @@ static void btu_hcif_hdl_command_complete (UINT16 opcode, UINT8 *p, UINT16 evt_l HCI_TRACE_EVENT("%s opcode 0x%x status 0x%x", __func__, opcode, status); break; } +#endif // #if (BLE_50_EXTEND_ADV_EN == TRUE) case HCI_BLE_READ_PHY: { uint16_t conn_handle; uint8_t tx_phy; @@ -1124,11 +1314,14 @@ static void btu_hcif_hdl_command_complete (UINT16 opcode, UINT8 *p, UINT16 evt_l btm_read_phy_callback(status, conn_handle, tx_phy, rx_phy); break; } +#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE) +#if (BLE_50_DTM_TEST_EN == TRUE) case HCI_BLE_ENH_RX_TEST: case HCI_BLE_ENH_TX_TEST: btm_ble_test_command_complete(p); break; -#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE) +#endif // #if (BLE_50_DTM_TEST_EN == TRUE) + #if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE) case HCI_BLE_SET_PERIOD_ADV_RECV_ENABLE: case HCI_BLE_SET_DEFAULT_PAST_PARAMS: @@ -1143,6 +1336,59 @@ static void btu_hcif_hdl_command_complete (UINT16 opcode, UINT8 *p, UINT16 evt_l break; } #endif // #if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE) +#if (BLE_FEAT_ISO_EN == TRUE) +#if (BLE_FEAT_ISO_BIG_SYNCER_EN == TRUE) + case HCI_BLE_BIG_TERMINATE_SYNC: + UINT16 big_handle; + STREAM_TO_UINT8(status, p); + STREAM_TO_UINT8(big_handle, p); + btm_ble_big_sync_terminate_complete(status, big_handle); + break; +#endif // #if (BLE_FEAT_ISO_BIG_SYNCER_EN == TRUE) + case HCI_BLE_ISO_SET_DATA_PATH: + case HCI_BLE_ISO_REMOVE_DATA_PATH: + UINT16 conn_handle; + STREAM_TO_UINT8(status, p); + STREAM_TO_UINT16(conn_handle, p); + btm_ble_iso_data_path_update_complete(opcode, status, conn_handle); + break; + case HCI_BLE_ISO_READ_TX_SYNC: + btm_ble_iso_read_iso_tx_sync_complete(p); + break; + case HCI_BLE_ISO_READ_ISO_LINK_QUALITY: + btm_ble_iso_read_iso_link_quality_complete(p); + break; + +#if (BLE_FEAT_ISO_CIG_CENTRAL_EN == TRUE) + case HCI_BLE_ISO_SET_CIG_PARAMS: + case HCI_BLE_ISO_SET_CIG_PARAMS_TEST: + btm_ble_iso_set_cig_params_complete(p); + break; + case HCI_BLE_ISO_REMOVE_CIG: + // do nothing + break; +#endif // #if (BLE_FEAT_ISO_CIG_CENTRAL_EN == TRUE) + +#if (BLE_FEAT_ISO_CIG_PERIPHERAL_EN == TRUE) + case HCI_BLE_ISO_ACCEPT_CIS_REQ: + case HCI_BLE_ISO_REJECT_CIS_REQ: + // do nothing + break; +#endif // #if (BLE_FEAT_ISO_CIG_PERIPHERAL_EN == TRUE) + +#endif // #if (BLE_FEAT_ISO_EN == TRUE) +#if (BLE_FEAT_CTE_EN == TRUE) + case HCI_BLE_READ_ANT_INFOR: + btm_ble_cte_read_ant_infor_complete(p); + break; +#endif // #if (BLE_FEAT_CTE_EN == TRUE) + +#if (BLE_FEAT_POWER_CONTROL_EN == TRUE) + case HCI_BLE_ENH_READ_TRANS_POWER_LEVEL: + btm_enh_read_trans_pwr_level_cmpl_evt(p); + break; +#endif //#if (BLE_FEAT_POWER_CONTROL_EN == TRUE) + #endif /* (BLE_INCLUDED == TRUE) */ default: { @@ -1192,6 +1438,7 @@ static void btu_hcif_command_complete_evt(BT_HDR *response, void *context) uint8_t *stream = response->data + response->offset + 3; STREAM_TO_UINT16(opcode, stream); switch (opcode) { +#if (BLE_42_ADV_EN == TRUE) case HCI_BLE_WRITE_ADV_DATA: adv_data_status = *stream; osi_sem_give(&adv_data_sem); @@ -1209,6 +1456,8 @@ static void btu_hcif_command_complete_evt(BT_HDR *response, void *context) adv_param_status = *stream; osi_sem_give(&adv_param_sem); break; +#endif // #if (BLE_42_ADV_EN == TRUE) +#if (BLE_42_SCAN_EN == TRUE) case HCI_BLE_WRITE_SCAN_PARAMS: scan_param_status = *stream; osi_sem_give(&scan_param_sem); @@ -1217,6 +1466,7 @@ static void btu_hcif_command_complete_evt(BT_HDR *response, void *context) scan_enable_status = *stream; osi_sem_give(&scan_enable_sem); break; +#endif // #if (BLE_42_SCAN_EN == TRUE) default: break; } @@ -1265,6 +1515,7 @@ static void btu_hcif_hdl_command_status (UINT16 opcode, UINT8 status, UINT8 *p_c #endif switch (opcode) { +#if (CLASSIC_BT_INCLUDED == TRUE) case HCI_EXIT_SNIFF_MODE: case HCI_EXIT_PARK_MODE: #if BTM_SCO_WAKE_PARKED_LINK == TRUE @@ -1284,7 +1535,9 @@ static void btu_hcif_hdl_command_status (UINT16 opcode, UINT8 status, UINT8 *p_c case HCI_PARK_MODE: btm_pm_proc_cmd_status(status); break; +#endif // #if (CLASSIC_BT_INCLUDED == TRUE) #if (BLE_50_FEATURE_SUPPORT == TRUE) +#if (BLE_50_EXTEND_SYNC_EN == TRUE) case HCI_BLE_PERIOD_ADV_CREATE_SYNC: { uint8_t btm_status = BTM_SUCCESS; @@ -1295,6 +1548,7 @@ static void btu_hcif_hdl_command_status (UINT16 opcode, UINT8 status, UINT8 *p_c btm_create_sync_callback(btm_status); break; } +#endif // #if (BLE_50_EXTEND_SYNC_EN == TRUE) case HCI_BLE_SET_PHY: { uint8_t btm_status = BTM_SUCCESS; @@ -1306,6 +1560,42 @@ static void btu_hcif_hdl_command_status (UINT16 opcode, UINT8 status, UINT8 *p_c break; } #endif // #if (BLE_50_FEATURE_SUPPORT == TRUE) +#if (BLE_FEAT_ISO_EN == TRUE) +#if (BLE_FEAT_ISO_BIG_BROCASTER_EN == TRUE) + case HCI_BLE_CREATE_BIG: + case HCI_BLE_CREATE_BIG_TEST: + btu_ble_create_big_cmd_status(status); + break; + case HCI_BLE_TERMINATE_BIG: + btu_ble_big_terminate_cmd_status(status); + break; +#endif // #if (BLE_FEAT_ISO_BIG_BROCASTER_EN == TRUE) +#if (BLE_FEAT_ISO_BIG_SYNCER_EN == TRUE) + case HCI_BLE_BIG_CREATE_SYNC: + btu_ble_create_big_sync_cmd_status(status); + break; +#endif // #if (BLE_FEAT_ISO_BIG_SYNCER_EN == TRUE) +#if (BLE_FEAT_ISO_CIG_CENTRAL_EN == TRUE) + case HCI_BLE_ISO_CREATE_CIS: + btu_ble_create_cis_cmd_status(status); + break; +#endif // #if (BLE_FEAT_ISO_CIG_CENTRAL_EN == TRUE) +#if (BLE_FEAT_ISO_CIG_PERIPHERAL_EN == TRUE) + case HCI_BLE_ISO_ACCEPT_CIS_REQ: + btu_ble_accept_cis_req_cmd_status(status); + break; +#endif // #if (BLE_FEAT_ISO_CIG_PERIPHERAL_EN == TRUE) +#endif // #if (BLE_FEAT_ISO_EN == TRUE) +#if (BLE_FEAT_POWER_CONTROL_EN == TRUE) + case HCI_BLE_READ_REMOTE_TRANS_POWER_LEVEL: + btm_read_remote_trans_pwr_level_cmpl(status); + break; +#endif // #if (BLE_FEAT_POWER_CONTROL_EN == TRUE) +#if (BLE_FEAT_CONN_SUBRATING == TRUE) + case HCI_BLE_SUBRATE_REQUEST: + btm_subrate_req_cmd_status(status); + break; +#endif // #if (BLE_FEAT_CONN_SUBRATING == TRUE) default: /* If command failed to start, we may need to tell BTM */ if (status != HCI_SUCCESS) { @@ -1379,6 +1669,9 @@ static void btu_hcif_hdl_command_status (UINT16 opcode, UINT8 status, UINT8 *p_c break; #if BLE_INCLUDED == TRUE +#if (BLE_50_FEATURE_SUPPORT == TRUE) + case HCI_BLE_EXT_CREATE_CONN: +#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE) case HCI_BLE_CREATE_LL_CONN: btm_ble_create_ll_conn_complete(status); break; @@ -1498,7 +1791,7 @@ static void btu_hcif_hardware_error_evt (UINT8 *p) } } - +#if (CLASSIC_BT_INCLUDED == TRUE) /******************************************************************************* ** ** Function btu_hcif_flush_occured_evt @@ -1535,7 +1828,7 @@ static void btu_hcif_role_change_evt (UINT8 *p) l2c_link_role_changed (bda, role, status); btm_acl_role_changed(status, bda, role); } - +#endif // #if (CLASSIC_BT_INCLUDED == TRUE) /******************************************************************************* ** @@ -1556,7 +1849,7 @@ static void btu_hcif_num_compl_data_pkts_evt (UINT8 *p) btm_sco_process_num_completed_pkts (p); #endif } - +#if (CLASSIC_BT_INCLUDED == TRUE) /******************************************************************************* ** ** Function btu_hcif_mode_change_evt @@ -1624,7 +1917,7 @@ static void btu_hcif_ssr_evt (UINT8 *p, UINT16 evt_len) HCI_TRACE_WARNING("hcif ssr evt: st 0x%x, hdl 0x%x, tx_lat %d rx_lat %d", status, handle, max_tx_lat, max_rx_lat); } - +#endif // #if (CLASSIC_BT_INCLUDED == TRUE) /******************************************************************************* ** ** Function btu_hcif_pin_code_request_evt @@ -1635,6 +1928,7 @@ static void btu_hcif_ssr_evt (UINT8 *p, UINT16 evt_len) ** *******************************************************************************/ #if (SMP_INCLUDED == TRUE) +#if (CLASSIC_BT_INCLUDED == TRUE) static void btu_hcif_pin_code_request_evt (UINT8 *p) { #if (CLASSIC_BT_INCLUDED == TRUE) @@ -1689,9 +1983,10 @@ static void btu_hcif_link_key_notification_evt (UINT8 *p) btm_sec_link_key_notification (bda, key, key_type); } +#endif // #if (CLASSIC_BT_INCLUDED == TRUE) #endif ///SMP_INCLUDED == TRUE - +#if (CLASSIC_BT_INCLUDED == TRUE) /******************************************************************************* ** ** Function btu_hcif_loopback_command_evt @@ -1867,7 +2162,7 @@ static void btu_hcif_host_support_evt (UINT8 *p) ** Returns void ** *******************************************************************************/ -#if (CLASSIC_BT_INCLUDED == TRUE) + static void btu_hcif_io_cap_request_evt (UINT8 *p) { btm_io_capabilities_req(p); @@ -1976,6 +2271,7 @@ static void btu_hcif_rem_oob_request_evt (UINT8 *p) } #endif +#if (CLASSIC_BT_INCLUDED == TRUE) /******************************************************************************* ** ** Function btu_hcif_link_supv_to_changed_evt @@ -2014,6 +2310,7 @@ static void btu_hcif_enhanced_flush_complete_evt (void) /* This is empty until an upper layer cares about returning event */ } #endif +#endif // #if (CLASSIC_BT_INCLUDED == TRUE) /********************************************** ** End of Simple Pairing Events ***********************************************/ @@ -2133,6 +2430,7 @@ static void btu_ble_phy_update_complete_evt(UINT8 *p) } #if BLE_PRIVACY_SPT == TRUE +#if (BLE_50_EXTEND_SCAN_EN == TRUE) /******************************************************************************* ** ** Function btm_ble_resolve_random_addr_adv_ext @@ -2153,13 +2451,17 @@ static void btm_ble_resolve_random_addr_adv_ext(void *p_rec, void *p) BDADDR_TO_STREAM(pp,bda); } } +#endif // #if (BLE_50_EXTEND_SCAN_EN == TRUE) #endif +#if (BLE_50_EXTEND_SCAN_EN == TRUE) static void btu_ble_ext_adv_report_evt(UINT8 *p, UINT16 evt_len) { tBTM_BLE_EXT_ADV_REPORT ext_adv_report = {0}; UINT8 num_reports = {0}; +#if (defined BLE_PRIVACY_SPT && BLE_PRIVACY_SPT == TRUE) UINT8 *pp = p; +#endif //UINT8 legacy_event_type = 0; UINT16 evt_type = 0; uint8_t addr_type; @@ -2233,7 +2535,9 @@ 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) { tBTM_BLE_PERIOD_ADV_SYNC_ESTAB sync_estab = {0}; @@ -2274,7 +2578,7 @@ static void btu_ble_periodic_adv_report_evt(UINT8 *p, UINT8 evt_len) STREAM_TO_UINT16(adv_report.sync_handle, p); STREAM_TO_UINT8(adv_report.tx_power, p); STREAM_TO_UINT8(adv_report.rssi, p); - STREAM_TO_UINT8(unused, p); + STREAM_TO_UINT8(adv_report.cte_type, p); STREAM_TO_UINT8(adv_report.data_status, p); STREAM_TO_UINT8(adv_report.data_length, p); @@ -2306,14 +2610,18 @@ static void btu_ble_periodic_adv_sync_lost_evt(UINT8 *p) btm_ble_periodic_adv_sync_lost_evt(&sync_lost); } +#endif // #if (BLE_50_EXTEND_SYNC_EN == TRUE) +#if (BLE_50_EXTEND_SCAN_EN == TRUE) static void btu_ble_scan_timeout_evt(UINT8 *p) { UNUSED(p); btm_ble_scan_timeout_evt(); } +#endif // #if (BLE_50_EXTEND_SCAN_EN == TRUE) +#if (BLE_50_EXTEND_ADV_EN == TRUE) static void btu_ble_adv_set_terminate_evt(UINT8 *p) { tBTM_BLE_ADV_TERMINAT adv_term = {0}; @@ -2346,6 +2654,22 @@ static void btu_ble_scan_req_received_evt(UINT8 *p) btm_ble_scan_req_received_evt(&req_received); } +#endif // #if (BLE_50_EXTEND_ADV_EN == TRUE) + +static void btu_ble_channel_select_alg_evt(UINT8 *p) +{ + tBTM_BLE_CHANNEL_SEL_ALG chan_sel_alg = {0}; + + if (!p) { + HCI_TRACE_ERROR("%s, Invalid params.", __func__); + return; + } + + STREAM_TO_UINT16(chan_sel_alg.conn_handle, p); + STREAM_TO_UINT8(chan_sel_alg.channel_sel_alg, p); + + btm_ble_channel_select_algorithm_evt(&chan_sel_alg); +} #endif // #if (BLE_50_FEATURE_SUPPORT == TRUE) #if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE) @@ -2380,6 +2704,384 @@ static void btu_ble_periodic_adv_sync_trans_recv(UINT8 *p) } #endif // #if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE) +#if (BLE_FEAT_ISO_EN == TRUE) + +#if (BLE_FEAT_ISO_CIG_CENTRAL_EN == TRUE) +static void btu_ble_create_cis_cmd_status(UINT8 status) +{ + tBTM_BLE_ISO_CB_PARAMS cb_params = {0}; + if (status != HCI_SUCCESS) { + status = (BTM_HCI_ERROR | status); + } + cb_params.status = status; + btm_ble_create_cis_cmd_status(&cb_params); +} +#endif // #if (BLE_FEAT_ISO_CIG_CENTRAL_EN == TRUE) + +#if (BLE_FEAT_ISO_CIG_PERIPHERAL_EN == TRUE) +static void btu_ble_accept_cis_req_cmd_status(UINT8 status) +{ + tBTM_BLE_ISO_CB_PARAMS cb_params = {0}; + if (status != HCI_SUCCESS) { + status = (BTM_HCI_ERROR | status); + } + cb_params.status = status; + + btm_ble_accept_cis_req_cmd_status(&cb_params); +} +#endif // #if (BLE_FEAT_ISO_CIG_PERIPHERAL_EN == TRUE) + +#if (BLE_FEAT_ISO_CIG_EN == TRUE) +static void btu_ble_cis_disconnected(UINT16 handle, UINT8 reason) +{ + tBTM_BLE_CIS_DISCON_CMPL cis_disconnected_evt = {0}; + cis_disconnected_evt.cis_handle = handle; + cis_disconnected_evt.reason = reason; + btm_ble_cis_disconnected_evt(&cis_disconnected_evt); +} + +static void btu_ble_cis_established_evt(UINT8 *p) +{ + HCI_TRACE_DEBUG("%s", __func__); + tBTM_BLE_CIS_ESTABLISHED_CMPL cis_estab_evt = {0}; + + if (!p) { + HCI_TRACE_ERROR("%s, Invalid params.", __func__); + return; + } + + STREAM_TO_UINT8(cis_estab_evt.status, p); + STREAM_TO_UINT16(cis_estab_evt.conn_handle, p); + STREAM_TO_UINT24(cis_estab_evt.cig_sync_delay, p); + STREAM_TO_UINT24(cis_estab_evt.cis_sync_delay, p); + STREAM_TO_UINT24(cis_estab_evt.trans_lat_c_to_p, p); + STREAM_TO_UINT24(cis_estab_evt.trans_lat_p_to_c, p); + STREAM_TO_UINT8(cis_estab_evt.phy_c_to_p, p); + STREAM_TO_UINT8(cis_estab_evt.phy_p_to_c, p); + STREAM_TO_UINT8(cis_estab_evt.nse, p); + STREAM_TO_UINT8(cis_estab_evt.bn_c_to_p, p); + STREAM_TO_UINT8(cis_estab_evt.bn_p_to_c, p); + STREAM_TO_UINT8(cis_estab_evt.ft_c_to_p, p); + STREAM_TO_UINT8(cis_estab_evt.ft_p_to_c, p); + STREAM_TO_UINT16(cis_estab_evt.max_pdu_c_to_p, 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); +#endif // #if (BLE_FEAT_ISO_60_EN == TRUE) + + btm_ble_cis_established_evt(&cis_estab_evt); +} +#endif // #if (BLE_FEAT_ISO_CIG_EN == TRUE) + +#if (BLE_FEAT_ISO_CIG_PERIPHERAL_EN == TRUE) +static void btu_ble_cis_request_evt(UINT8 *p) +{ + HCI_TRACE_DEBUG("%s", __func__); + tBTM_BLE_CIS_REQUEST_CMPL cis_req_evt = {0}; + + if (!p) { + HCI_TRACE_ERROR("%s, Invalid params.", __func__); + return; + } + + STREAM_TO_UINT16(cis_req_evt.acl_handle, p); + STREAM_TO_UINT16(cis_req_evt.cis_handle, p); + STREAM_TO_UINT8(cis_req_evt.cig_id, p); + STREAM_TO_UINT8(cis_req_evt.cis_id, p); + + + btm_ble_cis_request_evt(&cis_req_evt); +} +#endif // #if (BLE_FEAT_ISO_CIG_PERIPHERAL_EN == TRUE) + +#if (BLE_FEAT_ISO_BIG_BROCASTER_EN == TRUE) +void btu_ble_create_big_cmd_status(UINT8 status) +{ + if (status != HCI_SUCCESS) { + tBTM_BLE_BIG_CREATE_CMPL big_cmpl = {0}; + btm_ble_big_create_cmpl_evt(&big_cmpl); + } +} + +static void btu_ble_big_create_complete_evt(UINT8 *p) +{ + HCI_TRACE_DEBUG("%s", __func__); + tBTM_BLE_BIG_CREATE_CMPL big_cmpl = {0}; + + if (!p) { + HCI_TRACE_ERROR("%s, Invalid params.", __func__); + return; + } + + STREAM_TO_UINT8(big_cmpl.status, p); + STREAM_TO_UINT8(big_cmpl.big_handle, p); + STREAM_TO_UINT24(big_cmpl.big_sync_delay, p); + STREAM_TO_UINT24(big_cmpl.transport_latency, p); + STREAM_TO_UINT8(big_cmpl.phy, p); + STREAM_TO_UINT8(big_cmpl.nse, p); + STREAM_TO_UINT8(big_cmpl.bn, p); + STREAM_TO_UINT8(big_cmpl.pto, p); + STREAM_TO_UINT8(big_cmpl.irc, p); + STREAM_TO_UINT16(big_cmpl.max_pdu, p); + STREAM_TO_UINT16(big_cmpl.iso_interval, p); + STREAM_TO_UINT8(big_cmpl.num_bis, p); + for (uint8_t i = 0; i < big_cmpl.num_bis; i++) + { + STREAM_TO_UINT16(big_cmpl.bis_handle[i], p); + // only 12 bits meaningful + big_cmpl.bis_handle[i] = (big_cmpl.bis_handle[i] & 0x0FFF); + } + + btm_ble_big_create_cmpl_evt(&big_cmpl); +} + +void btu_ble_big_terminate_cmd_status(UINT8 status) +{ + if (status != HCI_SUCCESS) { + tBTM_BLE_BIG_TERMINATE_CMPL big_term = {0}; + big_term.status = (status | BTM_HCI_ERROR); + btm_ble_big_terminate_cmpl_evt(&big_term); + } +} + +static void btu_ble_big_terminate_complete_evt(UINT8 *p) +{ + tBTM_BLE_BIG_TERMINATE_CMPL big_term = {0}; + + if (!p) { + HCI_TRACE_ERROR("%s, Invalid params.", __func__); + return; + } + + STREAM_TO_UINT8(big_term.big_handle, p); + STREAM_TO_UINT8(big_term.reason, p); + big_term.status = HCI_SUCCESS; + + btm_ble_big_terminate_cmpl_evt(&big_term); +} +#endif // #if (BLE_FEAT_ISO_BIG_BROCASTER_EN == TRUE) + +#if (BLE_FEAT_ISO_BIG_SYNCER_EN == TRUE) +void btu_ble_create_big_sync_cmd_status(UINT8 status) +{ + if (status != HCI_SUCCESS) { + tBTM_BLE_BIG_SYNC_ESTAB_CMPL big_estb = {0}; + big_estb.status = status; + btm_ble_big_sync_estab_evt(&big_estb); + } +} + +static void btu_ble_big_sync_establish_evt(UINT8 *p) +{ + tBTM_BLE_BIG_SYNC_ESTAB_CMPL big_estb = {0}; + + if (!p) { + HCI_TRACE_ERROR("%s, Invalid params.", __func__); + return; + } + + STREAM_TO_UINT8(big_estb.status, p); + STREAM_TO_UINT8(big_estb.big_handle, p); + STREAM_TO_UINT24(big_estb.transport_latency_big, p); + STREAM_TO_UINT8(big_estb.nse, p); + STREAM_TO_UINT8(big_estb.bn, p); + STREAM_TO_UINT8(big_estb.pto, p); + STREAM_TO_UINT8(big_estb.irc, p); + STREAM_TO_UINT16(big_estb.max_pdu, p); + STREAM_TO_UINT16(big_estb.iso_interval, p); + STREAM_TO_UINT8(big_estb.num_bis, p); + for (uint8_t i = 0; i < big_estb.num_bis; i++) + { + STREAM_TO_UINT16(big_estb.bis_handle[i], p); + } + + btm_ble_big_sync_estab_evt(&big_estb); +} + +static void btu_ble_big_sync_lost_evt(UINT8 *p) +{ + tBTM_BLE_BIG_SYNC_LOST_EVT big_sync_lost = {0}; + + if (!p) { + HCI_TRACE_ERROR("%s, Invalid params.", __func__); + return; + } + + STREAM_TO_UINT8(big_sync_lost.big_handle, p); + STREAM_TO_UINT8(big_sync_lost.reason, p); + + btm_ble_big_sync_lost_evt(&big_sync_lost); +} + +static void btu_ble_biginfo_adv_report_evt(UINT8 *p) +{ + tBTM_BLE_BIGINFO_ADV_REPORT_EVT biginfo_report = {0}; + + if (!p) { + HCI_TRACE_ERROR("%s, Invalid params.", __func__); + return; + } + + STREAM_TO_UINT16(biginfo_report.sync_handle, p); + STREAM_TO_UINT8(biginfo_report.num_bis, p); + STREAM_TO_UINT8(biginfo_report.nse, p); + STREAM_TO_UINT16(biginfo_report.iso_interval, p); + STREAM_TO_UINT8(biginfo_report.bn, p); + STREAM_TO_UINT8(biginfo_report.pto, p); + STREAM_TO_UINT8(biginfo_report.irc, p); + STREAM_TO_UINT16(biginfo_report.max_pdu, p); + STREAM_TO_UINT24(biginfo_report.sdu_interval, p); + STREAM_TO_UINT16(biginfo_report.max_sdu, p); + STREAM_TO_UINT8(biginfo_report.phy, p); + STREAM_TO_UINT8(biginfo_report.framing, p); + STREAM_TO_UINT8(biginfo_report.encryption, p); + + btm_ble_biginfo_adv_report_evt(&biginfo_report); +} +#endif // #if (BLE_FEAT_ISO_BIG_SYNCER_EN == TRUE) +#endif // #if (BLE_FEAT_ISO_EN == TRUE) + +#if (BLE_FEAT_CTE_EN == TRUE) +#if (BLE_FEAT_CTE_CONNECTIONLESS_EN == TRUE) +static void btu_ble_cte_connless_iq_report_evt(UINT8 *p) +{ + tBTM_BLE_CTE_CONNLESS_IQ_REPORT_EVT connless_iq_rpt = {0}; + + if (!p) { + HCI_TRACE_ERROR("%s, Invalid params.", __func__); + return; + } + + STREAM_TO_UINT16(connless_iq_rpt.sync_handle, p); + STREAM_TO_UINT8(connless_iq_rpt.channel_idx, p); + STREAM_TO_UINT16(connless_iq_rpt.rssi, p); + STREAM_TO_UINT8(connless_iq_rpt.rssi_ant_id, p); + STREAM_TO_UINT8(connless_iq_rpt.cte_type, p); + STREAM_TO_UINT8(connless_iq_rpt.slot_dur, p); + STREAM_TO_UINT8(connless_iq_rpt.pkt_status, p); + STREAM_TO_UINT16(connless_iq_rpt.periodic_evt_counter, p); + STREAM_TO_UINT8(connless_iq_rpt.sample_count, p); + + for (uint8_t i = 0; i < connless_iq_rpt.sample_count; i++) + { + STREAM_TO_UINT8(connless_iq_rpt.i_sample[i], p); + STREAM_TO_UINT8(connless_iq_rpt.q_sample[i], p); + } + + btm_ble_connless_iq_report_evt(&connless_iq_rpt); +} +#endif // #if (BLE_FEAT_CTE_CONNECTIONLESS_EN == TRUE) + +#if (BLE_FEAT_CTE_CONNECTION_EN == TRUE) +static void btu_ble_cte_conn_iq_report_evt(UINT8 *p) +{ + tBTM_BLE_CTE_CONN_IQ_REPORT_EVT conn_iq_rpt = {0}; + + if (!p) { + HCI_TRACE_ERROR("%s, Invalid params.", __func__); + return; + } + + STREAM_TO_UINT16(conn_iq_rpt.conn_handle, p); + STREAM_TO_UINT8(conn_iq_rpt.rx_phy, p); + STREAM_TO_UINT8(conn_iq_rpt.data_channel_idx, p); + STREAM_TO_UINT16(conn_iq_rpt.rssi, p); + STREAM_TO_UINT8(conn_iq_rpt.rssi_ant_id, p); + STREAM_TO_UINT8(conn_iq_rpt.cte_type, p); + STREAM_TO_UINT8(conn_iq_rpt.slot_dur, p); + STREAM_TO_UINT8(conn_iq_rpt.pkt_status, p); + STREAM_TO_UINT16(conn_iq_rpt.conn_evt_counter, p); + STREAM_TO_UINT8(conn_iq_rpt.sample_count, p); + + for (uint8_t i = 0; i < conn_iq_rpt.sample_count; i++) + { + STREAM_TO_UINT8(conn_iq_rpt.i_sample[i], p); + STREAM_TO_UINT8(conn_iq_rpt.q_sample[i], p); + } + + btm_ble_conn_iq_report_evt(&conn_iq_rpt); +} + +static void btu_ble_cte_req_failed_evt(UINT8 *p) +{ + tBTM_BLE_CTE_REQ_FAILED_EVT cte_req_failed = {0}; + + if (!p) { + HCI_TRACE_ERROR("%s, Invalid params.", __func__); + return; + } + + STREAM_TO_UINT8(cte_req_failed.status, p); + STREAM_TO_UINT16(cte_req_failed.conn_handle, p); + + btm_ble_cte_req_failed_evt(&cte_req_failed); +} +#endif // #if (BLE_FEAT_CTE_CONNECTION_EN == TRUE) + +#endif // #if (BLE_FEAT_CTE_EN == TRUE) + +#if (BLE_FEAT_POWER_CONTROL_EN == TRUE) +static void btu_ble_path_loss_threshold_evt(UINT8 *p) +{ + tBTM_BLE_PATH_LOSS_THRESHOLD_EVT path_loss_thres_evt = {0}; + if (!p) { + HCI_TRACE_ERROR("%s, Invalid params.", __func__); + return; + } + + STREAM_TO_UINT16(path_loss_thres_evt.conn_handle, p); + STREAM_TO_UINT8(path_loss_thres_evt.cur_path_loss, p); + STREAM_TO_UINT8(path_loss_thres_evt.zone_entered, p); + + btm_ble_path_loss_threshold_evt(&path_loss_thres_evt); +} + +static void btu_ble_transmit_power_report_evt(UINT8 *p) +{ + tBTM_BLE_TRANS_POWER_REPORT_EVT trans_pwr_report_evt = {0}; + if (!p) { + HCI_TRACE_ERROR("%s, Invalid params.", __func__); + return; + } + + STREAM_TO_UINT8(trans_pwr_report_evt.status, p); + STREAM_TO_UINT16(trans_pwr_report_evt.conn_handle, p); + STREAM_TO_UINT8(trans_pwr_report_evt.reason, p); + STREAM_TO_UINT8(trans_pwr_report_evt.phy, p); + STREAM_TO_UINT8(trans_pwr_report_evt.tx_power_level, p); + STREAM_TO_UINT8(trans_pwr_report_evt.tx_power_level_flag, p); + STREAM_TO_UINT8(trans_pwr_report_evt.delta, p); + + btm_ble_transmit_power_report_evt(&trans_pwr_report_evt); +} +#endif // #if (BLE_FEAT_POWER_CONTROL_EN == TRUE) + +#if (BLE_FEAT_CONN_SUBRATING == TRUE) +static void btu_ble_subrate_change_evt(UINT8 *p) +{ + tBTM_BLE_SUBRATE_CHANGE_EVT subrate_change_evt = {0}; + if (!p) { + HCI_TRACE_ERROR("%s, Invalid params.", __func__); + return; + } + + STREAM_TO_UINT8(subrate_change_evt.status, p); + STREAM_TO_UINT16(subrate_change_evt.conn_handle, p); + STREAM_TO_UINT16(subrate_change_evt.subrate_factor, p); + STREAM_TO_UINT16(subrate_change_evt.peripheral_latency, p); + STREAM_TO_UINT16(subrate_change_evt.continuation_number, p); + STREAM_TO_UINT16(subrate_change_evt.supervision_timeout, p); + + btm_ble_subrate_change_evt(&subrate_change_evt); +} +#endif // #if (BLE_FEAT_CONN_SUBRATING == TRUE) + /********************************************** ** End of BLE Events Handler ***********************************************/ diff --git a/lib/bt/host/bluedroid/stack/btu/btu_init.c b/lib/bt/host/bluedroid/stack/btu/btu_init.c index 9ede9c2d..a00b3243 100644 --- a/lib/bt/host/bluedroid/stack/btu/btu_init.c +++ b/lib/bt/host/bluedroid/stack/btu/btu_init.c @@ -254,17 +254,6 @@ UINT16 BTU_BleAclPktSize(void) #endif } -#if SCAN_QUEUE_CONGEST_CHECK -bool BTU_check_queue_is_congest(void) -{ - if (osi_thread_queue_wait_size(btu_thread, 0) >= BT_QUEUE_CONGEST_SIZE) { - return true; - } - - return false; -} -#endif - int get_btu_work_queue_size(void) { return osi_thread_queue_wait_size(btu_thread, 0); diff --git a/lib/bt/host/bluedroid/stack/btu/btu_task.c b/lib/bt/host/bluedroid/stack/btu/btu_task.c index 9311a36d..bffa6837 100644 --- a/lib/bt/host/bluedroid/stack/btu/btu_task.c +++ b/lib/bt/host/bluedroid/stack/btu/btu_task.c @@ -229,11 +229,13 @@ bool btu_task_post(uint32_t sig, void *param, uint32_t timeout) break; case SIG_BTU_HCI_ADV_RPT_MSG: #if BLE_INCLUDED == TRUE +#if (BLE_42_SCAN_EN == TRUE) if (param != NULL) { btm_ble_adv_pkt_post(param); } btm_ble_adv_pkt_ready(); status = true; +#endif // #if (BLE_42_SCAN_EN == TRUE) #else osi_free(param); status = false; @@ -451,7 +453,7 @@ void btu_start_timer(TIMER_LIST_ENT *p_tle, UINT16 type, UINT32 timeout_sec) // NOTE: This value is in seconds but stored in a ticks field. p_tle->ticks = timeout_sec; p_tle->in_use = TRUE; - osi_alarm_set(alarm, (period_ms_t)(timeout_sec * 1000)); + osi_alarm_set(alarm, (period_ms_t)((period_ms_t)timeout_sec * 1000)); } -- cgit v1.2.3