From 25e80695329552613e019354cd8fc9412bab2f04 Mon Sep 17 00:00:00 2001 From: xiongweichao Date: Tue, 25 Apr 2023 15:39:38 +0800 Subject: [PATCH] bt: Fixed the inconsistency between the indicator event received by the HF application layer and the actually received indicator. Closes https://github.com/espressif/esp-idf/issues/6486 --- .../bt/host/bluedroid/bta/hf_client/bta_hf_client_at.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/components/bt/host/bluedroid/bta/hf_client/bta_hf_client_at.c b/components/bt/host/bluedroid/bta/hf_client/bta_hf_client_at.c index d526be99fc..adf3d609d0 100644 --- a/components/bt/host/bluedroid/bta/hf_client/bta_hf_client_at.c +++ b/components/bt/host/bluedroid/bta/hf_client/bta_hf_client_at.c @@ -427,7 +427,8 @@ static void bta_hf_client_handle_ciev(UINT32 index, UINT32 value) APPL_TRACE_DEBUG("%s index: %u value: %u", __FUNCTION__, index, value); - if (index >= BTA_HF_CLIENT_AT_INDICATOR_COUNT) { + if (index == 0 || index > BTA_HF_CLIENT_AT_INDICATOR_COUNT) { + APPL_TRACE_WARNING("%s: Invalid index %d", __FUNCTION__, index); return; } @@ -435,7 +436,7 @@ static void bta_hf_client_handle_ciev(UINT32 index, UINT32 value) service_availability = value == 0 ? FALSE : TRUE; } - realind = bta_hf_client_cb.scb.at_cb.indicator_lookup[index]; + realind = bta_hf_client_cb.scb.at_cb.indicator_lookup[index - 1]; if (realind >= 0 && realind < BTA_HF_CLIENT_AT_SUPPORTED_INDICATOR_COUNT) { /* get the real in-array index from lookup table by index it comes at */