Skip to content

Commit 80ceaf1

Browse files
committed
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 <[email protected]>
1 parent e680dc8 commit 80ceaf1

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

subsys/bluetooth/host/gatt.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1900,8 +1900,11 @@ static void gatt_indicate_rsp(struct bt_conn *conn, uint8_t err,
19001900
{
19011901
struct bt_gatt_indicate_params *params = user_data;
19021902

1903+
if (params->func) {
1904+
params->func(conn, params, err);
1905+
}
1906+
19031907
params->_ref--;
1904-
params->func(conn, params, err);
19051908
if (params->destroy && (params->_ref == 0)) {
19061909
params->destroy(params);
19071910
}
@@ -1976,10 +1979,6 @@ static int gatt_indicate(struct bt_conn *conn, uint16_t handle,
19761979
net_buf_add(buf, params->len);
19771980
memcpy(ind->value, params->data, params->len);
19781981

1979-
if (!params->func) {
1980-
return gatt_send(conn, buf, NULL, NULL, NULL);
1981-
}
1982-
19831982
return gatt_send(conn, buf, gatt_indicate_rsp, params, NULL);
19841983
}
19851984

0 commit comments

Comments
 (0)