Bluetooth: SDP: Allocate user delivered memory for resolved data
Adds driven by user params buffer location to be populated by UUID resolved data. Corresponding handlers responsible for connected and disconnected states of L2CAP transport channel used by SDP PSM traffic automatically allocates and unrefs such memory. Data receiving handler performs buffer fill up. Jira: ZEP-1112 Change-Id: I8aa97e6e69344dca0f241a4e9097acac75e14a7c Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
This commit is contained in:
parent
3304cbc41b
commit
c97220c1d6
1 changed files with 21 additions and 1 deletions
|
@ -71,6 +71,8 @@ struct bt_sdp_client {
|
|||
const struct bt_sdp_discover_params *param;
|
||||
/* PDU continuation state object */
|
||||
struct bt_sdp_pdu_cstate cstate;
|
||||
/* buffer for collecting record data */
|
||||
struct net_buf *rec_buf;
|
||||
};
|
||||
|
||||
static struct bt_sdp_client bt_sdp_client_pool[CONFIG_BLUETOOTH_MAX_CONN];
|
||||
|
@ -532,7 +534,7 @@ static void sdp_client_receive(struct bt_l2cap_chan *chan, struct net_buf *buf)
|
|||
goto iterate;
|
||||
}
|
||||
|
||||
/* TO DO: fillup user buffer with record's data */
|
||||
net_buf_add_mem(session->rec_buf, buf->data, frame_len);
|
||||
|
||||
net_buf_pull(buf, frame_len);
|
||||
|
||||
|
@ -556,6 +558,8 @@ static void sdp_client_receive(struct bt_l2cap_chan *chan, struct net_buf *buf)
|
|||
net_buf_pull(buf, sizeof(cstate->length));
|
||||
|
||||
BT_DBG("UUID 0x%s resolved", bt_uuid_str(session->param->uuid));
|
||||
|
||||
/* TODO: Call user UUID callback with gathered SDP data */
|
||||
iterate:
|
||||
/* Get next UUID and start resolving it */
|
||||
sdp_client_params_iterator(session);
|
||||
|
@ -572,12 +576,25 @@ static int sdp_client_chan_connect(struct bt_sdp_client *session)
|
|||
&session->chan.chan, SDP_PSM);
|
||||
}
|
||||
|
||||
static struct net_buf *sdp_client_alloc_buf(struct bt_l2cap_chan *chan)
|
||||
{
|
||||
struct bt_sdp_client *session = SDP_CLIENT_CHAN(chan);
|
||||
|
||||
BT_DBG("session %p chan %p", session, chan);
|
||||
|
||||
session->param = GET_PARAM(sys_slist_peek_head(&session->reqs));
|
||||
|
||||
return net_buf_alloc(session->param->pool, K_FOREVER);
|
||||
}
|
||||
|
||||
static void sdp_client_connected(struct bt_l2cap_chan *chan)
|
||||
{
|
||||
struct bt_sdp_client *session = SDP_CLIENT_CHAN(chan);
|
||||
|
||||
BT_DBG("session %p chan %p connected", session, chan);
|
||||
|
||||
session->rec_buf = chan->ops->alloc_buf(chan);
|
||||
|
||||
sdp_client_ssa_search(session);
|
||||
}
|
||||
|
||||
|
@ -587,6 +604,8 @@ static void sdp_client_disconnected(struct bt_l2cap_chan *chan)
|
|||
|
||||
BT_DBG("session %p chan %p disconnected", session, chan);
|
||||
|
||||
net_buf_unref(session->rec_buf);
|
||||
|
||||
/*
|
||||
* Reset session excluding L2CAP channel member. Let's the channel
|
||||
* resets autonomous.
|
||||
|
@ -598,6 +617,7 @@ static struct bt_l2cap_chan_ops sdp_client_chan_ops = {
|
|||
.connected = sdp_client_connected,
|
||||
.disconnected = sdp_client_disconnected,
|
||||
.recv = sdp_client_receive,
|
||||
.alloc_buf = sdp_client_alloc_buf,
|
||||
};
|
||||
|
||||
static struct bt_sdp_client *sdp_client_new_session(struct bt_conn *conn)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue