Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bluetooth: host: gatt: consolidate net_buf_add call #82896

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions subsys/bluetooth/host/gatt.c
Original file line number Diff line number Diff line change
Expand Up @@ -2417,11 +2417,9 @@ static void gatt_add_nfy_to_buf(struct net_buf *buf,
{
struct bt_att_notify_mult *nfy;

nfy = net_buf_add(buf, sizeof(*nfy));
nfy = net_buf_add(buf, sizeof(*nfy) + params->len);
nfy->handle = sys_cpu_to_le16(handle);
nfy->len = sys_cpu_to_le16(params->len);

net_buf_add(buf, params->len);
(void)memcpy(nfy->value, params->data, params->len);
}

Expand Down Expand Up @@ -2532,10 +2530,8 @@ static int gatt_notify(struct bt_conn *conn, uint16_t handle,

LOG_DBG("conn %p handle 0x%04x", conn, handle);

nfy = net_buf_add(buf, sizeof(*nfy));
nfy = net_buf_add(buf, sizeof(*nfy) + params->len);
nfy->handle = sys_cpu_to_le16(handle);

net_buf_add(buf, params->len);
memcpy(nfy->value, params->data, params->len);

bt_att_set_tx_meta_data(buf, params->func, params->user_data, BT_ATT_CHAN_OPT(params));
Expand Down Expand Up @@ -2700,10 +2696,8 @@ static int gatt_indicate(struct bt_conn *conn, uint16_t handle,

bt_att_set_tx_meta_data(buf, NULL, NULL, BT_ATT_CHAN_OPT(params));

ind = net_buf_add(buf, sizeof(*ind));
ind = net_buf_add(buf, sizeof(*ind) + params->len);
ind->handle = sys_cpu_to_le16(handle);

net_buf_add(buf, params->len);
memcpy(ind->value, params->data, params->len);

LOG_DBG("conn %p handle 0x%04x", conn, handle);
Expand Down
Loading