Bluetooth: GATT: Add flag to indicate write command
Application may need to handle the write differently depending on the write operation so this adds a flag called BT_GATT_WRITE_FLAG_CMD which can then be checked by the callback, for instance one can respond with BT_ATT_ERR_WRITE_REQ_REJECTED when that flag is not set which should indicate to the client to use write command instead. Fixes #11206 Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This commit is contained in:
parent
ac31020deb
commit
ae05089946
2 changed files with 13 additions and 1 deletions
|
@ -91,6 +91,13 @@ enum {
|
|||
* authorized but no data shall be written.
|
||||
*/
|
||||
BT_GATT_WRITE_FLAG_PREPARE = BIT(0),
|
||||
|
||||
/** Attribute write command flag
|
||||
*
|
||||
* If set, indicates that write operation is a command (Write without
|
||||
* response) which doesn't generate any response.
|
||||
*/
|
||||
BT_GATT_WRITE_FLAG_CMD = BIT(1),
|
||||
};
|
||||
|
||||
/** @brief GATT Attribute structure. */
|
||||
|
|
|
@ -1199,6 +1199,7 @@ static u8_t write_cb(const struct bt_gatt_attr *attr, void *user_data)
|
|||
{
|
||||
struct write_data *data = user_data;
|
||||
int write;
|
||||
u8_t flags = 0;
|
||||
|
||||
BT_DBG("handle 0x%04x offset %u", attr->handle, data->offset);
|
||||
|
||||
|
@ -1208,9 +1209,13 @@ static u8_t write_cb(const struct bt_gatt_attr *attr, void *user_data)
|
|||
return BT_GATT_ITER_STOP;
|
||||
}
|
||||
|
||||
if (!data->op) {
|
||||
flags |= BT_GATT_WRITE_FLAG_CMD;
|
||||
}
|
||||
|
||||
/* Read attribute value and store in the buffer */
|
||||
write = attr->write(data->conn, attr, data->value, data->len,
|
||||
data->offset, 0);
|
||||
data->offset, flags);
|
||||
if (write < 0 || write != data->len) {
|
||||
data->err = err_to_att(write);
|
||||
return BT_GATT_ITER_STOP;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue