From 78f1bd2ccff6afb1a89969ff71c9afad1c02953b Mon Sep 17 00:00:00 2001 From: Zhang Hai Peng Date: Fri, 26 Jun 2026 20:16:29 +0800 Subject: [PATCH] fix(ble/bluedroid): set REQ_WAITING before GATTC service-change rediscovery When service change cancels in-progress discovery, bta_gattc_disc_cmpl() re-triggers discovery without marking auto_update as REQ_WAITING. If a client command is queued in p_q_cmd, bta_gattc_start_discover() refuses to restart and the command is never dispatched. (cherry picked from commit 13926bb9bc7a36beb5f4b67709924c7fc9ae5aa1) Co-authored-by: zhanghaipeng --- components/bt/host/bluedroid/bta/gatt/bta_gattc_act.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 9dce7417070..1b17e58622a 100644 --- a/components/bt/host/bluedroid/bta/gatt/bta_gattc_act.c +++ b/components/bt/host/bluedroid/bta/gatt/bta_gattc_act.c @@ -1153,7 +1153,9 @@ void bta_gattc_disc_cmpl(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data) } if (p_clcb->auto_update == BTA_GATTC_DISC_WAITING) { - /* start discovery again */ + /* Service change arrived during discovery; restart even if p_q_cmd is set. + * Mirrors bta_gattc_op_cmpl(). */ + p_clcb->auto_update = BTA_GATTC_REQ_WAITING; bta_gattc_sm_execute(p_clcb, BTA_GATTC_INT_DISCOVER_EVT, NULL); } /* get any queued command to proceed */