From b78cd855b8ddc3469c816d46387f091907152112 Mon Sep 17 00:00:00 2001 From: Emil Gydesen Date: Mon, 3 Jan 2022 13:39:57 +0100 Subject: [PATCH] Bluetooth: GATT: Add BT_GATT_WRITE_FLAG_EXECUTE flag Add the BT_GATT_WRITE_FLAG_EXECUTE flag that indicates whether a write callback is from an ATT execute write. Signed-off-by: Emil Gydesen --- include/bluetooth/gatt.h | 8 ++++++++ subsys/bluetooth/host/att.c | 2 ++ 2 files changed, 10 insertions(+) diff --git a/include/bluetooth/gatt.h b/include/bluetooth/gatt.h index cdd58ca895f..08366b8d052 100644 --- a/include/bluetooth/gatt.h +++ b/include/bluetooth/gatt.h @@ -98,6 +98,14 @@ enum { * response) which doesn't generate any response. */ BT_GATT_WRITE_FLAG_CMD = BIT(1), + + /** @brief Attribute write execute flag + * + * If set, indicates that write operation is a execute, which indicates + * the end of a long write, and will come after 1 or more + * @ref BT_GATT_WRITE_FLAG_PREPARE. + */ + BT_GATT_WRITE_FLAG_EXECUTE = BIT(2), }; /** @brief GATT Attribute structure. */ diff --git a/subsys/bluetooth/host/att.c b/subsys/bluetooth/host/att.c index f225b42008b..dfcb10daf18 100644 --- a/subsys/bluetooth/host/att.c +++ b/subsys/bluetooth/host/att.c @@ -1666,6 +1666,8 @@ static uint8_t write_cb(const struct bt_gatt_attr *attr, uint16_t handle, /* Set command flag if not a request */ if (!data->req) { flags |= BT_GATT_WRITE_FLAG_CMD; + } else if (data->req == BT_ATT_OP_EXEC_WRITE_REQ) { + flags |= BT_GATT_WRITE_FLAG_EXECUTE; } /* Write attribute value */