From 76a3f84779e6aedfab13ac6e9d6a7fe841020f8d Mon Sep 17 00:00:00 2001 From: yangfeng Date: Mon, 13 Jul 2026 10:48:52 +0800 Subject: [PATCH] fix(bt/example): Add log in the failure path for avrcp_ct_metadata example --- .../classic_bt/avrcp_ct_metadata/main/main.c | 14 ++++++++++---- .../common/bt_app_core_utils/bt_app_core_utils.c | 9 +++++++++ 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/examples/bluetooth/bluedroid/classic_bt/avrcp_ct_metadata/main/main.c b/examples/bluetooth/bluedroid/classic_bt/avrcp_ct_metadata/main/main.c index 0d094121305..4ff11d03e92 100644 --- a/examples/bluetooth/bluedroid/classic_bt/avrcp_ct_metadata/main/main.c +++ b/examples/bluetooth/bluedroid/classic_bt/avrcp_ct_metadata/main/main.c @@ -183,8 +183,10 @@ static void bt_app_rc_ct_cb(esp_avrc_ct_cb_event_t event, esp_avrc_ct_cb_param_t { switch (event) { case ESP_AVRC_CT_METADATA_RSP_EVT: { - bt_app_work_dispatch(bt_app_avrc_ct_evt_hdl, event, param, sizeof(esp_avrc_ct_cb_param_t), - bt_avrc_common_copy_metadata, bt_avrc_common_free_metadata); + if (!bt_app_work_dispatch(bt_app_avrc_ct_evt_hdl, event, param, sizeof(esp_avrc_ct_cb_param_t), + bt_avrc_common_copy_metadata, bt_avrc_common_free_metadata)) { + ESP_LOGE(BT_RC_CT_TAG, "CT event %d dispatch failed", event); + } break; } case ESP_AVRC_CT_CONNECTION_STATE_EVT: @@ -193,7 +195,9 @@ static void bt_app_rc_ct_cb(esp_avrc_ct_cb_event_t event, esp_avrc_ct_cb_param_t case ESP_AVRC_CT_REMOTE_FEATURES_EVT: case ESP_AVRC_CT_GET_RN_CAPABILITIES_RSP_EVT: case ESP_AVRC_CT_PROF_STATE_EVT: - bt_app_work_dispatch(bt_app_avrc_ct_evt_hdl, event, param, sizeof(esp_avrc_ct_cb_param_t), NULL, NULL); + if (!bt_app_work_dispatch(bt_app_avrc_ct_evt_hdl, event, param, sizeof(esp_avrc_ct_cb_param_t), NULL, NULL)) { + ESP_LOGE(BT_RC_CT_TAG, "CT event %d dispatch failed", event); + } break; default: ESP_LOGE(BT_RC_CT_TAG, "Invalid AVRC event: %d", event); @@ -211,7 +215,9 @@ static void bt_app_rc_tg_cb(esp_avrc_tg_cb_event_t event, esp_avrc_tg_cb_param_t case ESP_AVRC_TG_REGISTER_NOTIFICATION_EVT: case ESP_AVRC_TG_SET_PLAYER_APP_VALUE_EVT: case ESP_AVRC_TG_PROF_STATE_EVT: - bt_app_work_dispatch(bt_avrc_common_tg_evt_def_hdl, event, param, sizeof(esp_avrc_tg_cb_param_t), NULL, NULL); + if (!bt_app_work_dispatch(bt_avrc_common_tg_evt_def_hdl, event, param, sizeof(esp_avrc_tg_cb_param_t), NULL, NULL)) { + ESP_LOGE(BT_RC_TG_TAG, "TG event %d dispatch failed", event); + } break; default: ESP_LOGE(BT_RC_TG_TAG, "Invalid AVRC event: %d", event); diff --git a/examples/bluetooth/bluedroid/classic_bt/common/bt_app_core_utils/bt_app_core_utils.c b/examples/bluetooth/bluedroid/classic_bt/common/bt_app_core_utils/bt_app_core_utils.c index ae9e01cac2a..b79bef80339 100644 --- a/examples/bluetooth/bluedroid/classic_bt/common/bt_app_core_utils/bt_app_core_utils.c +++ b/examples/bluetooth/bluedroid/classic_bt/common/bt_app_core_utils/bt_app_core_utils.c @@ -7,8 +7,11 @@ #include #include #include +#include +#include #include "esp_log.h" +#include "esp_system.h" #include "freertos/FreeRTOSConfig.h" #include "freertos/FreeRTOS.h" @@ -45,6 +48,7 @@ static TaskHandle_t s_bt_app_task_handle = NULL; /* handle of application task static bool bt_app_send_msg(bt_app_msg_t *msg) { if (msg == NULL || s_bt_app_task_queue == NULL) { + ESP_LOGE(BT_APP_CORE_TAG, "%s failed: msg=%p, queue=%p", __func__, msg, s_bt_app_task_queue); return false; } @@ -126,6 +130,11 @@ bool bt_app_work_dispatch(bt_app_cb_t p_cback, uint16_t event, void *p_params, i } return true; } + ESP_LOGE(BT_APP_CORE_TAG, "%s malloc failed, event: 0x%x, param_len: %d, free_heap: %" PRIu32, + __func__, event, param_len, esp_get_free_heap_size()); + } else { + ESP_LOGE(BT_APP_CORE_TAG, "%s invalid args, event: 0x%x, p_params: %p, param_len: %d", + __func__, event, p_params, param_len); } return false;