1.. _bt_l2cap: 2 3Logical Link Control and Adaptation Protocol (L2CAP) 4#################################################### 5 6L2CAP layer enables connection-oriented channels which can be enable with the 7configuration option: :kconfig:option:`CONFIG_BT_L2CAP_DYNAMIC_CHANNEL`. This channels 8support segmentation and reassembly transparently, they also support credit 9based flow control making it suitable for data streams. 10 11Channels instances are represented by the :c:struct:`bt_l2cap_chan` struct which 12contains the callbacks in the :c:struct:`bt_l2cap_chan_ops` struct to inform 13when the channel has been connected, disconnected or when the encryption has 14changed. 15In addition to that it also contains the ``recv`` callback which is called 16whenever an incoming data has been received. Data received this way can be 17marked as processed by returning 0 or using 18:c:func:`bt_l2cap_chan_recv_complete` API if processing is asynchronous. 19 20.. note:: 21 The ``recv`` callback is called directly from RX Thread thus it is not 22 recommended to block for long periods of time. 23 24For sending data the :c:func:`bt_l2cap_chan_send` API can be used noting that 25it may block if no credits are available, and resuming as soon as more credits 26are available. 27 28Servers can be registered using :c:func:`bt_l2cap_server_register` API passing 29the :c:struct:`bt_l2cap_server` struct which informs what ``psm`` it should 30listen to, the required security level ``sec_level``, and the callback 31``accept`` which is called to authorize incoming connection requests and 32allocate channel instances. 33 34Client channels can be initiated with use of :c:func:`bt_l2cap_chan_connect` 35API and can be disconnected with the :c:func:`bt_l2cap_chan_disconnect` API. 36Note that the later can also disconnect channel instances created by servers. 37 38API Reference 39************* 40 41.. doxygengroup:: bt_l2cap 42