Lines Matching refs:session

1483 static int sdp_client_ss_search(struct bt_sdp_client *session,  in sdp_client_ss_search()  argument
1519 net_buf_add_be16(buf, net_buf_tailroom(session->rec_buf) / SDP_RECORD_HANDLE_SIZE); in sdp_client_ss_search()
1526 if (session->cstate.length == 0U) { in sdp_client_ss_search()
1529 net_buf_add_u8(buf, session->cstate.length); in sdp_client_ss_search()
1530 net_buf_add_mem(buf, session->cstate.data, session->cstate.length); in sdp_client_ss_search()
1534 session->param = param; in sdp_client_ss_search()
1535 session->tid++; in sdp_client_ss_search()
1537 return bt_sdp_send(&session->chan.chan, buf, BT_SDP_SVC_SEARCH_REQ, session->tid); in sdp_client_ss_search()
1541 static int sdp_client_sa_search(struct bt_sdp_client *session, in sdp_client_sa_search() argument
1552 net_buf_add_be16(buf, net_buf_tailroom(session->rec_buf)); in sdp_client_sa_search()
1571 if (session->cstate.length == 0U) { in sdp_client_sa_search()
1574 net_buf_add_u8(buf, session->cstate.length); in sdp_client_sa_search()
1575 net_buf_add_mem(buf, session->cstate.data, session->cstate.length); in sdp_client_sa_search()
1579 session->param = param; in sdp_client_sa_search()
1580 session->tid++; in sdp_client_sa_search()
1582 return bt_sdp_send(&session->chan.chan, buf, BT_SDP_SVC_ATTR_REQ, session->tid); in sdp_client_sa_search()
1586 static int sdp_client_ssa_search(struct bt_sdp_client *session, in sdp_client_ssa_search() argument
1622 net_buf_add_be16(buf, net_buf_tailroom(session->rec_buf)); in sdp_client_ssa_search()
1641 if (session->cstate.length == 0U) { in sdp_client_ssa_search()
1644 net_buf_add_u8(buf, session->cstate.length); in sdp_client_ssa_search()
1645 net_buf_add_mem(buf, session->cstate.data, in sdp_client_ssa_search()
1646 session->cstate.length); in sdp_client_ssa_search()
1650 session->param = param; in sdp_client_ssa_search()
1651 session->tid++; in sdp_client_ssa_search()
1653 return bt_sdp_send(&session->chan.chan, buf, BT_SDP_SVC_SEARCH_ATTR_REQ, in sdp_client_ssa_search()
1654 session->tid); in sdp_client_ssa_search()
1657 static void sdp_client_params_iterator(struct bt_sdp_client *session);
1659 static int sdp_client_discover(struct bt_sdp_client *session) in sdp_client_discover() argument
1670 if (!session->param) { in sdp_client_discover()
1671 param = GET_PARAM(sys_slist_peek_head(&session->reqs)); in sdp_client_discover()
1673 param = session->param; in sdp_client_discover()
1677 struct bt_l2cap_chan *chan = &session->chan.chan; in sdp_client_discover()
1686 err = sdp_client_ss_search(session, param); in sdp_client_discover()
1689 err = sdp_client_sa_search(session, param); in sdp_client_discover()
1692 err = sdp_client_ssa_search(session, param); in sdp_client_discover()
1701 sdp_client_params_iterator(session); in sdp_client_discover()
1707 static void sdp_client_params_iterator(struct bt_sdp_client *session) in sdp_client_params_iterator() argument
1709 struct bt_l2cap_chan *chan = &session->chan.chan; in sdp_client_params_iterator()
1712 SYS_SLIST_FOR_EACH_CONTAINER_SAFE(&session->reqs, param, tmp, _node) { in sdp_client_params_iterator()
1713 if (param != session->param) { in sdp_client_params_iterator()
1720 sys_slist_remove(&session->reqs, NULL, &param->_node); in sdp_client_params_iterator()
1722 session->param = NULL; in sdp_client_params_iterator()
1724 (void)memset(&session->cstate, 0, sizeof(session->cstate)); in sdp_client_params_iterator()
1727 if (!sys_slist_is_empty(&session->reqs)) { in sdp_client_params_iterator()
1728 sdp_client_discover(session); in sdp_client_params_iterator()
1738 static uint16_t sdp_client_get_total(struct bt_sdp_client *session, in sdp_client_get_total() argument
1751 if (session->cstate.length == 0U) { in sdp_client_get_total()
1818 static uint16_t get_record_len(struct bt_sdp_client *session) in get_record_len() argument
1823 buf = session->rec_buf; in get_record_len()
1825 if (!session->param) { in get_record_len()
1829 switch (session->param->type) { in get_record_len()
1852 static void sdp_client_notify_result(struct bt_sdp_client *session, in sdp_client_notify_result() argument
1855 struct bt_conn *conn = session->chan.chan.conn; in sdp_client_notify_result()
1863 session->param->func(conn, &result, session->param); in sdp_client_notify_result()
1867 while (session->rec_buf->len) { in sdp_client_notify_result()
1870 rec_len = get_record_len(session); in sdp_client_notify_result()
1872 if (session->rec_buf->len > rec_len) { in sdp_client_notify_result()
1879 net_buf_simple_save(&session->rec_buf->b, &buf_state); in sdp_client_notify_result()
1881 result.resp_buf = session->rec_buf; in sdp_client_notify_result()
1889 user_ret = session->param->func(conn, &result, session->param); in sdp_client_notify_result()
1892 net_buf_simple_restore(&session->rec_buf->b, &buf_state); in sdp_client_notify_result()
1897 net_buf_pull(session->rec_buf, rec_len); in sdp_client_notify_result()
1904 static int sdp_client_receive_ss(struct bt_sdp_client *session, struct net_buf *buf) in sdp_client_receive_ss() argument
1935 received_count = session->rec_buf->len / SDP_RECORD_HANDLE_SIZE; in sdp_client_receive_ss()
1965 if (!current_count && cstate->length == 0U && session->cstate.length == 0U) { in sdp_client_receive_ss()
1966 LOG_DBG("Service record handle 0x%x not found", session->param->handle); in sdp_client_receive_ss()
1968 sdp_client_notify_result(session, UUID_NOT_RESOLVED); in sdp_client_receive_ss()
1973 if (record_len > net_buf_tailroom(session->rec_buf)) { in sdp_client_receive_ss()
1978 net_buf_add_mem(session->rec_buf, buf->data, record_len); in sdp_client_receive_ss()
1984 memcpy(&session->cstate, cstate, sizeof(struct bt_sdp_pdu_cstate)); in sdp_client_receive_ss()
1989 return sdp_client_discover(session); in sdp_client_receive_ss()
1994 LOG_DBG("UUID 0x%s resolved", bt_uuid_str(session->param->uuid)); in sdp_client_receive_ss()
1995 sdp_client_notify_result(session, UUID_RESOLVED); in sdp_client_receive_ss()
1998 sdp_client_params_iterator(session); in sdp_client_receive_ss()
2003 static int sdp_client_receive_ssa_sa(struct bt_sdp_client *session, struct net_buf *buf) in sdp_client_receive_ssa_sa() argument
2046 if (frame_len == 2U && cstate->length == 0U && session->cstate.length == 0U) { in sdp_client_receive_ssa_sa()
2047 LOG_DBG("Record for UUID 0x%s not found", bt_uuid_str(session->param->uuid)); in sdp_client_receive_ssa_sa()
2049 sdp_client_notify_result(session, UUID_NOT_RESOLVED); in sdp_client_receive_ssa_sa()
2055 frame_len -= sdp_client_get_total(session, buf, &total); in sdp_client_receive_ssa_sa()
2057 if (total > net_buf_tailroom(session->rec_buf)) { in sdp_client_receive_ssa_sa()
2062 net_buf_add_mem(session->rec_buf, buf->data, frame_len); in sdp_client_receive_ssa_sa()
2068 memcpy(&session->cstate, cstate, sizeof(struct bt_sdp_pdu_cstate)); in sdp_client_receive_ssa_sa()
2073 return sdp_client_discover(session); in sdp_client_receive_ssa_sa()
2078 LOG_DBG("UUID 0x%s resolved", bt_uuid_str(session->param->uuid)); in sdp_client_receive_ssa_sa()
2079 sdp_client_notify_result(session, UUID_RESOLVED); in sdp_client_receive_ssa_sa()
2082 sdp_client_params_iterator(session); in sdp_client_receive_ssa_sa()
2089 struct bt_sdp_client *session = SDP_CLIENT_CHAN(chan); in sdp_client_receive() local
2093 LOG_DBG("session %p buf %p", session, buf); in sdp_client_receive()
2111 if (tid != session->tid) { in sdp_client_receive()
2118 return sdp_client_receive_ss(session, buf); in sdp_client_receive()
2122 return sdp_client_receive_ssa_sa(session, buf); in sdp_client_receive()
2125 sdp_client_notify_result(session, UUID_NOT_RESOLVED); in sdp_client_receive()
2126 sdp_client_params_iterator(session); in sdp_client_receive()
2136 static int sdp_client_chan_connect(struct bt_sdp_client *session) in sdp_client_chan_connect() argument
2138 return bt_l2cap_br_chan_connect(session->chan.chan.conn, &session->chan.chan, SDP_PSM); in sdp_client_chan_connect()
2143 struct bt_sdp_client *session = SDP_CLIENT_CHAN(chan); in sdp_client_alloc_buf() local
2146 LOG_DBG("session %p chan %p", session, chan); in sdp_client_alloc_buf()
2148 session->param = GET_PARAM(sys_slist_peek_head(&session->reqs)); in sdp_client_alloc_buf()
2150 buf = net_buf_alloc(session->param->pool, K_FOREVER); in sdp_client_alloc_buf()
2158 struct bt_sdp_client *session = SDP_CLIENT_CHAN(chan); in sdp_client_connected() local
2160 LOG_DBG("session %p chan %p connected", session, chan); in sdp_client_connected()
2162 session->rec_buf = chan->ops->alloc_buf(chan); in sdp_client_connected()
2163 if (!session->rec_buf) { in sdp_client_connected()
2168 sdp_client_discover(session); in sdp_client_connected()
2173 struct bt_sdp_client *session = SDP_CLIENT_CHAN(chan); in sdp_client_disconnected() local
2175 LOG_DBG("session %p chan %p disconnected", session, chan); in sdp_client_disconnected()
2177 if (session->rec_buf) { in sdp_client_disconnected()
2178 net_buf_unref(session->rec_buf); in sdp_client_disconnected()
2185 (void)memset(&session->reqs, 0, in sdp_client_disconnected()
2186 sizeof(*session) - sizeof(session->chan)); in sdp_client_disconnected()
2201 struct bt_sdp_client *session = &bt_sdp_client_pool[i]; in sdp_client_new_session() local
2204 if (session->chan.chan.conn) { in sdp_client_new_session()
2208 sys_slist_init(&session->reqs); in sdp_client_new_session()
2210 session->chan.chan.ops = &sdp_client_chan_ops; in sdp_client_new_session()
2211 session->chan.chan.conn = conn; in sdp_client_new_session()
2212 session->chan.rx.mtu = SDP_CLIENT_MTU; in sdp_client_new_session()
2214 err = sdp_client_chan_connect(session); in sdp_client_new_session()
2216 (void)memset(session, 0, sizeof(*session)); in sdp_client_new_session()
2221 return session; in sdp_client_new_session()
2249 struct bt_sdp_client *session; in bt_sdp_discover() local
2256 session = sdp_client_get_session(conn); in bt_sdp_discover()
2257 if (!session) { in bt_sdp_discover()
2261 sys_slist_append(&session->reqs, (sys_snode_t *)&params->_node); in bt_sdp_discover()