From ede13428e74736730e8184701baab196e291a7ae Mon Sep 17 00:00:00 2001 From: Luiz Augusto von Dentz Date: Fri, 26 Jun 2020 09:35:09 -0700 Subject: [PATCH] Bluetooth: GATT: Fix not being able to notify When CONFIG_BT_GATT_NOTIFY_MULTIPLE is selected and the remote has enabled support for using its procedure data can sometimes not fit into the buffer since the multiple variant has a bigger header, so instead of failing immediatelly this attempts to send the data using the legacy PDU instead so those using bt_gatt_get_mtu - 3 can still be sent. Fixes #26106 Signed-off-by: Luiz Augusto von Dentz --- subsys/bluetooth/host/gatt.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/subsys/bluetooth/host/gatt.c b/subsys/bluetooth/host/gatt.c index 14a07ddab42..b523ee2f985 100644 --- a/subsys/bluetooth/host/gatt.c +++ b/subsys/bluetooth/host/gatt.c @@ -1720,7 +1720,6 @@ static int gatt_notify_mult(struct bt_conn *conn, uint16_t handle, *buf = bt_att_create_pdu(conn, BT_ATT_OP_NOTIFY_MULT, sizeof(*nfy) + params->len); if (!*buf) { - BT_WARN("No buffer available to send notification"); return -ENOMEM; } /* Set user_data so it can be restored when sending */ @@ -1762,7 +1761,12 @@ static int gatt_notify(struct bt_conn *conn, uint16_t handle, #if defined(CONFIG_BT_GATT_NOTIFY_MULTIPLE) if (gatt_cf_notify_multi(conn)) { - return gatt_notify_mult(conn, handle, params); + int err; + + err = gatt_notify_mult(conn, handle, params); + if (err && err != -ENOMEM) { + return err; + } } #endif /* CONFIG_BT_GATT_NOTIFY_MULTIPLE */