Commit 170f17e0 authored by Jordan Yates's avatar Jordan Yates Committed by Carles Cufi
Browse files

Bluetooth: indication callback signature update



Update the signature of the `bt_gatt_indicate_func_t` callback type by
replacing the attr pointer with a pointer to the
`bt_gatt_indicate_params` struct that was used to start the indication.

This allows the callback to free the `bt_gatt_indicate_params` instance
if it was allocated from storage, while still allowing the
`bt_gatt_attr` value to be accessed through `params->attr`.

Allocating the `bt_gatt_indicate_params` instance from storage is
desirable as multiple indications can be queued, however each instance
must be valid until the callback is run.

Implements API update from #29357

Signed-off-by: default avatarJordan Yates <jordan.yates@data61.csiro.au>
parent e51226b8
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -999,15 +999,18 @@ static inline int bt_gatt_notify_uuid(struct bt_conn *conn,
	return bt_gatt_notify_cb(conn, &params);
}

/* Forward declaration of the bt_gatt_indicate_params structure */
struct bt_gatt_indicate_params;

/** @typedef bt_gatt_indicate_func_t
 *  @brief Indication complete result callback.
 *
 *  @param conn Connection object.
 *  @param attr Attribute object.
 *  @param params Indication params object.
 *  @param err ATT error code
 */
typedef void (*bt_gatt_indicate_func_t)(struct bt_conn *conn,
					const struct bt_gatt_attr *attr,
					struct bt_gatt_indicate_params *params,
					uint8_t err);

/** @brief GATT Indicate Value parameters */
+2 −2
Original line number Diff line number Diff line
@@ -74,8 +74,8 @@ static void vnd_ccc_cfg_changed(const struct bt_gatt_attr *attr, uint16_t value)
	simulate_vnd = (value == BT_GATT_CCC_INDICATE) ? 1 : 0;
}

static void indicate_cb(struct bt_conn *conn, const struct bt_gatt_attr *attr,
			uint8_t err)
static void indicate_cb(struct bt_conn *conn,
			struct bt_gatt_indicate_params *params, uint8_t err)
{
	printk("Indication %s\n", err != 0U ? "fail" : "success");
	indicating = 0U;
+2 −2
Original line number Diff line number Diff line
@@ -37,8 +37,8 @@ static void htmc_ccc_cfg_changed(const struct bt_gatt_attr *attr,
	simulate_htm = (value == BT_GATT_CCC_INDICATE) ? 1 : 0;
}

static void indicate_cb(struct bt_conn *conn, const struct bt_gatt_attr *attr,
			uint8_t err)
static void indicate_cb(struct bt_conn *conn,
			struct bt_gatt_indicate_params *params, uint8_t err)
{
	printk("Indication %s\n", err != 0U ? "fail" : "success");
	indicating = 0U;
+3 −3
Original line number Diff line number Diff line
@@ -904,7 +904,7 @@ static inline void sc_work_submit(k_timeout_t timeout)

#if defined(CONFIG_BT_GATT_SERVICE_CHANGED)
static void sc_indicate_rsp(struct bt_conn *conn,
			    const struct bt_gatt_attr *attr, uint8_t err)
			    struct bt_gatt_indicate_params *params, uint8_t err)
{
#if defined(CONFIG_BT_GATT_CACHING)
	struct gatt_cf_cfg *cfg;
@@ -1900,7 +1900,7 @@ static void gatt_indicate_rsp(struct bt_conn *conn, uint8_t err,
{
	struct bt_gatt_indicate_params *params = user_data;

	params->func(conn, params->attr, err);
	params->func(conn, params, err);
}

static int gatt_send(struct bt_conn *conn, struct net_buf *buf,
@@ -2268,7 +2268,7 @@ uint8_t bt_gatt_check_perm(struct bt_conn *conn, const struct bt_gatt_attr *attr
}

static void sc_restore_rsp(struct bt_conn *conn,
			   const struct bt_gatt_attr *attr, uint8_t err)
			   struct bt_gatt_indicate_params *params, uint8_t err)
{
#if defined(CONFIG_BT_GATT_CACHING)
	struct gatt_cf_cfg *cfg;
+2 −2
Original line number Diff line number Diff line
@@ -241,10 +241,10 @@ static void oacp_read_proc_execute(struct bt_ots *ots,
}

static void oacp_ind_cb(struct bt_conn *conn,
			const struct bt_gatt_attr *attr,
			struct bt_gatt_indicate_params *params,
			uint8_t err)
{
	struct bt_ots *ots = (struct bt_ots *) attr->user_data;
	struct bt_ots *ots = (struct bt_ots *) params->attr->user_data;

	LOG_DBG("Received OACP Indication ACK with status: 0x%04X", err);

Loading