Bluetooth: GATT: Add bt_gatt_write_without_response
This split the use of ATT Write Command and ATT Write Request since with the former it is possible to sign the data thus making combinations of parameters in bt_gatt_write complex/confusing. Change-Id: I0349acd16d22ea4e38ac3e5ad8c3cdc318851633 Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This commit is contained in:
parent
1d55b64fdf
commit
c6c89a8529
2 changed files with 23 additions and 8 deletions
|
@ -746,7 +746,7 @@ int bt_gatt_read(struct bt_conn *conn, uint16_t handle, uint16_t offset,
|
||||||
/** @brief Write Attribute Value by handle
|
/** @brief Write Attribute Value by handle
|
||||||
*
|
*
|
||||||
* This procedure write the attribute value and return the result in the
|
* This procedure write the attribute value and return the result in the
|
||||||
* callback in case it is set.
|
* callback.
|
||||||
*
|
*
|
||||||
* @param conn Connection object.
|
* @param conn Connection object.
|
||||||
* @param handle Attribute handle.
|
* @param handle Attribute handle.
|
||||||
|
@ -760,6 +760,21 @@ int bt_gatt_read(struct bt_conn *conn, uint16_t handle, uint16_t offset,
|
||||||
int bt_gatt_write(struct bt_conn *conn, uint16_t handle, uint16_t offset,
|
int bt_gatt_write(struct bt_conn *conn, uint16_t handle, uint16_t offset,
|
||||||
const void *data, uint16_t length, bt_gatt_rsp_func_t func);
|
const void *data, uint16_t length, bt_gatt_rsp_func_t func);
|
||||||
|
|
||||||
|
/** @brief Write Attribute Value by handle without reponse
|
||||||
|
*
|
||||||
|
* This procedure write the attribute value without requiring an
|
||||||
|
* acknowledgement that the write was successfully performed
|
||||||
|
*
|
||||||
|
* @param conn Connection object.
|
||||||
|
* @param handle Attribute handle.
|
||||||
|
* @param data Data to be written.
|
||||||
|
* @param length Data length.
|
||||||
|
*
|
||||||
|
* @return 0 in case of success or negative value in case of error.
|
||||||
|
*/
|
||||||
|
int bt_gatt_write_without_response(struct bt_conn *conn, uint16_t handle,
|
||||||
|
const void *data, uint16_t length);
|
||||||
|
|
||||||
/** @brief GATT Subscribe parameters */
|
/** @brief GATT Subscribe parameters */
|
||||||
struct bt_gatt_subscribe_params {
|
struct bt_gatt_subscribe_params {
|
||||||
bt_addr_le_t _peer;
|
bt_addr_le_t _peer;
|
||||||
|
|
|
@ -985,12 +985,16 @@ static void att_write_rsp(struct bt_conn *conn, uint8_t err, const void *pdu,
|
||||||
func(conn, err);
|
func(conn, err);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int gatt_write_cmd(struct bt_conn *conn, uint16_t handle,
|
int bt_gatt_write_without_response(struct bt_conn *conn, uint16_t handle,
|
||||||
const void *data, uint16_t length)
|
const void *data, uint16_t length)
|
||||||
{
|
{
|
||||||
struct bt_buf *buf;
|
struct bt_buf *buf;
|
||||||
struct bt_att_write_cmd *cmd;
|
struct bt_att_write_cmd *cmd;
|
||||||
|
|
||||||
|
if (!conn || !handle) {
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
buf = bt_att_create_pdu(conn, BT_ATT_OP_WRITE_CMD,
|
buf = bt_att_create_pdu(conn, BT_ATT_OP_WRITE_CMD,
|
||||||
sizeof(*cmd) + length);
|
sizeof(*cmd) + length);
|
||||||
if (!buf) {
|
if (!buf) {
|
||||||
|
@ -1106,7 +1110,7 @@ int bt_gatt_write(struct bt_conn *conn, uint16_t handle, uint16_t offset,
|
||||||
struct bt_buf *buf;
|
struct bt_buf *buf;
|
||||||
struct bt_att_write_req *req;
|
struct bt_att_write_req *req;
|
||||||
|
|
||||||
if (!conn || !handle) {
|
if (!conn || !handle || !func) {
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1116,10 +1120,6 @@ int bt_gatt_write(struct bt_conn *conn, uint16_t handle, uint16_t offset,
|
||||||
func);
|
func);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!func) {
|
|
||||||
return gatt_write_cmd(conn, handle, data, length);
|
|
||||||
}
|
|
||||||
|
|
||||||
buf = bt_att_create_pdu(conn, BT_ATT_OP_WRITE_REQ,
|
buf = bt_att_create_pdu(conn, BT_ATT_OP_WRITE_REQ,
|
||||||
sizeof(*req) + length);
|
sizeof(*req) + length);
|
||||||
if (!buf) {
|
if (!buf) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue