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: Joakim Andersson <joakim.andersson@nordicsemi.no>
This commit is contained in:
Joakim Andersson 2020-12-18 21:13:40 +01:00 committed by Anas Nashif
commit 75deefb1b2

View file

@ -1900,8 +1900,11 @@ static void gatt_indicate_rsp(struct bt_conn *conn, uint8_t err,
{
struct bt_gatt_indicate_params *params = user_data;
if (params->func) {
params->func(conn, params, err);
}
params->_ref--;
params->func(conn, params, err);
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);
}