Commit 75deefb1 authored by Joakim Andersson's avatar Joakim Andersson Committed by Anas Nashif
Browse files

Bluetooth: host: Fix indicate without user callback



Fix indicate without func not working properly, when sent as a
non-req by GATT this has two propblems:
 - The indicate would not be treated as a transaction, and back
   to back indicate would be sent without waiting for the confirm
 - The destroy callback would not be called on the indicate parameters
   since the indicate_rsp callback would not be called.

Signed-off-by: default avatarJoakim Andersson <joakim.andersson@nordicsemi.no>
parent 8df6124d
Loading
Loading
Loading
Loading
+4 −5
Original line number Diff line number Diff line
@@ -1900,8 +1900,11 @@ static void gatt_indicate_rsp(struct bt_conn *conn, uint8_t err,
{
	struct bt_gatt_indicate_params *params = user_data;

	params->_ref--;
	if (params->func) {
		params->func(conn, params, err);
	}

	params->_ref--;
	if (params->destroy && (params->_ref == 0)) {
		params->destroy(params);
	}
@@ -1976,10 +1979,6 @@ static int gatt_indicate(struct bt_conn *conn, uint16_t handle,
	net_buf_add(buf, params->len);
	memcpy(ind->value, params->data, params->len);

	if (!params->func) {
		return gatt_send(conn, buf, NULL, NULL, NULL);
	}

	return gatt_send(conn, buf, gatt_indicate_rsp, params, NULL);
}