From 4c0488d92a51f33f3353636b08eb9b3fbb063b92 Mon Sep 17 00:00:00 2001 From: zhanghaipeng Date: Thu, 2 Jul 2026 16:02:41 +0800 Subject: [PATCH] fix(ble/bluedroid): use sr_cmd status for GATT server error rsp When sending an ATT error response after a failed server operation, use p_tcb->sr_cmd.status instead of the last app callback status so invalid error code 0x00 is not sent to the peer. --- components/bt/host/bluedroid/stack/gatt/gatt_sr.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/components/bt/host/bluedroid/stack/gatt/gatt_sr.c b/components/bt/host/bluedroid/stack/gatt/gatt_sr.c index bc2ca32147d..1c4b0b3a890 100644 --- a/components/bt/host/bluedroid/stack/gatt/gatt_sr.c +++ b/components/bt/host/bluedroid/stack/gatt/gatt_sr.c @@ -480,10 +480,12 @@ tGATT_STATUS gatt_sr_process_app_rsp (tGATT_TCB *p_tcb, tGATT_IF gatt_if, ret_code = attp_send_sr_msg (p_tcb, p_tcb->sr_cmd.p_rsp_msg); p_tcb->sr_cmd.p_rsp_msg = NULL; } else { - if (p_tcb->sr_cmd.status == GATT_SUCCESS){ - status = GATT_UNKNOWN_ERROR; + tGATT_STATUS err_status = p_tcb->sr_cmd.status; + + if (err_status == GATT_SUCCESS) { + err_status = GATT_UNKNOWN_ERROR; } - ret_code = gatt_send_error_rsp (p_tcb, status, op_code, p_tcb->sr_cmd.handle, FALSE); + ret_code = gatt_send_error_rsp (p_tcb, err_status, op_code, p_tcb->sr_cmd.handle, FALSE); } gatt_dequeue_sr_cmd(p_tcb);