Bluetooth: SDP: Enable resolve all user delivered UUIDs

Iterates all UUID params list delivered by user. When iteration finish
release SDP client L2CAP transport channel.

Jira: ZEP-1112

Change-Id: I0602e32a5296a05719ad1385b4aff537350b3e7d
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
This commit is contained in:
Arkadiusz Lichwa 2016-12-21 16:49:31 +01:00 committed by Johan Hedberg
commit 7c6063c4ec

View file

@ -428,6 +428,39 @@ static int sdp_client_ssa_search(struct bt_sdp_client *session)
return bt_l2cap_chan_send(&session->chan.chan, buf);
}
static void sdp_client_params_iterator(struct bt_sdp_client *session)
{
struct bt_l2cap_chan *chan = &session->chan.chan;
const struct bt_sdp_discover_params *param;
sys_snode_t *node, *node_s;
SYS_SLIST_FOR_EACH_NODE_SAFE(&session->reqs, node, node_s) {
param = GET_PARAM(node);
if (param != session->param) {
continue;
}
BT_DBG("");
/* Remove already checked UUID node */
sys_slist_remove(&session->reqs, NULL, node);
/* Invalidate cached param in context */
session->param = NULL;
/* Reset continuation state in current context */
memset(&session->cstate, 0, sizeof(session->cstate));
/* Check if there's valid next UUID */
if (!sys_slist_is_empty(&session->reqs)) {
sdp_client_ssa_search(session);
return;
}
/* No UUID items, disconnect channel */
bt_l2cap_chan_disconnect(chan);
break;
}
}
static void sdp_client_receive(struct bt_l2cap_chan *chan, struct net_buf *buf)
{
struct bt_sdp_client *session = SDP_CLIENT_CHAN(chan);
@ -485,7 +518,7 @@ static void sdp_client_receive(struct bt_l2cap_chan *chan, struct net_buf *buf)
/* Call user UUID handler */
session->param->func(conn, NULL);
net_buf_pull(buf, frame_len + sizeof(cstate->length));
break;
goto iterate;
}
/* TO DO: fillup user buffer with record's data */
@ -510,6 +543,11 @@ 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));
iterate:
/* Get next UUID and start resolving it */
sdp_client_params_iterator(session);
break;
default:
BT_DBG("PDU 0x%0x response not handled", hdr->op_code);