Logo
  • Built-in search
  • Google search
Zephyr Project v: latest
Document Release Versions
latest
4.1.0
4.0.0
3.7.0 (LTS)
Downloads
PDF
zephyrproject.org Links
Project Home
SDK
Releases
  • Introduction
  • Developing with Zephyr
  • Kernel
  • OS Services
  • Build and Configuration Systems
  • Connectivity
    • Bluetooth
      • Supported features
      • Qualification
      • Stack Architecture
      • LE Host
      • LE Audio Stack
      • LE Audio resources
      • LE Controller
      • Application Development
      • API
        • Bluetooth Classic Host and profiles
        • Bluetooth LE Audio
        • Bluetooth LE Host
        • Bluetooth Mesh
        • Core Host and drivers
          • Logical Link Control and Adaptation Protocol (L2CAP)
          • Connection Management
          • Data Buffers
          • HCI Drivers
          • HCI RAW channel
          • Cryptography
        • Other
      • Tools
      • Shell
    • Controller Area Network (CAN) Bus Protocols
    • Networking
    • LoRa and LoRaWAN
    • USB
  • Hardware Support
  • Contributing to Zephyr
  • Project and Governance
  • Security
  • Safety
  • Samples and Demos
  • Supported Boards and Shields
  • Shields
  • Releases

Reference

  • API
  • Kconfig Options
  • Devicetree Bindings
  • West Projects
Zephyr Project
  • Docs / Latest »
  • Connectivity »
  • Bluetooth »
  • API »
  • Logical Link Control and Adaptation Protocol (L2CAP)
  • Open on GitHub Report an issue with this page

Logical Link Control and Adaptation Protocol (L2CAP)

L2CAP layer enables connection-oriented channels which can be enable with the configuration option: CONFIG_BT_L2CAP_DYNAMIC_CHANNEL. This channels support segmentation and reassembly transparently, they also support credit based flow control making it suitable for data streams.

Channels instances are represented by the bt_l2cap_chan struct which contains the callbacks in the bt_l2cap_chan_ops struct to inform when the channel has been connected, disconnected or when the encryption has changed. In addition to that it also contains the recv callback which is called whenever an incoming data has been received. Data received this way can be marked as processed by returning 0 or using bt_l2cap_chan_recv_complete() API if processing is asynchronous.

Note

The recv callback is called directly from RX Thread thus it is not recommended to block for long periods of time.

For sending data the bt_l2cap_chan_send() API can be used noting that it may block if no credits are available, and resuming as soon as more credits are available.

Servers can be registered using bt_l2cap_server_register() API passing the bt_l2cap_server struct which informs what psm it should listen to, the required security level sec_level, and the callback accept which is called to authorize incoming connection requests and allocate channel instances.

Client channels can be initiated with use of bt_l2cap_chan_connect() API and can be disconnected with the bt_l2cap_chan_disconnect() API. Note that the later can also disconnect channel instances created by servers.

API Reference

L2CAP

© Copyright 2015-2025 Zephyr Project members and individual contributors.

Last generated: May 11, 2025. Last source update: Apr 04, 2022.