Skip to content

Commit d4fc635

Browse files
committed
docs: Migrate ESP32 Bluetooth Architecture PDF content to ESP-IDF
1 parent 4f3e643 commit d4fc635

29 files changed

+1278
-118
lines changed
360 KB
Loading
181 KB
Loading
54.6 KB
Loading
312 KB
Loading

docs/conf_common.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
raise RuntimeError('IDF_PATH should be set, run export.sh before building docs')
1818

1919
BT_DOCS = [
20+
'api-guides/bt-architecture/index.rst',
21+
'api-guides/bt-architecture/overview.rst',
2022
'api-reference/bluetooth/esp_bt_defs.rst',
2123
'api-reference/bluetooth/esp_bt_device.rst',
2224
'api-reference/bluetooth/esp_bt_main.rst',
@@ -36,6 +38,7 @@
3638
'api-guides/ble/get-started/ble-device-discovery.rst',
3739
'api-guides/ble/get-started/ble-connection.rst',
3840
'api-guides/ble/get-started/ble-data-exchange.rst',
41+
'api-guides/ble/smp.rst',
3942
'api-reference/bluetooth/bt_le.rst',
4043
'api-reference/bluetooth/esp_gap_ble.rst',
4144
'api-reference/bluetooth/esp_gatt_defs.rst',
@@ -58,6 +61,7 @@
5861
CLASSIC_BT_DOCS = [
5962
'api-guides/classic-bt/index.rst',
6063
'api-guides/classic-bt/overview.rst',
64+
'api-guides/classic-bt/profiles-protocols.rst',
6165
'api-reference/bluetooth/classic_bt.rst',
6266
'api-reference/bluetooth/esp_a2dp.rst',
6367
'api-reference/bluetooth/esp_avrc.rst',

docs/en/api-guides/ble/get-started/ble-connection.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Basic Concepts
2121
Initiating a Connection
2222
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2323

24-
*With the introduction of extended advertising features in Bluetooth LE 5.0, there are slight differences in the connection establishment process between Legacy ADV and Extended ADV. Below, we take the Legacy ADV connection establishment process as an example.*
24+
*With the introduction of extended advertising features in Bluetooth Core Specification 5.0, there are slight differences in the connection establishment process between Legacy ADV and Extended ADV. Below, we take the Legacy ADV connection establishment process as an example.*
2525

2626
When a scanner receives an advertising packet on a specific advertising channel, if the advertiser is connectable, the scanner can send a connection request on the same advertising channel. The advertiser can set a *Filter Accept List* to filter out untrusted devices or accept connection requests from any scanner. Afterward, the advertiser becomes the peripheral device, and the scanner becomes the central device, allowing for bidirectional communication over the data channel.
2727

@@ -101,7 +101,7 @@ The structure of the Data Channel Packet is similar to that of the :ref:`Adverti
101101
* - 2
102102
- Payload
103103
- 0-27 / 0-251
104-
- Before Bluetooth LE 4.2, the maximum payload was 27 bytes; Bluetooth LE 4.2 introduced Data Length Extension (DLE), allowing a maximum payload of 251 bytes.
104+
- Before Bluetooth Core Specification 4.2, the maximum payload was 27 bytes; Bluetooth Core Specification 4.2 introduced Data Length Extension (DLE), allowing a maximum payload of 251 bytes.
105105
* - 3
106106
- Message Integrity Check, MIC
107107
- 4
@@ -124,9 +124,9 @@ The payload of the data PDU can be further divided into:
124124
- ATT Header + ATT Data
125125
- 0-23 / 0-247
126126

127-
The default MTU value is 23 bytes, which matches the maximum ATT data byte size that can be carried in a single data PDU before Bluetooth LE 4.2.
127+
The default MTU value is 23 bytes, which matches the maximum ATT data byte size that can be carried in a single data PDU before Bluetooth Core Specification 4.2.
128128

129-
MTU can be set to larger values, such as 140 bytes. Before Bluetooth LE 4.2, with a maximum of 23 bytes carrying ATT data in the payload, a complete ATT data packet would need to be split across multiple data PDUs. After Bluetooth LE 4.2, a single data PDU can carry up to 247 bytes of ATT data, so an MTU of 140 bytes can still be accommodated in a single data PDU.
129+
MTU can be set to larger values, such as 140 bytes. Before Bluetooth Core Specification 4.2, with a maximum of 23 bytes carrying ATT data in the payload, a complete ATT data packet would need to be split across multiple data PDUs. After Bluetooth Core Specification 4.2, a single data PDU can carry up to 247 bytes of ATT data, so an MTU of 140 bytes can still be accommodated in a single data PDU.
130130

131131

132132
Hands-On Practice

docs/en/api-guides/ble/get-started/ble-device-discovery.rst

Lines changed: 148 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ Bluetooth Channels
4141

4242
Similar to Bluetooth Classic, the Bluetooth SIG has adopted Adaptive Frequency Hopping (AFH) in Bluetooth LE to address data collision issues. This technology can assess the congestion of RF channels and avoid crowded channels through frequency hopping to improve communication quality. However, unlike Bluetooth Classic, Bluetooth LE uses the 2.4 GHz ISM band divided into 40 RF channels, each with a 2 MHz bandwidth, ranging from 2402 MHz to 2480 MHz, while Bluetooth Classic uses 79 RF channels, each with a 1 MHz bandwidth.
4343

44-
In the Bluetooth LE 4.2 standard, RF channels are categorized into two types, as follows:
44+
In Bluetooth Core Specification 4.2, RF channels are categorized into two types, as follows:
4545

4646
.. list-table::
4747
:align: center
@@ -67,7 +67,7 @@ During advertising, the advertiser will send advertising packets on the three ad
6767
Extended Advertising Features
6868
##################################
6969

70-
In the Bluetooth LE 4.2 standard, advertising packets are limited to a maximum of 31 bytes, which restricts the functionality of advertising. To enhance the capability of advertising, Bluetooth 5.0 introduced the Extended Advertising feature. This feature divides advertising packets into:
70+
In Bluetooth Core Specification 4.2, advertising packets are limited to a maximum of 31 bytes, which restricts the functionality of advertising. To enhance the capability of advertising, Bluetooth 5.0 introduced the Extended Advertising feature. This feature divides advertising packets into:
7171

7272
.. list-table::
7373
:align: center
@@ -124,7 +124,7 @@ What information is included in the advertising packet?
124124
Advertising Packet Structure
125125
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
126126

127-
For the third question, regarding the information contained in the advertising packet, the Bluetooth LE 4.2 standard defines the format of the advertising packet, as shown in the diagram below:
127+
For the third question, regarding the information contained in the advertising packet, Bluetooth Core Specification 4.2 defines the format of the advertising packet, as shown in the diagram below:
128128

129129

130130
.. _adv_packet_structure:
@@ -134,7 +134,7 @@ For the third question, regarding the information contained in the advertising p
134134
:scale: 35%
135135
:alt: Advertising Packet Structure
136136

137-
Bluetooth LE 4.2 Advertising Packet Structure
137+
Advertising Packet Structure in Bluetooth Core Specification 4.2
138138

139139

140140
Let’s break it down step by step. The outer layer of an advertising packet contains four parts, which are:
@@ -336,7 +336,7 @@ For devices using random private addresses to communicate with trusted devices,
336336
* - Non-resolvable Random Private Address
337337
- Completely random and rarely used, as it cannot be resolved and is only meant to prevent tracking
338338

339-
Let's look at the **advertising data**. The format of an advertising data structure is defined as follows:
339+
Let's look at the advertising data. The format of an advertising data structure is defined as follows:
340340

341341
.. list-table::
342342
:align: center
@@ -361,6 +361,148 @@ Let's look at the **advertising data**. The format of an advertising data struct
361361
-
362362

363363

364+
Advertising Process
365+
^^^^^^^^^^^^^^^^^^^^^
366+
367+
Advertising With a Public Address
368+
####################################
369+
370+
When using a public address for advertising, set the ``own_addr_type`` of ``esp_ble_adv_params_t`` to ``BLE_ADDR_TYPE_PUBLIC``. The advertising process flowchart is as follows (*click to enlarge*):
371+
372+
373+
.. seqdiag::
374+
:caption: Advertising With a Public Address
375+
:align: center
376+
:scale: 200%
377+
378+
seqdiag adv-public-addr {
379+
activation = none;
380+
edge_length = 160;
381+
span_height = 20;
382+
default_shape = roundedbox;
383+
default_fontsize = 14;
384+
385+
"Input\n[Advertiser]";
386+
"API\n[Advertiser]";
387+
"LLM\n[Advertiser]";
388+
"LLM\n[Scanner]";
389+
"API\n[Scanner]";
390+
"Output\n[Scanner]";
391+
392+
"Input\n[Advertiser]" -> "API\n[Advertiser]" [label="calls\n esp_ble_gap_set_device_name"];
393+
"Input\n[Advertiser]" -> "API\n[Advertiser]" [label="calls\n esp_ble_gap_config_adv_data"];
394+
"API\n[Advertiser]" -> "LLM\n[Advertiser]" [label="sends config adv data HCI command to LL layer"];
395+
"API\n[Advertiser]" <- "LLM\n[Advertiser]" [label="returns set adv data event"];
396+
"Input\n[Advertiser]" <- "API\n[Advertiser]" [label="returns\n esp_gap_ble_adv_data_set_complete_evt"];
397+
"Input\n[Advertiser]" -> "API\n[Advertiser]" [label="calls\n esp_ble_gap_start_advertising to start advertising; sets the own_addr_type parameter to ble_addr_type_public"];
398+
"API\n[Advertiser]" -> "LLM\n[Advertiser]" [label="sends start adv HCI command to LL layer"];
399+
"API\n[Advertiser]" <- "LLM\n[Advertiser]" [label="returns start adv event"];
400+
"LLM\n[Advertiser]" -> "LLM\n[Scanner]" [label="advertising event"];
401+
"LLM\n[Advertiser]" -> "LLM\n[Scanner]" [label="advertising event"];
402+
"Input\n[Advertiser]" <- "API\n[Advertiser]" [label="returns\n esp_gap_ble_adv_start_complete_evt"];
403+
"LLM\n[Scanner]" -> "API\n[Scanner]";
404+
"API\n[Scanner]" -> "Output\n[Scanner]" [label="esp_gap_ble_scan_result_evt"];
405+
}
406+
407+
408+
Advertising With a Resolvable Random Private Address
409+
##########################################################
410+
411+
When using a resolvable random private address for advertising, the underlying protocol stack updates the advertising address when the resolvable random private address times out. The default timeout is set to 15 minutes. The timeout duration for the resolvable random private address can be configured using the ``BT_BLE_RPA_TIMEOUT`` option in menuconfig. Set the ``own_addr_type`` of ``esp_ble_adv_params_t`` to ``BLE_ADDR_TYPE_RPA_PUBLIC`` or ``BLE_ADDR_TYPE_RPA_RANDOM``. The advertising process flowchart is as follows (*click to enlarge*):
412+
413+
414+
.. seqdiag::
415+
:caption: Advertising With a Resolvable Random Private Address
416+
:align: center
417+
:scale: 200%
418+
419+
seqdiag adv-resolvable-addr {
420+
activation = none;
421+
edge_length = 160;
422+
span_height = 20;
423+
default_shape = roundedbox;
424+
default_fontsize = 14;
425+
426+
"Input\n[Advertiser]";
427+
"API\n[Advertiser]";
428+
"LLM\n[Advertiser]";
429+
"LLM\n[Scanner]";
430+
"API\n[Scanner]";
431+
"Output\n[Scanner]";
432+
433+
"Input\n[Advertiser]" -> "API\n[Advertiser]" [label="calls\n esp_ble_gap_set_device_name"];
434+
"Input\n[Advertiser]" -> "API\n[Advertiser]" [label="calls\n esp_ble_gap_config_local_privacy"];
435+
"Input\n[Advertiser]" -> "API\n[Advertiser]" [label="calls\n esp_ble_gap_config_adv_data"];
436+
"API\n[Advertiser]" -> "LLM\n[Advertiser]" [label="sends config adv data HCI command to LL layer"];
437+
"API\n[Advertiser]" <- "LLM\n[Advertiser]" [label="returns set adv data event"];
438+
"Input\n[Advertiser]" <- "API\n[Advertiser]" [label="returns\n esp_gap_ble_adv_data_set_complete_evt"];
439+
"Input\n[Advertiser]" -> "API\n[Advertiser]" [label="calls\n esp_ble_gap_start_advertising to start advertising; sets the own_addr_type parameter to ble_addr_type_rpa_public or ble_addr_type_rpa_random"];
440+
"API\n[Advertiser]" -> "LLM\n[Advertiser]" [label="sends start adv HCI command to LL layer"];
441+
"API\n[Advertiser]" <- "LLM\n[Advertiser]" [label="returns start adv event"];
442+
"LLM\n[Advertiser]" -> "LLM\n[Scanner]" [label="advertising event"];
443+
"LLM\n[Advertiser]" -> "LLM\n[Scanner]" [label="advertising event"];
444+
"Input\n[Advertiser]" <- "API\n[Advertiser]" [label="returns\n esp_gap_ble_adv_start_complete_evt"];
445+
"LLM\n[Scanner]" -> "API\n[Scanner]";
446+
"API\n[Scanner]" -> "Output\n[Scanner]" [label="esp_gap_ble_scan_result_evt"];
447+
}
448+
449+
450+
.. note::
451+
452+
When advertising with a resolvable random private address, advertising should start only after the ``esp_ble_gap_config_local_privacy`` event returns. Set ``own_addr_type`` to ``BLE_ADDR_TYPE_RPA_PUBLIC`` or ``BLE_ADDR_TYPE_RPA_RANDOM``.
453+
454+
To use ``BLE_ADDR_TYPE_RPA_RANDOM``, a random static address must be set through the ``esp_ble_gap_set_rand_addr`` API. This step is not required for ``BLE_ADDR_TYPE_RPA_PUBLIC``.
455+
456+
``BLE_ADDR_TYPE_RPA_PUBLIC`` operates as follows: The controller generates a Resolvable Random Private Address (RPA) based on the local Identity Resolving Key (IRK) from the resolving list. If no matching entry is found in the resolving list, the public address is used.
457+
458+
For ``BLE_ADDR_TYPE_RPA_RANDOM``, If no matching entry is found in the resolving list, a random static address is used.
459+
460+
461+
Advertising with a Random Static Address
462+
###########################################
463+
464+
Similar to advertising with a resolvable random private address, advertising with a random static address requires setting the ``own_addr_type`` of ``esp_ble_adv_params_t`` to ``BLE_ADDR_TYPE_RANDOM``. The advertising process flowchart is as follows (*click to enlarge*):
465+
466+
467+
.. seqdiag::
468+
:caption: Advertising With a Random Static Address
469+
:align: center
470+
:scale: 200%
471+
472+
seqdiag adv-random-addr {
473+
activation = none;
474+
edge_length = 160;
475+
span_height = 20;
476+
default_shape = roundedbox;
477+
default_fontsize = 14;
478+
479+
"Input\n[Advertiser]";
480+
"API\n[Advertiser]";
481+
"LLM\n[Advertiser]";
482+
"LLM\n[Scanner]";
483+
"API\n[Scanner]";
484+
"Output\n[Scanner]";
485+
486+
"Input\n[Advertiser]" -> "API\n[Advertiser]" [label="calls\n esp_ble_gap_set_device_name"];
487+
"Input\n[Advertiser]" -> "API\n[Advertiser]" [label="calls\n esp_ble_gap_set_rand_addr"];
488+
"API\n[Advertiser]" -> "LLM\n[Advertiser]" [label="sends set rand address HCI command to LL layer"];
489+
"API\n[Advertiser]" <- "LLM\n[Advertiser]" [label="returns set rand address event"];
490+
"Input\n[Advertiser]" <- "API\n[Advertiser]" [label="returns\n esp_gap_ble_set_static_rand_addr_evt"];
491+
"API\n[Advertiser]" -> "LLM\n[Advertiser]" [label="sends config adv data HCI command to LL layer"];
492+
"Input\n[Advertiser]" -> "API\n[Advertiser]" [label="calls\n esp_ble_gap_config_adv_data"];
493+
"API\n[Advertiser]" <- "LLM\n[Advertiser]" [label="return set adv data event"];
494+
"Input\n[Advertiser]" <- "API\n[Advertiser]" [label="calls\n esp_gap_ble_adv_data_set_complete_evt"];
495+
"Input\n[Advertiser]" -> "API\n[Advertiser]" [label="calls\n esp_ble_gap_start_advertising to start advertising; sets the own_addr_type parameter to ble_addr_type_random"];
496+
"API\n[Advertiser]" -> "LLM\n[Advertiser]" [label="sends start adv HCI command to LL layer"];
497+
"LLM\n[Advertiser]" -> "LLM\n[Scanner]" [label="advertising event"];
498+
"LLM\n[Advertiser]" -> "LLM\n[Scanner]" [label="advertising event"];
499+
"API\n[Advertiser]" <- "LLM\n[Advertiser]" [label="returns start adv event"];
500+
"Input\n[Advertiser]" <- "API\n[Advertiser]" [label="returns\n esp_gap_ble_adv_start_complete_evt"];
501+
"LLM\n[Scanner]" -> "API\n[Scanner]";
502+
"API\n[Scanner]" -> "Output\n[Scanner]" [label="esp_gap_ble_scan_result_evt"];
503+
}
504+
505+
364506
Basic Concepts of Scanning
365507
^^^^^^^^^^^^^^^^^^^^^^^^^^
366508

@@ -370,8 +512,7 @@ Similar to the advertising process, scanning also raises three questions:
370512
2. When to scan and for how long? (When?)
371513
3. What to do during scanning? (What?)
372514

373-
For Bluetooth LE 4.2 devices, the advertiser only sends data on the advertising channels, which are channels 37-39. For Bluetooth LE 5.0 devices, if the advertiser has enabled extended advertising, it sends `ADV_EXT_IND` on the primary advertising channels and `AUX_ADV_IND` on the secondary advertising channels.
374-
Thus, for Bluetooth LE 4.2 devices, scanners only need to receive advertising data on advertising channels. For Bluetooth LE 5.0 devices, scanners must first receive the `ADV_EXT_IND` on the primary advertising channels and, if it indicates a secondary channel, move to the corresponding secondary channel to receive the `AUX_ADV_IND`.
515+
For Bluetooth LE 4.2 devices, the advertiser only sends data on the advertising channels, which are channels 37-39. For Bluetooth LE 5.0 devices, if the advertiser has enabled extended advertising, it sends `ADV_EXT_IND` on the primary advertising channels and `AUX_ADV_IND` on the secondary advertising channels. Thus, for Bluetooth LE 4.2 devices, scanners only need to receive advertising data on advertising channels. For Bluetooth LE 5.0 devices, scanners must first receive the `ADV_EXT_IND` on the primary advertising channels and, if it indicates a secondary channel, move to the corresponding secondary channel to receive the `AUX_ADV_IND`.
375516

376517

377518
Scan Window and Scan Interval

docs/en/api-guides/ble/index.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,15 @@ Get Started
2626
get-started/ble-connection
2727
get-started/ble-data-exchange
2828

29+
***************
30+
Security
31+
***************
32+
33+
.. toctree::
34+
:maxdepth: 2
35+
36+
smp
37+
2938
**********
3039
Profile
3140
**********

docs/en/api-guides/ble/overview.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ This document provides an architecture overview of the Bluetooth Low Energy (Blu
1717

1818
{IDF_TARGET_NAME} supports Bluetooth 5.0 (LE) and is certified for Bluetooth LE 5.3.
1919

20-
The Bluetooth LE stack in ESP-IDF is a layered architecture that enables Bluetooth functionality on {IDF_TARGET_NAME} chip series. The table below shows its architecture.
20+
The Bluetooth LE stack in ESP-IDF is a layered architecture that enables Bluetooth functionality on {IDF_TARGET_NAME} chip series. The figure below shows its architecture.
2121

2222
.. only:: esp32 or esp32s3 or esp32c3 or esp32c6 or esp32c5 or esp32c61
2323

0 commit comments

Comments
 (0)