How to Receive 100bytes of data with net_buf_simple_pull_mem( ) over ble-mesh

Hi,

I am transferring 100 bytes of data via BLE-Mesh from a vendor client model, which I need to receive in my vendor server model.

I referred to nCS provided chat sample, where I noticed below data extraction code:

static const uint8_t *extract_msg(struct net_buf_simple *buf)
{
	buf->data[buf->len - 1] = '\0';
	return net_buf_simple_pull_mem(buf, buf->len);
}

static int handle_message(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx,
			  struct net_buf_simple *buf)
{
	struct bt_mesh_chat_cli *chat = model->user_data;
	const uint8_t *msg;

	msg = extract_msg(buf);

	if (chat->handlers->message) {
		chat->handlers->message(chat, ctx, msg);
	}

	return 0;
}

My questions are:

  1. What's the max len of data buffer that can be received.?
  2. How do I modify the size of data buffer..? I couldn't find where the net_buf_simple struct field for size buf->len is being set.
  3. How would the usage of net_buf_simple_pull_mem( ) look like to pull 100bytes..?
  4. This 100bytes data, can I typecast into my user structure to populate struct fields..?

Thanks,

Ubaid

Parents Reply Children
No Data
Related