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 ab231ad8c6d..9dce7417070 100644 --- a/components/bt/host/bluedroid/bta/gatt/bta_gattc_act.c +++ b/components/bt/host/bluedroid/bta/gatt/bta_gattc_act.c @@ -2264,12 +2264,14 @@ void bta_gattc_process_indicate(UINT16 conn_id, tGATTC_OPTYPE op, tGATT_CL_COMPL bta_gattc_proc_other_indication(p_clcb, op, p_data, ¬ify); } } else { - /* No app registered for this handle: drop the PDU, but log it - * so the common "registered a wrong handle" bug is visible - * instead of silently failing. */ - APPL_TRACE_WARNING("drop %s, handle 0x%04x not registered", - (op == GATTC_OPTYPE_INDICATION) ? "ind" : "notif", - handle); + /* GATT stack broadcasts notif/ind to every client app; drop here + * when this gatt_if did not register. Only warn if no app at all + * registered for the handle (likely wrong handle). */ + if (!bta_gattc_any_notif_registry(p_srcb, ¬ify)) { + APPL_TRACE_WARNING("drop %s, handle 0x%04x not registered", + (op == GATTC_OPTYPE_INDICATION) ? "ind" : "notif", + handle); + } if (op == GATTC_OPTYPE_INDICATION) { GATTC_SendHandleValueConfirm(conn_id, handle); } diff --git a/components/bt/host/bluedroid/bta/gatt/bta_gattc_utils.c b/components/bt/host/bluedroid/bta/gatt/bta_gattc_utils.c index 3d360c652a0..332bf33e6da 100644 --- a/components/bt/host/bluedroid/bta/gatt/bta_gattc_utils.c +++ b/components/bt/host/bluedroid/bta/gatt/bta_gattc_utils.c @@ -668,6 +668,29 @@ BOOLEAN bta_gattc_check_notif_registry(tBTA_GATTC_RCB *p_clreg, tBTA_GATTC_SERV return FALSE; } + +/******************************************************************************* +** +** Function bta_gattc_any_notif_registry +** +** Description check if any GATT client app registered for the notification. +** +** Returns TRUE if any app registered, FALSE otherwise. +** +*******************************************************************************/ +BOOLEAN bta_gattc_any_notif_registry(tBTA_GATTC_SERV *p_srcb, tBTA_GATTC_NOTIFY *p_notify) +{ + UINT8 i; + + for (i = 0; i < BTA_GATTC_CL_MAX; i++) { + if (bta_gattc_cb.cl_rcb[i].in_use && + bta_gattc_check_notif_registry(&bta_gattc_cb.cl_rcb[i], p_srcb, p_notify)) { + return TRUE; + } + } + return FALSE; +} + /******************************************************************************* ** ** Function bta_gattc_clear_notif_registration diff --git a/components/bt/host/bluedroid/bta/gatt/include/bta_gattc_int.h b/components/bt/host/bluedroid/bta/gatt/include/bta_gattc_int.h index 1c22f44ac81..770d38456fa 100644 --- a/components/bt/host/bluedroid/bta/gatt/include/bta_gattc_int.h +++ b/components/bt/host/bluedroid/bta/gatt/include/bta_gattc_int.h @@ -523,6 +523,7 @@ extern BOOLEAN bta_gattc_enqueue(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_dat extern BOOLEAN bta_gattc_uuid_compare (const tBT_UUID *p_src, const tBT_UUID *p_tar, BOOLEAN is_precise); extern BOOLEAN bta_gattc_check_notif_registry(tBTA_GATTC_RCB *p_clreg, tBTA_GATTC_SERV *p_srcb, tBTA_GATTC_NOTIFY *p_notify); +extern BOOLEAN bta_gattc_any_notif_registry(tBTA_GATTC_SERV *p_srcb, tBTA_GATTC_NOTIFY *p_notify); extern BOOLEAN bta_gattc_mark_bg_conn (tBTA_GATTC_IF client_if, BD_ADDR_PTR remote_bda, BOOLEAN add, BOOLEAN is_listen); extern BOOLEAN bta_gattc_check_bg_conn (tBTA_GATTC_IF client_if, BD_ADDR remote_bda, UINT8 role); extern UINT8 bta_gattc_num_reg_app(void);