From 11bdcf82941c6c967c8c6e13d17cb91ea79b8e3f 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 41b6db2d184..58ca35062f3 100644 --- a/components/bt/host/bluedroid/stack/gatt/gatt_sr.c +++ b/components/bt/host/bluedroid/stack/gatt/gatt_sr.c @@ -476,10 +476,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);