Skip to content

Commit 300750b

Browse files
committed
docs(ble): Revised the explanation for esp_bt_mem_release and esp_bt_controller_mem_release
1 parent 6df549d commit 300750b

File tree

1 file changed

+26
-22
lines changed
  • components/bt/include/esp32/include

1 file changed

+26
-22
lines changed

components/bt/include/esp32/include/esp_bt.h

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -472,11 +472,11 @@ typedef struct esp_vhci_host_callback {
472472
/**
473473
* @brief Check whether the Controller is ready to receive the packet
474474
*
475-
* If the return value is True, the Host can send the packet to the Controller.
475+
*If the return value is True, the Host can send the packet to the Controller.
476476
*
477-
* @note This function should be called before each `esp_vhci_host_send_packet()`.
477+
*@note This function should be called before each `esp_vhci_host_send_packet()`.
478478
*
479-
* @return
479+
*@return
480480
* True if the Controller is ready to receive packets; false otherwise
481481
*/
482482
bool esp_vhci_host_check_send_available(void);
@@ -509,17 +509,17 @@ esp_err_t esp_vhci_host_register_callback(const esp_vhci_host_callback_t *callba
509509
*
510510
* This function releases the BSS, data and other sections of the Controller to heap. The total size is about 70 KB.
511511
*
512-
* If the app calls `esp_bt_controller_enable(ESP_BT_MODE_BLE)` to use BLE only,
513-
* then it is safe to call `esp_bt_controller_mem_release(ESP_BT_MODE_CLASSIC_BT)` at initialization time to free unused Classic Bluetooth memory.
512+
* @note
513+
* 1. This function is optional and should be called only if you want to free up memory for other components.
514+
* 2. This function should only be called when the controller is in `ESP_BT_CONTROLLER_STATUS_IDLE` status.
515+
* 3. Once Bluetooth Controller memory is released, the process cannot be reversed. This means you cannot use the Bluetooth Controller mode that you have released using this function.
516+
* 4. If your firmware will upgrade the Bluetooth Controller mode later (such as switching from BLE to Classic Bluetooth or from disabled to enabled), then do not call this function.
514517
*
515-
* If the mode is `ESP_BT_MODE_BTDM`, then it may be useful to call API `esp_bt_mem_release(ESP_BT_MODE_BTDM)` instead,
516-
* which internally calls `esp_bt_controller_mem_release(ESP_BT_MODE_BTDM)` and additionally releases the BSS and data
517-
* consumed by the Classic Bluetooth/BLE Host stack to heap. For more details about usage please refer to the documentation of `esp_bt_mem_release()` function.
518+
* If you never intend to use Bluetooth in a current boot-up cycle, calling `esp_bt_controller_mem_release(ESP_BT_MODE_BTDM)` could release the BSS and data consumed by both Classic Bluetooth and BLE Controller to heap.
518519
*
519-
* @note
520-
* 1. This function should be called only before `esp_bt_controller_init()` or after `esp_bt_controller_deinit()`.
521-
* 2. Once Bluetooth Controller memory is released, the process cannot be reversed. This means you cannot use the Bluetooth Controller mode that you have released using this function.
522-
* 3. If your firmware will upgrade the Bluetooth Controller mode later (such as switching from BLE to Classic Bluetooth or from disabled to enabled), then do not call this function.
520+
* If you intend to use BLE only, calling `esp_bt_controller_mem_release(ESP_BT_MODE_CLASSIC_BT)` could release the BSS and data consumed by Classic Bluetooth Controller. You can then continue using BLE.
521+
*
522+
* If you intend to use Classic Bluetooth only, calling `esp_bt_controller_mem_release(ESP_BT_MODE_BLE)` could release the BSS and data consumed by BLE Controller. You can then continue using Classic Bluetooth.
523523
*
524524
* @param[in] mode The Bluetooth Controller mode
525525
*
@@ -530,13 +530,22 @@ esp_err_t esp_vhci_host_register_callback(const esp_vhci_host_callback_t *callba
530530
*/
531531
esp_err_t esp_bt_controller_mem_release(esp_bt_mode_t mode);
532532

533-
/** @brief Release the Controller memory, BSS and data section of the Classic Bluetooth/BLE Host stack as per the mode
533+
/**
534+
* @brief Release the Controller memory, BSS and data section of the Classic Bluetooth/BLE Host stack as per the mode
535+
*
536+
* @note
537+
* 1. This function is optional and should be called only if you want to free up memory for other components.
538+
* 2. This function should only be called when the controller is in `ESP_BT_CONTROLLER_STATUS_IDLE` status.
539+
* 3. Once Bluetooth Controller memory is released, the process cannot be reversed. This means you cannot use the Bluetooth Controller mode that you have released using this function.
540+
* 4. If your firmware will upgrade the Bluetooth Controller mode later (such as switching from BLE to Classic Bluetooth or from disabled to enabled), then do not call this function.
534541
*
535-
* This function first releases Controller memory by internally calling `esp_bt_controller_mem_release()`.
536-
* Additionally, if the mode is set to `ESP_BT_MODE_BTDM`, it also releases the BSS and data consumed by the Classic Bluetooth and BLE Host stack to heap.
542+
* This function first releases Controller memory by internally calling `esp_bt_controller_mem_release()`, then releases Host memory.
537543
*
538-
* If you never intend to use Bluetooth in a current boot-up cycle, you can call `esp_bt_mem_release(ESP_BT_MODE_BTDM)`
539-
* before `esp_bt_controller_init()` or after `esp_bt_controller_deinit()`.
544+
* If you never intend to use Bluetooth in a current boot-up cycle, calling `esp_bt_mem_release(ESP_BT_MODE_BTDM)` could release the BSS and data consumed by both Classic Bluetooth and BLE stack to heap.
545+
*
546+
* If you intend to use BLE only, calling `esp_bt_mem_release(ESP_BT_MODE_CLASSIC_BT)` could release the BSS and data consumed by Classic Bluetooth. You can then continue using BLE.
547+
*
548+
* If you intend to use Classic Bluetooth only, calling `esp_bt_mem_release(ESP_BT_MODE_BLE)` could release the BSS and data consumed by BLE. You can then continue using Classic Bluetooth.
540549
*
541550
* For example, if you only use Bluetooth for setting the Wi-Fi configuration, and do not use Bluetooth in the rest of the product operation,
542551
* after receiving the Wi-Fi configuration, you can disable/de-init Bluetooth and release its memory.
@@ -548,11 +557,6 @@ esp_err_t esp_bt_controller_mem_release(esp_bt_mode_t mode);
548557
* esp_bt_controller_deinit();
549558
* esp_bt_mem_release(ESP_BT_MODE_BTDM);
550559
*
551-
* @note
552-
* 1. Once Bluetooth Controller memory is released, the process cannot be reversed. This means you cannot use the Bluetooth Controller mode that you have released using this function.
553-
* 2. If your firmware will upgrade the Bluetooth Controller mode later (such as switching from BLE to Classic Bluetooth or from disabled to enabled), then do not call this function.
554-
* 3. In case of NimBLE Host, to release BSS and data memory to heap, the mode needs to be set to `ESP_BT_MODE_BTDM` as the Controller is in Dual mode.
555-
*
556560
* @param[in] mode The Bluetooth Controller mode
557561
*
558562
* @return

0 commit comments

Comments
 (0)