Function esp_idf_sys::esp_bt_mem_release

source ยท
pub unsafe extern "C" fn esp_bt_mem_release(
    mode: esp_bt_mode_t,
) -> esp_err_t
Expand description

@brief Release the Controller memory, BSS and data section of the Classic Bluetooth/BLE Host stack as per the mode

@note

  1. This function is optional and should be called only if you want to free up memory for other components.
  2. This function should only be called when the controller is in ESP_BT_CONTROLLER_STATUS_IDLE status.
  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.
  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.

This function first releases Controller memory by internally calling esp_bt_controller_mem_release(), then releases Host memory.

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.

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.

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.

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, after receiving the Wi-Fi configuration, you can disable/de-init Bluetooth and release its memory. Below is the sequence of APIs to be called for such scenarios:

  esp_bluedroid_disable();
  esp_bluedroid_deinit();
  esp_bt_controller_disable();
  esp_bt_controller_deinit();
  esp_bt_mem_release(ESP_BT_MODE_BTDM);

@param[in] mode The Bluetooth Controller mode

@return - ESP_OK: Success - ESP_ERR_INVALID_STATE: Invalid Bluetooth Controller state - ESP_ERR_NOT_FOUND: Requested resource not found