Bluetooth: Gatt: Added write callback for gatt (un)subscribe

Added a callback that lets an application get write error
(if any) when subscribing to a gatt characteristic.

Signed-off-by: Emil Gydesen <emil_gydesen@bose.com>
This commit is contained in:
Emil Gydesen 2020-06-23 13:34:01 +02:00 committed by Carles Cufí
commit 9bf50ddb20
2 changed files with 6 additions and 0 deletions

View file

@ -1401,6 +1401,8 @@ enum {
struct bt_gatt_subscribe_params {
/** Notification value callback */
bt_gatt_notify_func_t notify;
/** Subscribe CCC write request response callback */
bt_gatt_write_func_t write;
/** Subscribe value handle */
uint16_t value_handle;
/** Subscribe CCC handle */

View file

@ -3929,6 +3929,10 @@ static void gatt_write_ccc_rsp(struct bt_conn *conn, uint8_t err,
/* Notify with NULL data to complete unsubscribe */
params->notify(conn, params, NULL, 0);
}
if (params->write) {
params->write(conn, err, NULL);
}
}
static int gatt_write_ccc(struct bt_conn *conn, uint16_t handle, uint16_t value,