Merge branch 'bugfix/hf_ag_report_event_with_null_bdaddr_v4.3' into 'release/v4.3'

Bugfix/fixed bugs of HFP in BlueDroid (v4.3)

See merge request espressif/esp-idf!25830
This commit is contained in:
Jiang Jiang Jian
2023-09-11 10:15:09 +08:00
26 changed files with 760 additions and 250 deletions
@@ -1,10 +1,8 @@
/*
This example code is in the Public Domain (or CC0 licensed, at your option.)
Unless required by applicable law or agreed to in writing, this
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied.
*/
* SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Unlicense OR CC0-1.0
*/
#include <stdint.h>
#include <stdbool.h>
@@ -46,6 +44,7 @@ const char *c_hf_evt_str[] = {
"DIAL_EVT", /*!< DIAL INCOMING EVT */
"WBS_EVT", /*!< CURRENT CODEC EVT */
"BCS_EVT", /*!< CODEC NEGO EVT */
"PKT_STAT_EVT", /*!< REQUEST PACKET STATUS EVT */
};
//esp_hf_connection_state_t
@@ -213,7 +212,7 @@ static void bt_app_send_data_timer_cb(void *arg)
static void bt_app_send_data_task(void *arg)
{
uint64_t frame_data_num;
uint32_t item_size = 0;
size_t item_size = 0;
uint8_t *buf = NULL;
for (;;) {
if (xSemaphoreTake(s_send_data_Semaphore, (portTickType)portMAX_DELAY)) {
@@ -276,14 +275,14 @@ void bt_app_send_data_shut_down(void)
vTaskDelete(s_bt_app_send_data_task_handler);
s_bt_app_send_data_task_handler = NULL;
}
if (s_send_data_Semaphore) {
vSemaphoreDelete(s_send_data_Semaphore);
s_send_data_Semaphore = NULL;
}
if(s_periodic_timer) {
ESP_ERROR_CHECK(esp_timer_stop(s_periodic_timer));
ESP_ERROR_CHECK(esp_timer_delete(s_periodic_timer));
}
if (s_send_data_Semaphore) {
vSemaphoreDelete(s_send_data_Semaphore);
s_send_data_Semaphore = NULL;
}
if (s_m_rb) {
vRingbufferDelete(s_m_rb);
}
@@ -293,7 +292,7 @@ void bt_app_send_data_shut_down(void)
void bt_app_hf_cb(esp_hf_cb_event_t event, esp_hf_cb_param_t *param)
{
if (event <= ESP_HF_BCS_RESPONSE_EVT) {
if (event <= ESP_HF_PKT_STAT_NUMS_GET_EVT) {
ESP_LOGI(BT_HF_TAG, "APP HFP event: %s", c_hf_evt_str[event]);
} else {
ESP_LOGE(BT_HF_TAG, "APP HFP invalid event %d", event);
@@ -349,7 +348,7 @@ void bt_app_hf_cb(esp_hf_cb_event_t event, esp_hf_cb_param_t *param)
case ESP_HF_UNAT_RESPONSE_EVT:
{
ESP_LOGI(BT_HF_TAG, "--UNKOW AT CMD: %s", param->unat_rep.unat);
esp_hf_unat_response(hf_peer_addr, NULL);
esp_hf_unat_response(param->unat_rep.remote_addr, NULL);
break;
}
@@ -360,7 +359,7 @@ void bt_app_hf_cb(esp_hf_cb_event_t event, esp_hf_cb_param_t *param)
esp_hf_call_setup_status_t call_setup_state = 2;
esp_hf_network_state_t ntk_state = 1;
int signal = 2;
esp_bt_hf_indchange_notification(hf_peer_addr,call_state,call_setup_state,ntk_state,signal);
esp_bt_hf_indchange_notification(param->ind_upd.remote_addr,call_state,call_setup_state,ntk_state,signal);
break;
}
@@ -374,14 +373,14 @@ void bt_app_hf_cb(esp_hf_cb_event_t event, esp_hf_cb_param_t *param)
esp_hf_roaming_status_t roam = 0;
int batt_lev = 3;
esp_hf_call_held_status_t call_held_status = 0;
esp_bt_hf_cind_response(hf_peer_addr,call_status,call_setup_status,ntk_state,signal,roam,batt_lev,call_held_status);
esp_bt_hf_cind_response(param->cind_rep.remote_addr,call_status,call_setup_status,ntk_state,signal,roam,batt_lev,call_held_status);
break;
}
case ESP_HF_COPS_RESPONSE_EVT:
{
const int svc_type = 1;
esp_bt_hf_cops_response(hf_peer_addr, c_operator_name_str[svc_type]);
esp_bt_hf_cops_response(param->cops_rep.remote_addr, c_operator_name_str[svc_type]);
break;
}
@@ -398,7 +397,7 @@ void bt_app_hf_cb(esp_hf_cb_event_t event, esp_hf_cb_param_t *param)
esp_hf_call_addr_type_t type = ESP_HF_CALL_ADDR_TYPE_UNKNOWN;
ESP_LOGI(BT_HF_TAG, "--Calling Line Identification.");
esp_bt_hf_clcc_response(hf_peer_addr, index, dir, current_call_status, mode, mpty, number, type);
esp_bt_hf_clcc_response(param->clcc_rep.remote_addr, index, dir, current_call_status, mode, mpty, number, type);
break;
}
@@ -407,7 +406,7 @@ void bt_app_hf_cb(esp_hf_cb_event_t event, esp_hf_cb_param_t *param)
char *number = {"123456"};
esp_hf_subscriber_service_type_t type = 1;
ESP_LOGI(BT_HF_TAG, "--Current Number is %s ,Type is %s.", number, c_subscriber_service_type_str[type]);
esp_bt_hf_cnum_response(hf_peer_addr, number,type);
esp_bt_hf_cnum_response(param->cnum_rep.remote_addr, number,type);
break;
}
@@ -427,7 +426,7 @@ void bt_app_hf_cb(esp_hf_cb_event_t event, esp_hf_cb_param_t *param)
{
ESP_LOGI(BT_HF_TAG, "--Asnwer Incoming Call.");
char *number = {"123456"};
esp_bt_hf_answer_call(hf_peer_addr,1,0,1,0,number,0);
esp_bt_hf_answer_call(param->ata_rep.remote_addr,1,0,1,0,number,0);
break;
}
@@ -435,18 +434,33 @@ void bt_app_hf_cb(esp_hf_cb_event_t event, esp_hf_cb_param_t *param)
{
ESP_LOGI(BT_HF_TAG, "--Reject Incoming Call.");
char *number = {"123456"};
esp_bt_hf_reject_call(hf_peer_addr,0,0,0,0,number,0);
esp_bt_hf_reject_call(param->chup_rep.remote_addr,0,0,0,0,number,0);
break;
}
case ESP_HF_DIAL_EVT:
{
if (param->out_call.num_or_loc) {
//dia_num_or_mem
ESP_LOGI(BT_HF_TAG, "--Dial \"%s\".", param->out_call.num_or_loc);
esp_bt_hf_out_call(hf_peer_addr,1,0,1,0,param->out_call.num_or_loc,0);
if (param->out_call.type == ESP_HF_DIAL_NUM) {
// dia_num
ESP_LOGI(BT_HF_TAG, "--Dial number \"%s\".", param->out_call.num_or_loc);
esp_bt_hf_out_call(param->out_call.remote_addr,1,0,1,0,param->out_call.num_or_loc,0);
} else if (param->out_call.type == ESP_HF_DIAL_MEM) {
// dia_mem
ESP_LOGI(BT_HF_TAG, "--Dial memory \"%s\".", param->out_call.num_or_loc);
// AG found phone number by memory position
bool num_found = true;
if (num_found) {
char *number = "123456";
esp_bt_hf_cmee_response(param->out_call.remote_addr, ESP_HF_AT_RESPONSE_CODE_OK, ESP_HF_CME_AG_FAILURE);
esp_bt_hf_out_call(param->out_call.remote_addr,1,0,1,0,number,0);
} else {
esp_bt_hf_cmee_response(param->out_call.remote_addr, ESP_HF_AT_RESPONSE_CODE_CME, ESP_HF_CME_MEMEORY_FAILURE);
}
}
} else {
//dia_last
//refer to dia_mem
ESP_LOGI(BT_HF_TAG, "--Dial last number.");
}
break;
@@ -463,6 +477,11 @@ void bt_app_hf_cb(esp_hf_cb_event_t event, esp_hf_cb_param_t *param)
ESP_LOGI(BT_HF_TAG, "--Consequence of codec negotiation: %s",c_codec_mode_str[param->bcs_rep.mode]);
break;
}
case ESP_HF_PKT_STAT_NUMS_GET_EVT:
{
ESP_LOGI(BT_HF_TAG, "ESP_HF_PKT_STAT_NUMS_GET_EVT: %d.", event);
break;
}
default:
ESP_LOGI(BT_HF_TAG, "Unsupported HF_AG EVT: %d.", event);
@@ -0,0 +1,11 @@
# Override some defaults so BT stack is enabled and
# Classic BT is enabled and BT_DRAM_RELEASE is disabled
CONFIG_BT_ENABLED=y
CONFIG_BT_BLE_ENABLED=n
CONFIG_BTDM_CTRL_MODE_BR_EDR_ONLY=y
CONFIG_BTDM_CTRL_BR_EDR_MAX_SYNC_CONN=1
CONFIG_BT_BLUEDROID_ENABLED=y
CONFIG_BT_CLASSIC_ENABLED=y
CONFIG_BT_HFP_ENABLE=y
CONFIG_BT_HFP_AG_ENABLE=y
CONFIG_BT_HFP_AUDIO_DATA_PATH_HCI=y
@@ -1,10 +1,8 @@
/*
This example code is in the Public Domain (or CC0 licensed, at your option.)
Unless required by applicable law or agreed to in writing, this
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express esp_hf_ag_apiied.
*/
* SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Unlicense OR CC0-1.0
*/
#include <stdint.h>
#include <stdbool.h>
@@ -49,6 +47,7 @@ const char *c_hf_evt_str[] = {
"INBAND_RING_TONE_EVT", /*!< in-band ring tone settings */
"LAST_VOICE_TAG_NUMBER_EVT", /*!< requested number from AG event */
"RING_IND_EVT", /*!< ring indication event */
"PKT_STAT_EVT", /*!< requested number of packet status event */
};
// esp_hf_client_connection_state_t
@@ -229,7 +228,7 @@ static void bt_app_hf_client_incoming_cb(const uint8_t *buf, uint32_t sz)
/* callback for HF_CLIENT */
void bt_app_hf_client_cb(esp_hf_client_cb_event_t event, esp_hf_client_cb_param_t *param)
{
if (event <= ESP_HF_CLIENT_RING_IND_EVT) {
if (event <= ESP_HF_CLIENT_PKT_STAT_NUMS_GET_EVT) {
ESP_LOGI(BT_HF_TAG, "APP HFP event: %s", c_hf_evt_str[event]);
} else {
ESP_LOGE(BT_HF_TAG, "APP HFP invalid event %d", event);
@@ -394,7 +393,11 @@ void bt_app_hf_client_cb(esp_hf_client_cb_event_t event, esp_hf_client_cb_param_
(param->binp.number == NULL) ? "NULL" : param->binp.number);
break;
}
case ESP_HF_CLIENT_PKT_STAT_NUMS_GET_EVT:
{
ESP_LOGE(BT_HF_TAG, "ESP_HF_CLIENT_PKT_STAT_NUMS_GET_EVT: %d", event);
break;
}
default:
ESP_LOGE(BT_HF_TAG, "HF_CLIENT EVT: %d", event);
break;
@@ -0,0 +1,11 @@
# Override some defaults so BT stack is enabled and
# Classic BT is enabled and BT_DRAM_RELEASE is disabled
CONFIG_BT_ENABLED=y
CONFIG_BT_BLE_ENABLED=n
CONFIG_BTDM_CTRL_MODE_BR_EDR_ONLY=y
CONFIG_BTDM_CTRL_BR_EDR_MAX_SYNC_CONN=1
CONFIG_BT_BLUEDROID_ENABLED=y
CONFIG_BT_CLASSIC_ENABLED=y
CONFIG_BT_HFP_ENABLE=y
CONFIG_BT_HFP_CLIENT_ENABLE=y
CONFIG_BT_HFP_AUDIO_DATA_PATH_HCI=y