bluetooth.rst 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. Bluetooth® Overview
  2. ===================
  3. :link_to_translation:`zh_CN:[中文]`
  4. This document provides an architecture overview of the Bluetooth stack in ESP-IDF and some quick links to related documents and application examples.
  5. .. only:: esp32
  6. {IDF_TARGET_NAME} supports Dual-Mode Bluetooth 4.2 and is certified for Bluetooth 4.2.
  7. .. only:: esp32c3 or esp32s3
  8. {IDF_TARGET_NAME} supports Bluetooth 5.0 (LE) and is certified for Bluetooth LE 5.0.
  9. .. only:: esp32c2 or esp32c6 or esp32h2
  10. {IDF_TARGET_NAME} supports Bluetooth 5.0 (LE) and is certified for Bluetooth LE 5.3.
  11. The Bluetooth stack in ESP-IDF is a layered architecture that enables Bluetooth functionality on {IDF_TARGET_NAME} chip series. The table below shows its architecture.
  12. .. only:: esp32 or esp32s3 or esp32c3 or esp32c6
  13. .. figure:: ../../_static/bluetooth-architecture.png
  14. :align: center
  15. :scale: 90%
  16. :alt: {IDF_TARGET_NAME} Bluetooth Stack Architecture
  17. {IDF_TARGET_NAME} Bluetooth Stack Architecture
  18. .. only:: esp32c2
  19. .. figure:: ../../_static/bluetooth-architecture-no-ble-mesh.png
  20. :align: center
  21. :scale: 90%
  22. :alt: {IDF_TARGET_NAME} Bluetooth Stack Architecture
  23. {IDF_TARGET_NAME} Bluetooth Stack Architecture
  24. .. only:: esp32h2
  25. .. figure:: ../../_static/bluetooth-architecture-no-blufi.png
  26. :align: center
  27. :scale: 90%
  28. :alt: {IDF_TARGET_NAME} Bluetooth Stack Architecture
  29. {IDF_TARGET_NAME} Bluetooth Stack Architecture
  30. The table below shows whether the Bluetooth modules are supported in a specific chip series.
  31. .. list-table::
  32. :width: 100%
  33. :widths: auto
  34. :header-rows: 1
  35. * - Chip Series
  36. - Controller
  37. - ESP-Bluedroid
  38. - ESP-NimBLE
  39. - ESP-BLE-MESH
  40. - BluFi
  41. * - ESP32
  42. - Y
  43. - Y
  44. - Y
  45. - Y
  46. - Y
  47. * - ESP32-S2
  48. - \–
  49. - \–
  50. - \–
  51. - \–
  52. - \–
  53. * - ESP32-S3
  54. - Y
  55. - Y
  56. - Y
  57. - Y
  58. - Y
  59. * - ESP32-C2
  60. - Y
  61. - Y
  62. - Y
  63. - \–
  64. - Y
  65. * - ESP32-C3
  66. - Y
  67. - Y
  68. - Y
  69. - Y
  70. - Y
  71. * - ESP32-C6
  72. - Y
  73. - Y
  74. - Y
  75. - Y
  76. - Y
  77. * - ESP32-H2
  78. - Y
  79. - Y
  80. - Y
  81. - Y
  82. - \–
  83. The following sections briefly describe each layer and provide quick links to the related documents and application examples.
  84. ESP Bluetooth Controller
  85. ------------------------
  86. At the bottom layer is ESP Bluetooth Controller, which encompasses various modules such as PHY, Baseband, Link Controller, Link Manager, Device Manager, and HCI. It handles hardware interface management and link management. It provides functions in the form of libraries and is accessible through APIs. This layer directly interacts with the hardware and low-level Bluetooth protocols.
  87. - :doc:`API reference <../api-reference/bluetooth/controller_vhci>`
  88. - :example:`Application examples <bluetooth/hci>`
  89. Hosts
  90. -----
  91. There are two hosts, ESP-Bluedroid and ESP-NimBLE. The major difference between them is as follows:
  92. - Although both support Bluetooth LE, ESP-NimBLE requires less heap and flash size.
  93. .. only:: esp32
  94. - ESP-Bluedroid supports both Classic Bluetooth and Bluetooth LE, while ESP-NimBLE only supports Bluetooth LE.
  95. ESP-Bluedroid
  96. ^^^^^^^^^^^^^
  97. ESP-Bluedroid is a modified version of the native Android Bluetooth stack, Bluedroid. It consists of two layers: the Bluetooth Upper Layer (BTU) and the Bluetooth Transport Controller layer (BTC). The BTU layer is responsible for processing bottom layer Bluetooth protocols such as L2CAP, GATT/ATT, SMP, GAP, and other profiles. The BTU layer provides an interface prefixed with "bta". The BTC layer is mainly responsible for providing a supported interface, prefixed with "esp", to the application layer, processing GATT-based profiles and handling miscellaneous tasks. All the APIs are located in the ESP_API layer. Developers should use the Bluetooth APIs prefixed with "esp".
  98. .. only:: esp32
  99. ESP-Bluedroid for {IDF_TARGET_NAME} supports Classic Bluetooth and Bluetooth LE.
  100. .. only:: not esp32
  101. ESP-Bluedroid for {IDF_TARGET_NAME} supports Bluetooth LE only. Classic Bluetooth is not supported.
  102. - API references
  103. - :doc:`../api-reference/bluetooth/bt_common`
  104. - :doc:`Bluetooth LE <../api-reference/bluetooth/bt_le>`
  105. .. only:: esp32
  106. - :doc:`../api-reference/bluetooth/classic_bt`
  107. - :example:`Application examples <bluetooth/bluedroid>`
  108. ESP-NimBLE
  109. ^^^^^^^^^^
  110. ESP-NimBLE is a host stack built on top of the NimBLE host stack developed by Apache Mynewt. The NimBLE host stack is ported for {IDF_TARGET_NAME} chip series and FreeRTOS. The porting layer is kept clean by maintaining all the existing APIs of NimBLE along with a single ESP-NimBLE API for initialization, making it simpler for the application developers.
  111. ESP-NimBLE supports Bluetooth LE only. Classic Bluetooth is not supported.
  112. - `Apache Mynewt NimBLE User Guide <https://mynewt.apache.org/latest/network/index.html>`__
  113. - API references
  114. - `NimBLE API references <https://mynewt.apache.org/latest/network/ble_hs/ble_hs.html>`__
  115. - :doc:`ESP-NimBLE API references for initialization <../api-reference/bluetooth/nimble/index>`
  116. - :example:`Application examples <bluetooth/nimble>`
  117. Profiles
  118. --------
  119. Above the host stacks are the profile implementations by Espressif and some common profiles. Depending on your configuration, these profiles can run on ESP-Bluedroid or ESP-NimBLE.
  120. .. only:: SOC_BLE_MESH_SUPPORTED
  121. ESP-BLE-MESH
  122. ^^^^^^^^^^^^
  123. Built on top of Zephyr Bluetooth Mesh stack, the ESP-BLE-MESH implementation supports device provisioning and node control. It also supports such node features as Proxy, Relay, Low power and Friend.
  124. - :doc:`ESP-BLE-MESH documentation <esp-ble-mesh/ble-mesh-index>`: feature list, get started, architecture, description of application examples, frequently asked questions, etc.
  125. - :example:`Application examples <bluetooth/esp_ble_mesh>`
  126. .. only:: SOC_BLUFI_SUPPORTED
  127. BluFi
  128. ^^^^^
  129. The BluFi for {IDF_TARGET_NAME} is a Wi-Fi network configuration function via Bluetooth channel. It provides a secure protocol to pass Wi-Fi configuration and credentials to {IDF_TARGET_NAME}. Using this information, {IDF_TARGET_NAME} can then connect to an AP or establish a softAP.
  130. - :doc:`BluFi documentation <blufi>`
  131. - :example:`Application examples <bluetooth/blufi>`
  132. Applications
  133. ------------
  134. At the uppermost layer are applications. You can build your own applications on top of the ESP-Bluedroid and ESP-NimBLE stacks, leveraging the provided APIs and profiles to create Bluetooth-enabled applications tailored to specific use cases.