Bluetooth: GATT: Add bt_gatt_write_response_cb
This adds bt_gatt_write_response_cb works similarly to bt_gatt_notify_cb which can take a callback to be called when the PDU is considered transmitted over the air. Note: This can also be used to disable the ATT flow control which would blocks sending multiple commands without wainting their transmissions. Fixes #11558 Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This commit is contained in:
parent
c01535c735
commit
a779705f16
4 changed files with 53 additions and 23 deletions
|
@ -697,7 +697,7 @@ ssize_t bt_gatt_attr_read_cpf(struct bt_conn *conn,
|
|||
*
|
||||
* @param conn Connection object.
|
||||
*/
|
||||
typedef void (*bt_gatt_notify_complete_func_t) (struct bt_conn *conn);
|
||||
typedef void (*bt_gatt_complete_func_t) (struct bt_conn *conn);
|
||||
|
||||
/** @brief Notify attribute value change with callback.
|
||||
*
|
||||
|
@ -713,7 +713,7 @@ typedef void (*bt_gatt_notify_complete_func_t) (struct bt_conn *conn);
|
|||
*/
|
||||
int bt_gatt_notify_cb(struct bt_conn *conn, const struct bt_gatt_attr *attr,
|
||||
const void *data, u16_t len,
|
||||
bt_gatt_notify_complete_func_t func);
|
||||
bt_gatt_complete_func_t func);
|
||||
|
||||
/** @brief Notify attribute value change.
|
||||
*
|
||||
|
@ -999,6 +999,30 @@ struct bt_gatt_write_params {
|
|||
*/
|
||||
int bt_gatt_write(struct bt_conn *conn, struct bt_gatt_write_params *params);
|
||||
|
||||
/** @brief Write Attribute Value by handle without response with callback.
|
||||
*
|
||||
* This function works in the same way as @ref bt_gatt_write_without_response.
|
||||
* With the addition that after sending the write the callback function will be
|
||||
* called.
|
||||
*
|
||||
* Note: By using a callback it also disable the internal flow control
|
||||
* which would prevent sending multiple commands without wainting their
|
||||
* transmissions to complete, so if that is required the caller shall not
|
||||
* submit more data until the callback is called.
|
||||
*
|
||||
* @param conn Connection object.
|
||||
* @param handle Attribute handle.
|
||||
* @param data Data to be written.
|
||||
* @param length Data length.
|
||||
* @param sign Whether to sign data
|
||||
* @param func Transmission complete callback.
|
||||
*
|
||||
* @return 0 in case of success or negative value in case of error.
|
||||
*/
|
||||
int bt_gatt_write_without_response_cb(struct bt_conn *conn, u16_t handle,
|
||||
const void *data, u16_t length,
|
||||
bool sign, bt_gatt_complete_func_t func);
|
||||
|
||||
/** @brief Write Attribute Value by handle without response
|
||||
*
|
||||
* This procedure write the attribute value without requiring an
|
||||
|
@ -1012,9 +1036,13 @@ int bt_gatt_write(struct bt_conn *conn, struct bt_gatt_write_params *params);
|
|||
*
|
||||
* @return 0 in case of success or negative value in case of error.
|
||||
*/
|
||||
int bt_gatt_write_without_response(struct bt_conn *conn, u16_t handle,
|
||||
const void *data, u16_t length,
|
||||
bool sign);
|
||||
static inline int bt_gatt_write_without_response(struct bt_conn *conn,
|
||||
u16_t handle, const void *data,
|
||||
u16_t length, bool sign)
|
||||
{
|
||||
return bt_gatt_write_without_response_cb(conn, handle, data, length,
|
||||
sign, NULL);
|
||||
}
|
||||
|
||||
struct bt_gatt_subscribe_params;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue